Add OpenMW commits up to 9 Mar 2019

# Conflicts:
#	.travis.yml
#	CI/before_script.linux.sh
#	README.md
#	apps/openmw/mwgui/jailscreen.cpp
#	apps/openmw/mwscript/animationextensions.cpp
#	apps/openmw/mwscript/guiextensions.cpp
#	apps/openmw/mwscript/miscextensions.cpp
#	apps/openmw/mwscript/soundextensions.cpp
pull/541/head
David Cernat 5 years ago
commit 8729c3c5e3

@ -9,7 +9,11 @@ env:
global: global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key # via the "travis encrypt" command using the project repo's public key
- secure: 1QK0yVyoOB+gf2I7XzvhXu9w/5lq4stBXIwJbVCTjz4Q4XVHCosURaW1MAgKzMrPnbFEwjyn5uQ8BwsvvfkuN1AZD0YXITgc7gyI+J1wQ/p/ljxRxglakU6WEgsTs2J5z9UmGac4YTXg+quK7YP3rv+zuGim2I2rhzImejyzp0Ym3kRCnNcy+SGBsiRaevRJMe00Ch8zGAbEhduQGeSoS6W0rcu02DNlQKiq5NktWsXR+TWWWVfIeIlQR/lbPsCd0pdxMaMv2QCY0rVbwrYxWJwr/Qe45dAdWp+8/C3PbXpeMSGxlLa33nJNX4Lf/djxbjm8KWk6edaXPajrjR/0iwcpwq0jg2Jt6XfEdnJt35F1gpXlc04sxStjG45uloOKCFYT0wdhIO1Lq+hDP54wypQl+JInd5qC001O7pwhVxO36EgKWqo8HD+BqGDBwsNj2engy9Qcp3wO6G0rLBPB3CrZsk9wrHVv5cSiQSLMhId3Xviu3ZI2qEDA+kgTvxrKrsnMj4bILVCyG5Ka2Mj22wIDW9e8oIab9oTdujax3DTN1GkD6QuOAGzwDsNwGASsgfoeZ+FUhgM75RlBWGMilgkmnF7EJ0oAXLEpjtABnEr2d4qHv+y08kOuTDBLB9ExzCIj024dYYYNLZrqPKx0ncHuCMG2QNj2aJAJEZtj1rQ= - secure: "1QK0yVyoOB+gf2I7XzvhXu9w/5lq4stBXIwJbVCTjz4Q4XVHCosURaW1MAgKzMrPnbFEwjyn5uQ8BwsvvfkuN1AZD0YXITgc7gyI+J1wQ/p/ljxRxglakU6WEgsTs2J5z9UmGac4YTXg+quK7YP3rv+zuGim2I2rhzImejyzp0Ym3kRCnNcy+SGBsiRaevRJMe00Ch8zGAbEhduQGeSoS6W0rcu02DNlQKiq5NktWsXR+TWWWVfIeIlQR/lbPsCd0pdxMaMv2QCY0rVbwrYxWJwr/Qe45dAdWp+8/C3PbXpeMSGxlLa33nJNX4Lf/djxbjm8KWk6edaXPajrjR/0iwcpwq0jg2Jt6XfEdnJt35F1gpXlc04sxStjG45uloOKCFYT0wdhIO1Lq+hDP54wypQl+JInd5qC001O7pwhVxO36EgKWqo8HD+BqGDBwsNj2engy9Qcp3wO6G0rLBPB3CrZsk9wrHVv5cSiQSLMhId3Xviu3ZI2qEDA+kgTvxrKrsnMj4bILVCyG5Ka2Mj22wIDW9e8oIab9oTdujax3DTN1GkD6QuOAGzwDsNwGASsgfoeZ+FUhgM75RlBWGMilgkmnF7EJ0oAXLEpjtABnEr2d4qHv+y08kOuTDBLB9ExzCIj024dYYYNLZrqPKx0ncHuCMG2QNj2aJAJEZtj1rQ="
cache:
ccache: true
directories:
- ${HOME}/.ccache
addons: addons:
apt: apt:
sources: sources:
@ -19,7 +23,7 @@ addons:
- llvm-toolchain-xenial-7 - llvm-toolchain-xenial-7
packages: [ packages: [
# Dev # Dev
cmake, clang-7, clang-tools-7, gcc-8, g++-8, cmake, clang-7, clang-tools-7, gcc-8, g++-8, ccache,
# Boost # Boost
libboost-filesystem-dev, libboost-iostreams-dev, libboost-program-options-dev, libboost-system-dev, libboost-filesystem-dev, libboost-iostreams-dev, libboost-program-options-dev, libboost-system-dev,
# FFmpeg # FFmpeg

@ -26,17 +26,21 @@ Programmers
Allofich Allofich
Andrei Kortunov (akortunov) Andrei Kortunov (akortunov)
AnyOldName3 AnyOldName3
Aussiemon Ardekantur
Austin Salgat (Salgat) Armin Preiml
Artem Kotsynyak (greye) Artem Kotsynyak (greye)
artemutin artemutin
Arthur Moore (EmperorArthur) Arthur Moore (EmperorArthur)
Assumeru Assumeru
athile athile
Aussiemon
Austin Salgat (Salgat)
Ben Shealy (bentsherman) Ben Shealy (bentsherman)
Berulacks
Bret Curtis (psi29a) Bret Curtis (psi29a)
Britt Mathis (galdor557) Britt Mathis (galdor557)
Capostrophic Capostrophic
Carl Maxwell
cc9cii cc9cii
Cédric Mocquillon Cédric Mocquillon
Chris Boyce (slothlife) Chris Boyce (slothlife)
@ -47,6 +51,7 @@ Programmers
DanielVukelich DanielVukelich
darkf darkf
David Cernat (davidcernat) David Cernat (davidcernat)
Declan Millar (declan-millar)
devnexen devnexen
Dieho Dieho
Dmitry Shkurskiy (endorph) Dmitry Shkurskiy (endorph)
@ -54,10 +59,11 @@ Programmers
Douglas Mencken (dougmencken) Douglas Mencken (dougmencken)
dreamer-dead dreamer-dead
David Teviotdale (dteviot) David Teviotdale (dteviot)
Diggory Hardy
Dmitry Marakasov (AMDmi3)
Edmondo Tommasina (edmondo) Edmondo Tommasina (edmondo)
Eduard Cot (trombonecot) Eduard Cot (trombonecot)
Eli2 Eli2
elsid
Emanuel Guével (potatoesmaster) Emanuel Guével (potatoesmaster)
eroen eroen
escondida escondida
@ -67,13 +73,19 @@ Programmers
Finbar Crago(finbar-crago) Finbar Crago(finbar-crago)
Florian Weber (Florianjw) Florian Weber (Florianjw)
Gašper Sedej Gašper Sedej
Gohan1989
gugus/gus gugus/gus
guidoj
Hallfaer Tuilinn Hallfaer Tuilinn
Haoda Wang (h313) Haoda Wang (h313)
hristoast hristoast
Internecine Internecine
Jacob Essex (Yacoby) Jackerty
Jacob Essex (Yacoby)
Jake Westrip (16bitint) Jake Westrip (16bitint)
James Carty (MrTopCat)
Jan-Peter Nilsson (peppe)
Jan Borsodi (am0s)
Jason Hooks (jhooks) Jason Hooks (jhooks)
jeaye jeaye
Jeffrey Haines (Jyby) Jeffrey Haines (Jyby)
@ -84,6 +96,7 @@ Programmers
John Blomberg (fstp) John Blomberg (fstp)
Jordan Ayers Jordan Ayers
Jordan Milne Jordan Milne
Josua Grawitter
Jules Blok (Armada651) Jules Blok (Armada651)
julianko julianko
Julien Voisin (jvoisin/ap0) Julien Voisin (jvoisin/ap0)
@ -95,9 +108,10 @@ Programmers
lazydev lazydev
Leon Krieg (lkrieg) Leon Krieg (lkrieg)
Leon Saunders (emoose) Leon Saunders (emoose)
Łukasz Gołębiewski (lukago)
logzero logzero
lohikaarme lohikaarme
Lordrea
Łukasz Gołębiewski (lukago)
Lukasz Gromanowski (lgro) Lukasz Gromanowski (lgro)
Manuel Edelmann (vorenon) Manuel Edelmann (vorenon)
Marc Bouvier (CramitDeFrog) Marc Bouvier (CramitDeFrog)
@ -112,6 +126,7 @@ Programmers
Michael Hogan (Xethik) Michael Hogan (Xethik)
Michael Mc Donnell Michael Mc Donnell
Michael Papageorgiou (werdanith) Michael Papageorgiou (werdanith)
Michał Ściubidło (mike-sc)
Michał Bień (Glorf) Michał Bień (Glorf)
Michał Moroz (dragonee) Michał Moroz (dragonee)
Miloslav Číž (drummyfish) Miloslav Číž (drummyfish)
@ -123,15 +138,20 @@ Programmers
Nathan Jeffords (blunted2night) Nathan Jeffords (blunted2night)
NeveHanter NeveHanter
Nialsy Nialsy
Nicolay Korslund
Nikolay Kasyanov (corristo) Nikolay Kasyanov (corristo)
nobrakal nobrakal
Nolan Poe (nopoe) Nolan Poe (nopoe)
Oleg Chkan (mrcheko) Oleg Chkan (mrcheko)
Paul Cercueil (pcercuei) Paul Cercueil (pcercuei)
Paul McElroy (Greendogo) Paul McElroy (Greendogo)
pchan3
Perry Hugh
Phillip Andrews (PhillipAnd)
Pi03k Pi03k
Pieter van der Kloet (pvdk) Pieter van der Kloet (pvdk)
pkubik pkubik
PLkolek
PlutonicOverkill PlutonicOverkill
Radu-Marius Popovici (rpopovici) Radu-Marius Popovici (rpopovici)
Rafael Moura (dhustkoder) Rafael Moura (dhustkoder)
@ -145,11 +165,12 @@ Programmers
Roman Proskuryakov (kpp) Roman Proskuryakov (kpp)
Roman Siromakha (elsid) Roman Siromakha (elsid)
Sandy Carter (bwrsandman) Sandy Carter (bwrsandman)
Scott Howard Scott Howard (maqifrnswa)
scrawl scrawl
Sebastian Wick (swick) Sebastian Wick (swick)
Sergey Fukanchik Sergey Fukanchik
Sergey Shambir Sergey Shambir (sergey-shambir)
sergoz
ShadowRadiance ShadowRadiance
Siimacore Siimacore
sir_herrbatka sir_herrbatka
@ -158,24 +179,33 @@ Programmers
spycrab spycrab
Stefan Galowicz (bogglez) Stefan Galowicz (bogglez)
Stanislav Bobrov (Jiub) Stanislav Bobrov (Jiub)
Stanislaw Halik (sthalik)
Star-Demon
stil-t stil-t
Stomy
svaante svaante
Sylvain Thesnieres (Garvek) Sylvain Thesnieres (Garvek)
t6 t6
terrorfisch terrorfisch
thegriglat thegriglat
Thomas Luppi (Digmaster) Thomas Luppi (Digmaster)
tlmullis
tri4ng1e tri4ng1e
unelsson Thoronador
Will Herrmann (Thunderforge)
Tom Mason (wheybags) Tom Mason (wheybags)
Torben Leif Carrington (TorbenC) Torben Leif Carrington (TorbenC)
unelsson
uramer
viadanna viadanna
Vincent Heuken Vincent Heuken
Vladimir Panteleev (CyberShadow)
Wang Ryu (bzzt)
Will Herrmann (Thunderforge)
vocollapse vocollapse
xyzz
Yohaulticetl Yohaulticetl
Yuri Krupenin
zelurker zelurker
James Carty (MrTopCat)
Documentation Documentation
------------- -------------
@ -184,11 +214,12 @@ Documentation
Alejandro Sanchez (HiPhish) Alejandro Sanchez (HiPhish)
Bodillium Bodillium
Bret Curtis (psi29a) Bret Curtis (psi29a)
David Walley (Loriel)
Cramal Cramal
David Walley (Loriel)
Diego Crespo
Joakim Berg (lysol90)
Ryan Tucker (Ravenwing) Ryan Tucker (Ravenwing)
sir_herrbatka sir_herrbatka
Diego Crespo
Packagers Packagers
--------- ---------
@ -207,13 +238,19 @@ Public Relations and Translations
Artem Kotsynyak (greye) - Russian News Writer Artem Kotsynyak (greye) - Russian News Writer
Dawid Lakomy (Vedyimyn) - Polish News Writer Dawid Lakomy (Vedyimyn) - Polish News Writer
ElderTroll - Release Manager
Jim Clauwaert (Zedd) - Public Outreach Jim Clauwaert (Zedd) - Public Outreach
juanmnzsk8 - Spanish News Writer
Julien Voisin (jvoisin/ap0) - French News Writer Julien Voisin (jvoisin/ap0) - French News Writer
Kingpix - Italian News Writer
Lukasz Gromanowski (lgro) - English News Writer Lukasz Gromanowski (lgro) - English News Writer
Martin Otto (Atahualpa) - Podcaster, Public Outreach, German Translator Martin Otto (Atahualpa) - Podcaster, Public Outreach, German Translator
Mickey Lyle (raevol) - Release Manager Mickey Lyle (raevol) - Release Manager
Nekochan - English News Writer
penguinroad - Indonesian News Writer
Pithorn - Chinese News Writer Pithorn - Chinese News Writer
sir_herrbatka - Polish News Writer sir_herrbatka - Polish News Writer
spyboot - German Translator
Tom Koenderink (Okulo) - English News Writer Tom Koenderink (Okulo) - English News Writer
Website Website
@ -243,34 +280,6 @@ Artwork
Mickey Lyle (raevol) - Wordpress Theme Mickey Lyle (raevol) - Wordpress Theme
Tom Koenderink (Okulo), SirHerrbatka, crysthala, Shnatsel, Lamoot - OpenMW Editor Icons Tom Koenderink (Okulo), SirHerrbatka, crysthala, Shnatsel, Lamoot - OpenMW Editor Icons
Inactive Contributors
---------------------
Ardekantur
Armin Preiml
Berulacks
Carl Maxwell
Diggory Hardy
Dmitry Marakasov (AMDmi3)
ElderTroll
guidoj
Jan-Peter Nilsson (peppe)
Jan Borsodi
Josua Grawitter
juanmnzsk8
Kingpix
Lordrea
Michal Sciubidlo
Nicolay Korslund
Nekochan
pchan3
penguinroad
sergoz
spyboot
Star-Demon
Thoronador
Yuri Krupenin
Additional Credits Additional Credits
------------------ ------------------
In this section we would like to thank people not part of OpenMW for their work. In this section we would like to thank people not part of OpenMW for their work.

@ -6,8 +6,10 @@
Bug #3623: Fix HiDPI on Windows Bug #3623: Fix HiDPI on Windows
Bug #3733: Normal maps are inverted on mirrored UVs Bug #3733: Normal maps are inverted on mirrored UVs
Bug #3765: DisableTeleporting makes Mark/Recall/Intervention effects undetectable Bug #3765: DisableTeleporting makes Mark/Recall/Intervention effects undetectable
Bug #3778: [Mod] Improved Thrown Weapon Projectiles - weapons have wrong transformation during throw animation
Bug #4329: Removed birthsign abilities are restored after reloading the save Bug #4329: Removed birthsign abilities are restored after reloading the save
Bug #4383: Bow model obscures crosshair when arrow is drawn Bug #4383: Bow model obscures crosshair when arrow is drawn
Bug #4384: Resist Normal Weapons only checks ammunition for ranged weapons
Bug #4411: Reloading a saved game while falling prevents damage in some cases Bug #4411: Reloading a saved game while falling prevents damage in some cases
Bug #4540: Rain delay when exiting water Bug #4540: Rain delay when exiting water
Bug #4701: PrisonMarker record is not hardcoded like other markers Bug #4701: PrisonMarker record is not hardcoded like other markers
@ -26,6 +28,7 @@
Bug #4800: Standing collisions are not updated immediately when an object is teleported without a cell change Bug #4800: Standing collisions are not updated immediately when an object is teleported without a cell change
Bug #4803: Stray special characters before begin statement break script compilation Bug #4803: Stray special characters before begin statement break script compilation
Bug #4804: Particle system with the "Has Sizes = false" causes an exception Bug #4804: Particle system with the "Has Sizes = false" causes an exception
Bug #4810: Raki creature broken in OpenMW
Bug #4813: Creatures with known file but no "Sound Gen Creature" assigned use default sounds Bug #4813: Creatures with known file but no "Sound Gen Creature" assigned use default sounds
Bug #4815: "Finished" journal entry with lower index doesn't close journal, SetJournalIndex closes journal Bug #4815: "Finished" journal entry with lower index doesn't close journal, SetJournalIndex closes journal
Bug #4820: Spell absorption is broken Bug #4820: Spell absorption is broken
@ -33,15 +36,21 @@
Bug #4828: Potion looping effects VFX are not shown for NPCs Bug #4828: Potion looping effects VFX are not shown for NPCs
Bug #4837: CTD when a mesh with NiLODNode root node with particles is loaded Bug #4837: CTD when a mesh with NiLODNode root node with particles is loaded
Bug #4860: Actors outside of processing range visible for one frame after spawning Bug #4860: Actors outside of processing range visible for one frame after spawning
Bug #4876: AI ratings handling inconsistencies
Bug #4888: Global variable stray explicit reference calls break script compilation
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3442: Default values for fallbacks from ini file Feature #3442: Default values for fallbacks from ini file
Feature #3610: Option to invert X axis Feature #3610: Option to invert X axis
Feature #3980: In-game option to disable controller Feature #3980: In-game option to disable controller
Feature #4209: Editor: Faction rank sub-table Feature #4209: Editor: Faction rank sub-table
Feature #4673: Weapon sheathing Feature #4673: Weapon sheathing
Feature #4675: Support for NiRollController
Feature #4730: Native animated containers support Feature #4730: Native animated containers support
Feature #4812: Support NiSwitchNode Feature #4812: Support NiSwitchNode
Feature #4836: Daytime node switch Feature #4836: Daytime node switch
Feature #4859: Make water reflections more configurable
Feature #4887: Add openmw command option to set initial random seed
Feature #4890: Make Distant Terrain configurable
Task #4686: Upgrade media decoder to a more current FFmpeg API Task #4686: Upgrade media decoder to a more current FFmpeg API
0.45.0 0.45.0

@ -22,6 +22,10 @@ if [[ -z "${BUILD_OPENMW}" ]]; then export BUILD_OPENMW=ON; fi
if [[ -z "${BUILD_OPENMW_CS}" ]]; then export BUILD_OPENMW_CS=ON; fi if [[ -z "${BUILD_OPENMW_CS}" ]]; then export BUILD_OPENMW_CS=ON; fi
${ANALYZE} cmake .. \ ${ANALYZE} cmake .. \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DBUILD_OPENMW=${BUILD_OPENMW} \ -DBUILD_OPENMW=${BUILD_OPENMW} \
-DBUILD_OPENCS=${BUILD_OPENMW_CS} \ -DBUILD_OPENCS=${BUILD_OPENMW_CS} \
-DBUILD_LAUNCHER=${BUILD_OPENMW_CS} \ -DBUILD_LAUNCHER=${BUILD_OPENMW_CS} \

@ -82,7 +82,7 @@ while [ $# -gt 0 ]; do
t ) t )
TEST_FRAMEWORK=true ;; TEST_FRAMEWORK=true ;;
h ) h )
cat <<EOF cat <<EOF
Usage: $0 [-cdehkpuvV] Usage: $0 [-cdehkpuvV]
@ -99,8 +99,8 @@ Options:
Keep the old build directory, default is to delete it. Keep the old build directory, default is to delete it.
-p <Win32/Win64> -p <Win32/Win64>
Set the build platform, can also be set with environment variable PLATFORM. Set the build platform, can also be set with environment variable PLATFORM.
-t -t
Build unit tests / Google test Build unit tests / Google test
-u -u
Configure for unity builds. Configure for unity builds.
-v <2013/2015/2017> -v <2013/2015/2017>
@ -402,7 +402,7 @@ if [ -z $SKIP_DOWNLOAD ]; then
download "SDL 2.0.7" \ download "SDL 2.0.7" \
"https://www.libsdl.org/release/SDL2-devel-2.0.7-VC.zip" \ "https://www.libsdl.org/release/SDL2-devel-2.0.7-VC.zip" \
"SDL2-2.0.7.zip" "SDL2-2.0.7.zip"
# Google test and mock # Google test and mock
if [ ! -z $TEST_FRAMEWORK ]; then if [ ! -z $TEST_FRAMEWORK ]; then
echo "Google test 1.8.1..." echo "Google test 1.8.1..."
@ -446,7 +446,7 @@ echo
if [ -z $APPVEYOR ]; then if [ -z $APPVEYOR ]; then
printf "Boost 1.67.0... " printf "Boost 1.67.0... "
else else
if [ $MSVC_VER -eq 12.0 ]; then if [ "${MSVC_VER}" -eq 12.0 ]; then
printf "Boost 1.58.0 AppVeyor... " printf "Boost 1.58.0 AppVeyor... "
else else
printf "Boost 1.67.0 AppVeyor... " printf "Boost 1.67.0 AppVeyor... "
@ -609,7 +609,7 @@ printf "OSG 3.4.1-scrawl... "
fi fi
add_runtime_dlls "$(pwd)/OSG/bin/"{OpenThreads,zlib,libpng*}${SUFFIX}.dll \ add_runtime_dlls "$(pwd)/OSG/bin/"{OpenThreads,zlib,libpng*}${SUFFIX}.dll \
"$(pwd)/OSG/bin/osg"{,Animation,DB,FX,GA,Particle,Text,Util,Viewer,Shadow}${SUFFIX}.dll "$(pwd)/OSG/bin/osg"{,Animation,DB,FX,GA,Particle,Text,Util,Viewer,Shadow}${SUFFIX}.dll
add_osg_dlls "$(pwd)/OSG/bin/osgPlugins-3.4.1/osgdb_"{bmp,dds,jpeg,osg,png,tga}${SUFFIX}.dll add_osg_dlls "$(pwd)/OSG/bin/osgPlugins-3.4.1/osgdb_"{bmp,dds,freetype,jpeg,osg,png,tga}${SUFFIX}.dll
add_osg_dlls "$(pwd)/OSG/bin/osgPlugins-3.4.1/osgdb_serializers_osg"{,animation,fx,ga,particle,text,util,viewer,shadow}${SUFFIX}.dll add_osg_dlls "$(pwd)/OSG/bin/osgPlugins-3.4.1/osgdb_serializers_osg"{,animation,fx,ga,particle,text,util,viewer,shadow}${SUFFIX}.dll
echo Done. echo Done.
} }
@ -692,33 +692,33 @@ echo
# Google Test and Google Mock # Google Test and Google Mock
if [ ! -z $TEST_FRAMEWORK ]; then if [ ! -z $TEST_FRAMEWORK ]; then
printf "Google test 1.8.1 ..." printf "Google test 1.8.1 ..."
cd googletest cd googletest
if [ ! -d build ]; then if [ ! -d build ]; then
mkdir build mkdir build
fi fi
cd build cd build
GOOGLE_INSTALL_ROOT="${DEPS_INSTALL}/GoogleTest" GOOGLE_INSTALL_ROOT="${DEPS_INSTALL}/GoogleTest"
if [ $CONFIGURATION == "Debug" ]; then if [ $CONFIGURATION == "Debug" ]; then
DEBUG_SUFFIX="d" DEBUG_SUFFIX="d"
else else
DEBUG_SUFFIX="" DEBUG_SUFFIX=""
fi fi
if [ ! -d $GOOGLE_INSTALL_ROOT ]; then if [ ! -d $GOOGLE_INSTALL_ROOT ]; then
cmake .. -DCMAKE_BUILD_TYPE="${CONFIGURATION}" -DCMAKE_INSTALL_PREFIX="${GOOGLE_INSTALL_ROOT}" -DCMAKE_USE_WIN32_THREADS_INIT=1 -G "${GENERATOR}" -DBUILD_SHARED_LIBS=1 cmake .. -DCMAKE_BUILD_TYPE="${CONFIGURATION}" -DCMAKE_INSTALL_PREFIX="${GOOGLE_INSTALL_ROOT}" -DCMAKE_USE_WIN32_THREADS_INIT=1 -G "${GENERATOR}" -DBUILD_SHARED_LIBS=1
cmake --build . --config "${CONFIGURATION}" cmake --build . --config "${CONFIGURATION}"
cmake --build . --target install --config "${CONFIGURATION}" cmake --build . --target install --config "${CONFIGURATION}"
add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gtest_main${DEBUG_SUFFIX}.dll" add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gtest_main${DEBUG_SUFFIX}.dll"
add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gtest${DEBUG_SUFFIX}.dll" add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gtest${DEBUG_SUFFIX}.dll"
add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gmock_main${DEBUG_SUFFIX}.dll" add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gmock_main${DEBUG_SUFFIX}.dll"
add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gmock${DEBUG_SUFFIX}.dll" add_runtime_dlls "${GOOGLE_INSTALL_ROOT}\bin\gmock${DEBUG_SUFFIX}.dll"
fi fi
add_cmake_opts -DBUILD_UNITTESTS=yes add_cmake_opts -DBUILD_UNITTESTS=yes
# FindGTest and FindGMock do not work perfectly on Windows # FindGTest and FindGMock do not work perfectly on Windows
# but we can help them by telling them everything we know about installation # but we can help them by telling them everything we know about installation
@ -730,7 +730,7 @@ if [ ! -z $TEST_FRAMEWORK ]; then
add_cmake_opts -DGMOCK_MAIN_LIBRARY="$GOOGLE_INSTALL_ROOT/lib/gmock_main${DEBUG_SUFFIX}.lib" add_cmake_opts -DGMOCK_MAIN_LIBRARY="$GOOGLE_INSTALL_ROOT/lib/gmock_main${DEBUG_SUFFIX}.lib"
add_cmake_opts -DGTEST_LINKED_AS_SHARED_LIBRARY=True add_cmake_opts -DGTEST_LINKED_AS_SHARED_LIBRARY=True
echo Done. echo Done.
fi fi
echo echo

@ -46,4 +46,4 @@ Getting started
* [TES3MP section on OpenMW forums](https://forum.openmw.org/viewforum.php?f=45) * [TES3MP section on OpenMW forums](https://forum.openmw.org/viewforum.php?f=45)
* [Discord server](https://discord.gg/ECJk293) * [Discord server](https://discord.gg/ECJk293)
* [Subreddit](https://www.reddit.com/r/tes3mp) * [Subreddit](https://www.reddit.com/r/tes3mp)
* [Known issues and bug reports](https://github.com/TES3MP/openmw-tes3mp/issues) * [Known issues and bug reports](https://github.com/TES3MP/openmw-tes3mp/issues)

@ -660,7 +660,7 @@ void Record<ESM::Creature>::print()
printTransport(mData.getTransport()); printTransport(mData.getTransport());
std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; std::cout << " Artificial Intelligence: " << std::endl;
std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl;
std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl; std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl;
std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl; std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl;
@ -668,7 +668,6 @@ void Record<ESM::Creature>::print()
std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl; std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl;
std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl; std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl;
std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl; std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl;
std::cout << " AI U4:" << (int)mData.mAiData.mU4 << std::endl;
std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl;
for (const ESM::AIPackage &package : mData.mAiPackage.mList) for (const ESM::AIPackage &package : mData.mAiPackage.mList)
@ -1079,7 +1078,7 @@ void Record<ESM::NPC>::print()
printTransport(mData.getTransport()); printTransport(mData.getTransport());
std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; std::cout << " Artificial Intelligence: " << std::endl;
std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl;
std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl; std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl;
std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl; std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl;
@ -1087,7 +1086,6 @@ void Record<ESM::NPC>::print()
std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl; std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl;
std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl; std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl;
std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl; std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl;
std::cout << " AI U4:" << (int)mData.mAiData.mU4 << std::endl;
std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl;
for (const ESM::AIPackage &package : mData.mAiPackage.mList) for (const ESM::AIPackage &package : mData.mAiPackage.mList)

@ -80,6 +80,7 @@ bool Launcher::AdvancedPage::loadSettings()
int unarmedFactorsStrengthIndex = mEngineSettings.getInt("strength influences hand to hand", "Game"); int unarmedFactorsStrengthIndex = mEngineSettings.getInt("strength influences hand to hand", "Game");
if (unarmedFactorsStrengthIndex >= 0 && unarmedFactorsStrengthIndex <= 2) if (unarmedFactorsStrengthIndex >= 0 && unarmedFactorsStrengthIndex <= 2)
unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex); unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex);
loadSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
// Input Settings // Input Settings
loadSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input"); loadSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input");
@ -139,6 +140,7 @@ void Launcher::AdvancedPage::saveSettings()
int unarmedFactorsStrengthIndex = unarmedFactorsStrengthComboBox->currentIndex(); int unarmedFactorsStrengthIndex = unarmedFactorsStrengthComboBox->currentIndex();
if (unarmedFactorsStrengthIndex != mEngineSettings.getInt("strength influences hand to hand", "Game")) if (unarmedFactorsStrengthIndex != mEngineSettings.getInt("strength influences hand to hand", "Game"))
mEngineSettings.setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex); mEngineSettings.setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex);
saveSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
// Input Settings // Input Settings
saveSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input"); saveSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input");

@ -1,6 +1,5 @@
#include "graphicspage.hpp" #include "graphicspage.hpp"
#include <boost/math/common_factor.hpp>
#include <csignal> #include <csignal>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QMessageBox> #include <QMessageBox>
@ -15,10 +14,11 @@
#include <SDL_video.h> #include <SDL_video.h>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/misc/gcd.hpp>
QString getAspect(int x, int y) QString getAspect(int x, int y)
{ {
int gcd = boost::math::gcd (x, y); int gcd = Misc::gcd (x, y);
int xaspect = x / gcd; int xaspect = x / gcd;
int yaspect = y / gcd; int yaspect = y / gcd;
// special case: 8 : 5 is usually referred to as 16:10 // special case: 8 : 5 is usually referred to as 16:10

@ -364,6 +364,11 @@ int CSMDoc::Document::getState() const
return state; return state;
} }
const boost::filesystem::path& CSMDoc::Document::getResourceDir() const
{
return mResDir;
}
const boost::filesystem::path& CSMDoc::Document::getSavePath() const const boost::filesystem::path& CSMDoc::Document::getSavePath() const
{ {
return mSavePath; return mSavePath;

@ -115,6 +115,8 @@ namespace CSMDoc
int getState() const; int getState() const;
const boost::filesystem::path& getResourceDir() const;
const boost::filesystem::path& getSavePath() const; const boost::filesystem::path& getSavePath() const;
const boost::filesystem::path& getProjectPath() const; const boost::filesystem::path& getProjectPath() const;

@ -30,11 +30,11 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, const Compi
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);
stream << "line " << loc.mLine << ", column " << loc.mColumn << ": " << message << " (" << loc.mLiteral << ")"; stream << message << " (" << loc.mLiteral << ")" << " @ line " << loc.mLine+1 << ", column " << loc.mColumn;
std::ostringstream hintStream; std::ostringstream hintStream;
hintStream << "l:" << loc.mLine << " " << loc.mColumn; hintStream << "l:" << loc.mLine+1 << " " << loc.mColumn;
mMessages->add (id, stream.str(), hintStream.str(), getSeverity (type)); mMessages->add (id, stream.str(), hintStream.str(), getSeverity (type));
} }

@ -87,6 +87,7 @@ namespace CSMWorld
//CONCRETE TYPES ENDS HERE //CONCRETE TYPES ENDS HERE
Display_UnsignedInteger8, Display_UnsignedInteger8,
Display_UnsignedInteger16,
Display_Integer, Display_Integer,
Display_Float, Display_Float,
Display_Double, Display_Double,

@ -627,12 +627,12 @@ namespace CSMWorld
RecordT record2 = record.get(); RecordT record2 = record.get();
if (column==mActors.mHello) if (column==mActors.mHello)
record2.mAiData.mHello = value.toInt(); record2.mAiData.mHello = value.toInt();
else if (column==mActors.mFlee) else if (column==mActors.mFlee) // Flee, Fight and Alarm ratings are probabilities.
record2.mAiData.mFlee = value.toInt(); record2.mAiData.mFlee = std::min(100, value.toInt());
else if (column==mActors.mFight) else if (column==mActors.mFight)
record2.mAiData.mFight = value.toInt(); record2.mAiData.mFight = std::min(100, value.toInt());
else if (column==mActors.mAlarm) else if (column==mActors.mAlarm)
record2.mAiData.mAlarm = value.toInt(); record2.mAiData.mAlarm = std::min(100, value.toInt());
else else
{ {
typename std::map<const RefIdColumn *, unsigned int>::const_iterator iter = typename std::map<const RefIdColumn *, unsigned int>::const_iterator iter =

@ -128,7 +128,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
ActorColumns actorsColumns (nameColumns); ActorColumns actorsColumns (nameColumns);
mColumns.push_back (RefIdColumn (Columns::ColumnId_AiHello, ColumnBase::Display_UnsignedInteger8)); mColumns.push_back (RefIdColumn (Columns::ColumnId_AiHello, ColumnBase::Display_UnsignedInteger16));
actorsColumns.mHello = &mColumns.back(); actorsColumns.mHello = &mColumns.back();
mColumns.push_back (RefIdColumn (Columns::ColumnId_AiFlee, ColumnBase::Display_UnsignedInteger8)); mColumns.push_back (RefIdColumn (Columns::ColumnId_AiFlee, ColumnBase::Display_UnsignedInteger8));
actorsColumns.mFlee = &mColumns.back(); actorsColumns.mFlee = &mColumns.back();

@ -1,7 +1,8 @@
#include "adjusterwidget.hpp" #include "adjusterwidget.hpp"
#include <components/misc/stringops.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
@ -70,8 +71,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
{ {
boost::filesystem::path path (name.toUtf8().data()); boost::filesystem::path path (name.toUtf8().data());
std::string extension = path.extension().string(); std::string extension = Misc::StringUtils::lowerCase(path.extension().string());
boost::algorithm::to_lower(extension);
bool isLegacyPath = (extension == ".esm" || bool isLegacyPath = (extension == ".esm" ||
extension == ".esp"); extension == ".esp");

@ -5,6 +5,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox>
#include <QMdiArea> #include <QMdiArea>
#include <QDockWidget> #include <QDockWidget>
#include <QApplication> #include <QApplication>
@ -25,6 +26,8 @@
#include "../tools/subviews.hpp" #include "../tools/subviews.hpp"
#include <components/version/version.hpp>
#include "viewmanager.hpp" #include "viewmanager.hpp"
#include "operations.hpp" #include "operations.hpp"
#include "subview.hpp" #include "subview.hpp"
@ -303,6 +306,17 @@ void CSVDoc::View::setupDebugMenu()
connect (runLog, SIGNAL (triggered()), this, SLOT (addRunLogSubView())); connect (runLog, SIGNAL (triggered()), this, SLOT (addRunLogSubView()));
} }
void CSVDoc::View::setupHelpMenu()
{
QMenu *help = menuBar()->addMenu (tr ("Help"));
QAction* about = createMenuEntry("About OpenMW-CS", ":./info.png", help, "document-help-about");
connect (about, SIGNAL (triggered()), this, SLOT (infoAbout()));
QAction* aboutQt = createMenuEntry("About Qt", ":./qt.png", help, "document-help-qt");
connect (aboutQt, SIGNAL (triggered()), this, SLOT (infoAboutQt()));
}
QAction* CSVDoc::View::createMenuEntry(CSMWorld::UniversalId::Type type, QMenu* menu, const char* shortcutName) QAction* CSVDoc::View::createMenuEntry(CSMWorld::UniversalId::Type type, QMenu* menu, const char* shortcutName)
{ {
const std::string title = CSMWorld::UniversalId (type).getTypeName(); const std::string title = CSMWorld::UniversalId (type).getTypeName();
@ -339,6 +353,7 @@ void CSVDoc::View::setupUi()
setupCharacterMenu(); setupCharacterMenu();
setupAssetsMenu(); setupAssetsMenu();
setupDebugMenu(); setupDebugMenu();
setupHelpMenu();
} }
void CSVDoc::View::setupShortcut(const char* name, QAction* action) void CSVDoc::View::setupShortcut(const char* name, QAction* action)
@ -674,6 +689,52 @@ void CSVDoc::View::save()
mDocument->save(); mDocument->save();
} }
void CSVDoc::View::infoAbout()
{
// Get current OpenMW version
QString versionInfo = (Version::getOpenmwVersionDescription(mDocument->getResourceDir().string())+
#if defined(__x86_64__) || defined(_M_X64)
" (64-bit)").c_str();
#else
" (32-bit)").c_str();
#endif
// Get current year
time_t now = time(NULL);
struct tm tstruct;
char copyrightInfo[40];
tstruct = *localtime(&now);
strftime(copyrightInfo, sizeof(copyrightInfo), "Copyright © 2008-%Y OpenMW Team", &tstruct);
QString aboutText = QString(
"<p style=\"white-space: pre-wrap;\">"
"<b><h2>OpenMW Construction Set</h2></b>"
"%1\n\n"
"%2\n\n"
"%3\n\n"
"<table>"
"<tr><td>%4</td><td><a href=\"https://openmw.org\">https://openmw.org</a></td></tr>"
"<tr><td>%5</td><td><a href=\"https://forum.openmw.org\">https://forum.openmw.org</a></td></tr>"
"<tr><td>%6</td><td><a href=\"https://gitlab.com/OpenMW/openmw/issues\">https://gitlab.com/OpenMW/openmw/issues</a></td></tr>"
"<tr><td>%7</td><td><a href=\"https://webchat.freenode.net/?channels=openmw&uio=OT10cnVlde\">irc://irc.freenode.net/#openmw</a></td></tr>"
"</table>"
"</p>")
.arg(versionInfo
, tr("OpenMW-CS is a content file editor for OpenMW, a modern, free and open source game engine.")
, tr(copyrightInfo)
, tr("Home Page:")
, tr("Forum:")
, tr("Bug Tracker:")
, tr("IRC:"));
QMessageBox::about(this, "About OpenMW-CS", aboutText);
}
void CSVDoc::View::infoAboutQt()
{
QMessageBox::aboutQt(this);
}
void CSVDoc::View::verify() void CSVDoc::View::verify()
{ {
addSubView (mDocument->verify()); addSubView (mDocument->verify());

@ -85,6 +85,8 @@ namespace CSVDoc
void setupDebugMenu(); void setupDebugMenu();
void setupHelpMenu();
void setupUi(); void setupUi();
void setupShortcut(const char* name, QAction* action); void setupShortcut(const char* name, QAction* action);
@ -165,6 +167,10 @@ namespace CSVDoc
void exit(); void exit();
void infoAbout();
void infoAboutQt();
void verify(); void verify();
void addGlobalsSubView(); void addGlobalsSubView();

@ -141,13 +141,16 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
if (mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Preview) if (mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Preview)
{ {
const CSMWorld::UniversalId id = getUniversalId(currentRow);
const CSMWorld::UniversalId::Type type = id.getType();
QModelIndex index = mModel->index (row, QModelIndex index = mModel->index (row,
mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification)); mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification));
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State> ( CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State> (
mModel->data (index).toInt()); mModel->data (index).toInt());
if (state!=CSMWorld::RecordBase::State_Deleted) if (state!=CSMWorld::RecordBase::State_Deleted && type != CSMWorld::UniversalId::Type_ItemLevelledList)
menu.addAction (mPreviewAction); menu.addAction (mPreviewAction);
} }
} }

@ -219,6 +219,13 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
return sb; return sb;
} }
case CSMWorld::ColumnBase::Display_UnsignedInteger16:
{
DialogueSpinBox *sb = new DialogueSpinBox(parent);
sb->setRange(0, std::numeric_limits<unsigned short>::max());
return sb;
}
case CSMWorld::ColumnBase::Display_Var: case CSMWorld::ColumnBase::Display_Var:
return new QLineEdit(parent); return new QLineEdit(parent);

@ -49,7 +49,6 @@
#include "mwgui/windowmanagerimp.hpp" #include "mwgui/windowmanagerimp.hpp"
#include "mwscript/scriptmanagerimp.hpp" #include "mwscript/scriptmanagerimp.hpp"
#include "mwscript/extensions.hpp"
#include "mwscript/interpretercontext.hpp" #include "mwscript/interpretercontext.hpp"
#include "mwsound/soundmanagerimp.hpp" #include "mwsound/soundmanagerimp.hpp"
@ -320,7 +319,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mNewGame (false) , mNewGame (false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
{ {
Misc::Rng::init();
MWClass::registerClasses(); MWClass::registerClasses();
Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK; Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK;
@ -786,6 +784,8 @@ void OMW::Engine::go()
Log(Debug::Info) << "OSG version: " << osgGetVersion(); Log(Debug::Info) << "OSG version: " << osgGetVersion();
Misc::Rng::init(mRandomSeed);
// Load settings // Load settings
Settings::Manager settings; Settings::Manager settings;
std::string settingspath; std::string settingspath;
@ -986,3 +986,8 @@ void OMW::Engine::setSaveGameFile(const std::string &savegame)
{ {
mSaveGameFile = savegame; mSaveGameFile = savegame;
} }
void OMW::Engine::setRandomSeed(unsigned int seed)
{
mRandomSeed = seed;
}

@ -100,6 +100,7 @@ namespace OMW
bool mGrab; bool mGrab;
bool mExportFonts; bool mExportFonts;
unsigned int mRandomSeed;
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
@ -203,6 +204,8 @@ namespace OMW
/// Set the save game file to load after initialising the engine. /// Set the save game file to load after initialising the engine.
void setSaveGameFile(const std::string& savegame); void setSaveGameFile(const std::string& savegame);
void setRandomSeed(unsigned int seed);
private: private:
Files::ConfigurationManager& mCfgMgr; Files::ConfigurationManager& mCfgMgr;
}; };

@ -3,6 +3,7 @@
#include <components/files/escape.hpp> #include <components/files/escape.hpp>
#include <components/fallback/validate.hpp> #include <components/fallback/validate.hpp>
#include <components/debug/debugging.hpp> #include <components/debug/debugging.hpp>
#include <components/misc/rng.hpp>
#include "engine.hpp" #include "engine.hpp"
@ -154,7 +155,12 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("export-fonts", bpo::value<bool>()->implicit_value(true) ("export-fonts", bpo::value<bool>()->implicit_value(true)
->default_value(false), "Export Morrowind .fnt fonts to PNG image and XML file in current directory") ->default_value(false), "Export Morrowind .fnt fonts to PNG image and XML file in current directory")
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override"); ("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override")
("random-seed", bpo::value <unsigned int> ()
->default_value(Misc::Rng::generateDefaultSeed()),
"seed value for random number generator")
;
/* /*
Start of tes3mp addition Start of tes3mp addition
@ -312,6 +318,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap); engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>()); engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
engine.enableFontExport(variables["export-fonts"].as<bool>()); engine.enableFontExport(variables["export-fonts"].as<bool>());
engine.setRandomSeed(variables["random-seed"].as<unsigned int>());
/* /*
Start of tes3mp addition Start of tes3mp addition

@ -135,6 +135,7 @@ namespace MWBase
virtual MWWorld::Player& getPlayer() = 0; virtual MWWorld::Player& getPlayer() = 0;
virtual MWWorld::Ptr getPlayerPtr() = 0; virtual MWWorld::Ptr getPlayerPtr() = 0;
virtual MWWorld::ConstPtr getPlayerConstPtr() const = 0;
virtual const MWWorld::ESMStore& getStore() const = 0; virtual const MWWorld::ESMStore& getStore() const = 0;
@ -787,6 +788,9 @@ namespace MWBase
virtual void removeActorPath(const MWWorld::ConstPtr& actor) const = 0; virtual void removeActorPath(const MWWorld::ConstPtr& actor) const = 0;
virtual void setNavMeshNumberToRender(const std::size_t value) = 0; virtual void setNavMeshNumberToRender(const std::size_t value) = 0;
/// Return physical half extents of the given actor to be used in pathfinding
virtual osg::Vec3f getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const = 0;
}; };
} }

@ -2,10 +2,10 @@
#include <components/esm/loadacti.hpp> #include <components/esm/loadacti.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
@ -19,6 +19,7 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/vismask.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
@ -30,8 +31,10 @@ namespace MWClass
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
{ {
if (!model.empty()) { if (!model.empty())
{
renderingInterface.getObjects().insertModel(ptr, model, true); renderingInterface.getObjects().insertModel(ptr, model, true);
ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static);
} }
} }

@ -4,7 +4,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"

@ -15,11 +15,9 @@
#include <components/esm/loadappa.hpp> #include <components/esm/loadappa.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionalchemy.hpp" #include "../mwworld/actionalchemy.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"

@ -22,7 +22,6 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

@ -19,7 +19,6 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

@ -18,7 +18,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -305,8 +304,8 @@ namespace MWClass
std::string text; std::string text;
int lockLevel = ptr.getCellRef().getLockLevel(); int lockLevel = ptr.getCellRef().getLockLevel();
if (lockLevel > 0 && lockLevel != ESM::UnbreakableLock) if (lockLevel > 0 && lockLevel != ESM::UnbreakableLock)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ptr.getCellRef().getLockLevel()); text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(lockLevel);
else if (ptr.getCellRef().getLockLevel() < 0) else if (lockLevel < 0)
text += "\n#{sUnlocked}"; text += "\n#{sUnlocked}";
if (ptr.getCellRef().getTrap() != "") if (ptr.getCellRef().getTrap() != "")
text += "\n#{sTrapped}"; text += "\n#{sTrapped}";

@ -371,6 +371,7 @@ namespace MWClass
{ {
damage = attack[0] + ((attack[1]-attack[0])*attackStrength); damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
MWMechanics::adjustWeaponDamage(damage, weapon, ptr); MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr); MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
} }
@ -472,9 +473,6 @@ namespace MWClass
if (!object.isEmpty()) if (!object.isEmpty())
stats.setLastHitObject(object.getCellRef().getRefId()); stats.setLastHitObject(object.getCellRef().getRefId());
if (damage > 0.0f && !object.isEmpty())
MWMechanics::resistNormalWeapon(ptr, attacker, object, damage);
if (damage < 0.001f) if (damage < 0.001f)
damage = 0; damage = 0;
@ -760,11 +758,7 @@ namespace MWClass
int Creature::getServices(const MWWorld::ConstPtr &actor) const int Creature::getServices(const MWWorld::ConstPtr &actor) const
{ {
const MWWorld::LiveCellRef<ESM::Creature>* ref = actor.get<ESM::Creature>(); return actor.get<ESM::Creature>()->mBase->mAiData.mServices;
if (ref->mBase->mHasAI)
return ref->mBase->mAiData.mServices;
else
return 0;
} }
bool Creature::isPersistent(const MWWorld::ConstPtr &actor) const bool Creature::isPersistent(const MWWorld::ConstPtr &actor) const

@ -14,15 +14,14 @@
#include <components/esm/loaddoor.hpp> #include <components/esm/loaddoor.hpp>
#include <components/esm/doorstate.hpp> #include <components/esm/doorstate.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/failedaction.hpp" #include "../mwworld/failedaction.hpp"
#include "../mwworld/actionteleport.hpp" #include "../mwworld/actionteleport.hpp"
#include "../mwworld/actiondoor.hpp" #include "../mwworld/actiondoor.hpp"
@ -38,6 +37,7 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
#include "../mwrender/vismask.hpp"
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
@ -67,8 +67,10 @@ namespace MWClass
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const void Door::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
{ {
if (!model.empty()) { if (!model.empty())
{
renderingInterface.getObjects().insertModel(ptr, model, true); renderingInterface.getObjects().insertModel(ptr, model, true);
ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static);
} }
} }

@ -19,7 +19,6 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"

@ -5,20 +5,16 @@
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/nullaction.hpp" #include "../mwworld/nullaction.hpp"
#include "../mwworld/failedaction.hpp" #include "../mwworld/failedaction.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"

@ -4,11 +4,9 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

@ -19,7 +19,6 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"

@ -682,6 +682,8 @@ namespace MWClass
damage = attack[0] + ((attack[1]-attack[0])*attackStrength); damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
} }
MWMechanics::adjustWeaponDamage(damage, weapon, ptr); MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
MWMechanics::applyWerewolfDamageMult(victim, weapon, damage);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr); MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
healthdmg = true; healthdmg = true;
} }
@ -1388,11 +1390,7 @@ namespace MWClass
int Npc::getServices(const MWWorld::ConstPtr &actor) const int Npc::getServices(const MWWorld::ConstPtr &actor) const
{ {
const MWWorld::LiveCellRef<ESM::NPC>* ref = actor.get<ESM::NPC>(); return actor.get<ESM::NPC>()->mBase->mAiData.mServices;
if (ref->mBase->mHasAI)
return ref->mBase->mAiData.mServices;
else
return 0;
} }

@ -19,11 +19,9 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionapply.hpp" #include "../mwworld/actionapply.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/nullaction.hpp" #include "../mwworld/nullaction.hpp"

@ -4,11 +4,9 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

@ -15,14 +15,11 @@
#include <components/esm/loadrepa.hpp> #include <components/esm/loadrepa.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/actionrepair.hpp" #include "../mwworld/actionrepair.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"

@ -1,6 +1,7 @@
#include "static.hpp" #include "static.hpp"
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
@ -8,14 +9,17 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/vismask.hpp"
namespace MWClass namespace MWClass
{ {
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const void Static::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
{ {
if (!model.empty()) { if (!model.empty())
{
renderingInterface.getObjects().insertModel(ptr, model); renderingInterface.getObjects().insertModel(ptr, model);
ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static);
} }
} }

@ -22,7 +22,6 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

@ -1,9 +1,6 @@
#include "dialoguemanagerimp.hpp" #include "dialoguemanagerimp.hpp"
#include <cctype>
#include <cstdlib>
#include <algorithm> #include <algorithm>
#include <iterator>
#include <list> #include <list>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>

@ -15,7 +15,6 @@
#include <components/compiler/streamerrorhandler.hpp> #include <components/compiler/streamerrorhandler.hpp>
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
#include <components/compiler/output.hpp>
#include <components/compiler/scriptparser.hpp> #include <components/compiler/scriptparser.hpp>
#include "filter.hpp" #include "filter.hpp"

@ -1,9 +1,6 @@
#include "selectwrapper.hpp" #include "selectwrapper.hpp"
#include <cctype>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include <sstream> #include <sstream>
#include <iterator> #include <iterator>

@ -3,6 +3,7 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <MyGUI_Button.h> #include <MyGUI_Button.h>
#include <MyGUI_EditBox.h> #include <MyGUI_EditBox.h>
#include <MyGUI_ControllerManager.h>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -237,15 +238,15 @@ namespace MWGui
std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects(); std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects();
Widgets::SpellEffectList list; Widgets::SpellEffectList list;
unsigned int effectIndex=0; unsigned int effectIndex=0;
for (std::set<MWMechanics::EffectKey>::iterator it2 = effectIds.begin(); it2 != effectIds.end(); ++it2) for (const MWMechanics::EffectKey& effectKey : effectIds)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it2->mId; params.mEffectID = effectKey.mId;
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it2->mId); const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectKey.mId);
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
params.mSkill = it2->mArg; params.mSkill = effectKey.mArg;
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
params.mAttribute = it2->mArg; params.mAttribute = effectKey.mArg;
params.mIsConstant = true; params.mIsConstant = true;
params.mNoTarget = true; params.mNoTarget = true;

@ -1,12 +1,9 @@
#ifndef MWGUI_ALCHEMY_H #ifndef MWGUI_ALCHEMY_H
#define MWGUI_ALCHEMY_H #define MWGUI_ALCHEMY_H
#include <memory>
#include <vector> #include <vector>
#include <MyGUI_ControllerManager.h>
#include "../mwmechanics/alchemy.hpp"
#include <components/widgets/numericeditbox.hpp> #include <components/widgets/numericeditbox.hpp>
#include "controllers.hpp" #include "controllers.hpp"

@ -145,35 +145,35 @@ namespace MWGui
// sort by name // sort by name
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
MWWorld::Store<ESM::BirthSign>::iterator it = signs.begin(); for (const ESM::BirthSign& sign : signs)
for (; it != signs.end(); ++it)
{ {
birthSigns.push_back(std::make_pair(it->mId, &(*it))); birthSigns.push_back(std::make_pair(sign.mId, &sign));
} }
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); for (auto& birthsignPair : birthSigns)
it2 != birthSigns.end(); ++it2, ++index)
{ {
mBirthList->addItem(it2->second->mName, it2->first); mBirthList->addItem(birthsignPair.second->mName, birthsignPair.first);
if (mCurrentBirthId.empty()) if (mCurrentBirthId.empty())
{ {
mBirthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
mCurrentBirthId = it2->first; mCurrentBirthId = birthsignPair.first;
} }
else if (Misc::StringUtils::ciEqual(it2->first, mCurrentBirthId)) else if (Misc::StringUtils::ciEqual(birthsignPair.first, mCurrentBirthId))
{ {
mBirthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
} }
index++;
} }
} }
void BirthDialog::updateSpells() void BirthDialog::updateSpells()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it) for (MyGUI::Widget* widget : mSpellItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSpellItems.clear(); mSpellItems.clear();

@ -6,6 +6,7 @@
#include "MyGUI_FontManager.h" #include "MyGUI_FontManager.h"
#include <functional> #include <functional>
#include <memory>
#include <stdint.h> #include <stdint.h>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>

@ -257,19 +257,17 @@ namespace MWGui
{ {
std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues(); std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues();
for (std::map<int, MWMechanics::AttributeValue >::iterator it = attributes.begin(); for (auto& attributePair : attributes)
it != attributes.end(); ++it)
{ {
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (it->first), it->second); mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
} }
} }
{ {
std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues(); std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues();
for (std::map<int, MWMechanics::SkillValue >::iterator it = skills.begin(); for (auto& skillPair : skills)
it != skills.end(); ++it)
{ {
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (it->first), it->second); mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
} }
mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills()); mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills());
} }
@ -566,7 +564,7 @@ namespace MWGui
{ {
if (mGenerateClassStep == 10) if (mGenerateClassStep == 10)
{ {
static boost::array<ClassPoint, 23> classes = { { static std::array<ClassPoint, 23> classes = { {
{"Acrobat", {6, 2, 2}}, {"Acrobat", {6, 2, 2}},
{"Agent", {6, 1, 3}}, {"Agent", {6, 1, 3}},
{"Archer", {3, 5, 2}}, {"Archer", {3, 5, 2}},

@ -207,25 +207,25 @@ namespace MWGui
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
std::vector<std::pair<std::string, std::string> > items; // class id, class name std::vector<std::pair<std::string, std::string> > items; // class id, class name
for (MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin(); it != store.get<ESM::Class>().end(); ++it) for (const ESM::Class& classInfo : store.get<ESM::Class>())
{ {
bool playable = (it->mData.mIsPlayable != 0); bool playable = (classInfo.mData.mIsPlayable != 0);
if (!playable) // Only display playable classes if (!playable) // Only display playable classes
continue; continue;
if (store.get<ESM::Class>().isDynamic(it->mId)) if (store.get<ESM::Class>().isDynamic(classInfo.mId))
continue; // custom-made class not relevant for this dialog continue; // custom-made class not relevant for this dialog
items.push_back(std::make_pair(it->mId, it->mName)); items.push_back(std::make_pair(classInfo.mId, classInfo.mName));
} }
std::sort(items.begin(), items.end(), sortClasses); std::sort(items.begin(), items.end(), sortClasses);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, std::string> >::const_iterator it = items.begin(); it != items.end(); ++it) for (auto& itemPair : items)
{ {
const std::string &id = it->first; const std::string &id = itemPair.first;
mClassList->addItem(it->second, id); mClassList->addItem(itemPair.second, id);
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
{ {
mCurrentClassId = id; mCurrentClassId = id;
@ -332,19 +332,17 @@ namespace MWGui
void InfoBoxDialog::setButtons(ButtonList &buttons) void InfoBoxDialog::setButtons(ButtonList &buttons)
{ {
for (std::vector<MyGUI::Button*>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it) for (MyGUI::Button* button : this->mButtons)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(button);
} }
this->mButtons.clear(); this->mButtons.clear();
// TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
MyGUI::Button* button; MyGUI::Button* button;
MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10); MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10);
ButtonList::const_iterator end = buttons.end(); for (const std::string &text : buttons)
for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it)
{ {
const std::string &text = *it;
button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, "");
button->getSubWidgetText()->setWordWrap(true); button->getSubWidgetText()->setWordWrap(true);
button->setCaption(text); button->setCaption(text);
@ -368,11 +366,10 @@ namespace MWGui
void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender) void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender)
{ {
std::vector<MyGUI::Button*>::const_iterator end = mButtons.end();
int i = 0; int i = 0;
for (std::vector<MyGUI::Button*>::const_iterator it = mButtons.begin(); it != end; ++it) for (MyGUI::Button* button : mButtons)
{ {
if (*it == _sender) if (button == _sender)
{ {
eventButtonSelected(i); eventButtonSelected(i);
return; return;
@ -430,10 +427,9 @@ namespace MWGui
mSkills.push_back(mMinorSkill[i]); mSkills.push_back(mMinorSkill[i]);
} }
std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (Widgets::MWSkillPtr& skill : mSkills)
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
(*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); skill->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
} }
setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", "")); setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", ""));
@ -642,14 +638,13 @@ namespace MWGui
ESM::Skill::SkillEnum id = mSkillDialog->getSkillId(); ESM::Skill::SkillEnum id = mSkillDialog->getSkillId();
// Avoid duplicate skills by swapping any skill field that matches the selected one // Avoid duplicate skills by swapping any skill field that matches the selected one
std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (Widgets::MWSkillPtr& skill : mSkills)
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
if (*it == mAffectedSkill) if (skill == mAffectedSkill)
continue; continue;
if ((*it)->getSkillId() == id) if (skill->getSkillId() == id)
{ {
(*it)->setSkillId(mAffectedSkill->getSkillId()); skill->setSkillId(mAffectedSkill->getSkillId());
break; break;
} }
} }

@ -244,11 +244,13 @@ namespace MWGui
{ {
int i = 0; int i = 0;
printOK(""); printOK("");
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end(); ++it,++i ) for(std::string& match : matches)
{ {
printOK( *it ); if(i == 50)
if( i == 50 )
break; break;
printOK(match);
i++;
} }
} }
} }
@ -365,15 +367,16 @@ namespace MWGui
} }
/* Iterate through the vector. */ /* Iterate through the vector. */
for(std::vector<std::string>::iterator it=mNames.begin(); it < mNames.end();++it) { for(std::string& name : mNames)
{
bool string_different=false; bool string_different=false;
/* Is the string shorter than the input string? If yes skip it. */ /* Is the string shorter than the input string? If yes skip it. */
if( (*it).length() < tmp.length() ) if(name.length() < tmp.length())
continue; continue;
/* Is the beginning of the string different from the input string? If yes skip it. */ /* Is the beginning of the string different from the input string? If yes skip it. */
for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();++iter, ++iter2) { for( std::string::iterator iter=tmp.begin(), iter2=name.begin(); iter < tmp.end();++iter, ++iter2) {
if( Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2) ) { if( Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2) ) {
string_different=true; string_different=true;
break; break;
@ -384,7 +387,7 @@ namespace MWGui
continue; continue;
/* The beginning of the string matches the input string, save it for the next test. */ /* The beginning of the string matches the input string, save it for the next test. */
matches.push_back(*it); matches.push_back(name);
} }
/* There are no matches. Return the unchanged input. */ /* There are no matches. Return the unchanged input. */
@ -412,11 +415,14 @@ namespace MWGui
/* Check if all matching strings match further than input. If yes complete to this match. */ /* Check if all matching strings match further than input. If yes complete to this match. */
int i = tmp.length(); int i = tmp.length();
for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i) { for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i)
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end();++it) { {
if( Misc::StringUtils::toLower((*it)[i]) != Misc::StringUtils::toLower(*iter) ) { for(std::string& match : matches)
{
if(Misc::StringUtils::toLower(match[i]) != Misc::StringUtils::toLower(*iter))
{
/* Append the longest match to the end of the output string*/ /* Append the longest match to the end of the output string*/
output.append(matches.front().substr( 0, i)); output.append(matches.front().substr(0, i));
return output; return output;
} }
} }

@ -21,7 +21,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -33,7 +32,6 @@
#include "inventorywindow.hpp" #include "inventorywindow.hpp"
#include "itemview.hpp" #include "itemview.hpp"
#include "itemwidget.hpp"
#include "inventoryitemmodel.hpp" #include "inventoryitemmodel.hpp"
#include "containeritemmodel.hpp" #include "containeritemmodel.hpp"
#include "sortfilteritemmodel.hpp" #include "sortfilteritemmodel.hpp"

@ -13,8 +13,6 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace namespace
{ {
@ -84,9 +82,9 @@ size_t ContainerItemModel::getItemCount()
ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item) ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item)
{ {
size_t i = 0; size_t i = 0;
for (std::vector<ItemStack>::iterator it = mItems.begin(); it != mItems.end(); ++it) for (ItemStack& itemStack : mItems)
{ {
if (*it == item) if (itemStack == item)
return i; return i;
++i; ++i;
} }
@ -105,29 +103,29 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
{ {
int toRemove = count; int toRemove = count;
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source) for (MWWorld::Ptr& source : mItemSources)
{ {
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source); MWWorld::ContainerStore& store = source.getClass().getContainerStore(source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
if (stacks(*it, item.mBase)) if (stacks(*it, item.mBase))
{ {
toRemove -= store.remove(*it, toRemove, *source); toRemove -= store.remove(*it, toRemove, source);
if (toRemove <= 0) if (toRemove <= 0)
return; return;
} }
} }
} }
for (std::vector<MWWorld::Ptr>::iterator source = mWorldItems.begin(); source != mWorldItems.end(); ++source) for (MWWorld::Ptr& source : mWorldItems)
{ {
if (stacks(*source, item.mBase)) if (stacks(source, item.mBase))
{ {
int refCount = source->getRefData().getCount(); int refCount = source.getRefData().getCount();
if (refCount - toRemove <= 0) if (refCount - toRemove <= 0)
MWBase::Environment::get().getWorld()->deleteObject(*source); MWBase::Environment::get().getWorld()->deleteObject(source);
else else
source->getRefData().setCount(std::max(0, refCount - toRemove)); source.getRefData().setCount(std::max(0, refCount - toRemove));
toRemove -= refCount; toRemove -= refCount;
if (toRemove <= 0) if (toRemove <= 0)
return; return;
@ -140,27 +138,28 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
void ContainerItemModel::update() void ContainerItemModel::update()
{ {
mItems.clear(); mItems.clear();
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source) for (MWWorld::Ptr& source : mItemSources)
{ {
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source); MWWorld::ContainerStore& store = source.getClass().getContainerStore(source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
if (!(*it).getClass().showsInInventory(*it)) if (!(*it).getClass().showsInInventory(*it))
continue; continue;
std::vector<ItemStack>::iterator itemStack = mItems.begin(); bool found = false;
for (; itemStack != mItems.end(); ++itemStack) for (ItemStack& itemStack : mItems)
{ {
if (stacks(*it, itemStack->mBase)) if (stacks(*it, itemStack.mBase))
{ {
// we already have an item stack of this kind, add to it // we already have an item stack of this kind, add to it
itemStack->mCount += it->getRefData().getCount(); itemStack.mCount += it->getRefData().getCount();
found = true;
break; break;
} }
} }
if (itemStack == mItems.end()) if (!found)
{ {
// no stack yet, create one // no stack yet, create one
ItemStack newItem (*it, this, it->getRefData().getCount()); ItemStack newItem (*it, this, it->getRefData().getCount());
@ -168,23 +167,24 @@ void ContainerItemModel::update()
} }
} }
} }
for (std::vector<MWWorld::Ptr>::iterator source = mWorldItems.begin(); source != mWorldItems.end(); ++source) for (MWWorld::Ptr& source : mWorldItems)
{ {
std::vector<ItemStack>::iterator itemStack = mItems.begin(); bool found = false;
for (; itemStack != mItems.end(); ++itemStack) for (ItemStack& itemStack : mItems)
{ {
if (stacks(*source, itemStack->mBase)) if (stacks(source, itemStack.mBase))
{ {
// we already have an item stack of this kind, add to it // we already have an item stack of this kind, add to it
itemStack->mCount += source->getRefData().getCount(); itemStack.mCount += source.getRefData().getCount();
found = true;
break; break;
} }
} }
if (itemStack == mItems.end()) if (!found)
{ {
// no stack yet, create one // no stack yet, create one
ItemStack newItem (*source, this, source->getRefData().getCount()); ItemStack newItem (source, this, source.getRefData().getCount());
mItems.push_back(newItem); mItems.push_back(newItem);
} }
} }

@ -184,16 +184,16 @@ namespace MWGui
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false); BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false);
size_t formatted = 0; // points to the first character that is not laid out yet size_t formatted = 0; // points to the first character that is not laid out yet
for (std::map<Range, intptr_t>::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it) for (auto& hyperLink : hyperLinks)
{ {
intptr_t topicId = it->second; intptr_t topicId = hyperLink.second;
BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, textColours.link, BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, textColours.link,
textColours.linkOver, textColours.linkPressed, textColours.linkOver, textColours.linkPressed,
topicId); topicId);
if (formatted < it->first.first) if (formatted < hyperLink.first.first)
typesetter->write(style, formatted, it->first.first); typesetter->write(style, formatted, hyperLink.first.first);
typesetter->write(hotStyle, it->first.first, it->first.second); typesetter->write(hotStyle, hyperLink.first.first, hyperLink.first.second);
formatted = it->first.second; formatted = hyperLink.first.second;
} }
if (formatted < text.size()) if (formatted < text.size())
typesetter->write(style, formatted, text.size()); typesetter->write(style, formatted, text.size());
@ -204,9 +204,8 @@ namespace MWGui
keywordSearch->highlightKeywords(text.begin(), text.end(), matches); keywordSearch->highlightKeywords(text.begin(), text.end(), matches);
std::string::const_iterator i = text.begin (); std::string::const_iterator i = text.begin ();
for (std::vector<KeywordSearchT::Match>::iterator it = matches.begin(); it != matches.end(); ++it) for (KeywordSearchT::Match& match : matches)
{ {
KeywordSearchT::Match match = *it;
if (i != match.mBeg) if (i != match.mBeg)
addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ()); addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ());
@ -419,13 +418,13 @@ namespace MWGui
bool sameActor = (mPtr == actor); bool sameActor = (mPtr == actor);
if (!sameActor) if (!sameActor)
{ {
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it) for (DialogueText* text : mHistoryContents)
delete (*it); delete text;
mHistoryContents.clear(); mHistoryContents.clear();
mKeywords.clear(); mKeywords.clear();
mTopicsList->clear(); mTopicsList->clear();
for (std::vector<Link*>::iterator it = mLinks.begin(); it != mLinks.end(); ++it) for (Link* link : mLinks)
mDeleteLater.push_back(*it); // Links are not deleted right away to prevent issues with event handlers mDeleteLater.push_back(link); // Links are not deleted right away to prevent issues with event handlers
mLinks.clear(); mLinks.clear();
} }
@ -489,8 +488,8 @@ namespace MWGui
void DialogueWindow::updateTopicsPane() void DialogueWindow::updateTopicsPane()
{ {
mTopicsList->clear(); mTopicsList->clear();
for (std::map<std::string, Link*>::iterator it = mTopicLinks.begin(); it != mTopicLinks.end(); ++it) for (auto& linkPair : mTopicLinks)
mDeleteLater.push_back(it->second); mDeleteLater.push_back(linkPair.second);
mTopicLinks.clear(); mTopicLinks.clear();
mKeywordSearch.clear(); mKeywordSearch.clear();
@ -533,15 +532,15 @@ namespace MWGui
mTopicsList->addSeparator(); mTopicsList->addSeparator();
for(std::list<std::string>::iterator it = mKeywords.begin(); it != mKeywords.end(); ++it) for(std::string& keyword : mKeywords)
{ {
mTopicsList->addItem(*it); mTopicsList->addItem(keyword);
Topic* t = new Topic(*it); Topic* t = new Topic(keyword);
t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated); t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated);
mTopicLinks[Misc::StringUtils::lowerCase(*it)] = t; mTopicLinks[Misc::StringUtils::lowerCase(keyword)] = t;
mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); mKeywordSearch.seed(Misc::StringUtils::lowerCase(keyword), intptr_t(t));
} }
mTopicsList->adjustSize(); mTopicsList->adjustSize();
@ -563,9 +562,8 @@ namespace MWGui
BookTypesetter::Ptr typesetter = BookTypesetter::create (mHistory->getWidth(), std::numeric_limits<int>::max()); BookTypesetter::Ptr typesetter = BookTypesetter::create (mHistory->getWidth(), std::numeric_limits<int>::max());
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it) for (DialogueText* text : mHistoryContents)
(*it)->write(typesetter, &mKeywordSearch, mTopicLinks); text->write(typesetter, &mKeywordSearch, mTopicLinks);
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false); BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false);
@ -573,9 +571,9 @@ namespace MWGui
// choices // choices
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
mChoices = MWBase::Environment::get().getDialogueManager()->getChoices(); mChoices = MWBase::Environment::get().getDialogueManager()->getChoices();
for (std::vector<std::pair<std::string, int> >::const_iterator it = mChoices.begin(); it != mChoices.end(); ++it) for (std::pair<std::string, int>& choice : mChoices)
{ {
Choice* link = new Choice(it->second); Choice* link = new Choice(choice.second);
link->eventChoiceActivated += MyGUI::newDelegate(this, &DialogueWindow::onChoiceActivated); link->eventChoiceActivated += MyGUI::newDelegate(this, &DialogueWindow::onChoiceActivated);
mLinks.push_back(link); mLinks.push_back(link);
@ -583,7 +581,7 @@ namespace MWGui
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver, BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver,
textColours.answerPressed, textColours.answerPressed,
TypesetBook::InteractiveId(link)); TypesetBook::InteractiveId(link));
typesetter->write(questionStyle, to_utf8_span(it->first.c_str())); typesetter->write(questionStyle, to_utf8_span(choice.first.c_str()));
} }
mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye(); mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye();

@ -348,8 +348,7 @@ namespace MWGui
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(item.getCellRef().getRefId(), mPtr)) if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(item.getCellRef().getRefId(), mPtr))
{ {
std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage49")->mValue.getString(); std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage49")->mValue.getString();
if (msg.find("%s") != std::string::npos) Misc::StringUtils::replace(msg, "%s", item.getClass().getName(item).c_str(), 2);
msg.replace(msg.find("%s"), 2, item.getClass().getName(item));
MWBase::Environment::get().getWindowManager()->messageBox(msg); MWBase::Environment::get().getWindowManager()->messageBox(msg);
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, item, mPtr, 1); MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, item, mPtr, 1);

@ -4,15 +4,11 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <MyGUI_EditBox.h> #include <MyGUI_EditBox.h>
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <MyGUI_FontManager.h>
// correctBookartPath // correctBookartPath
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/interpreter/defines.hpp> #include <components/interpreter/defines.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
@ -30,7 +26,7 @@ namespace MWGui
MWScript::InterpreterContext interpreterContext(nullptr, MWWorld::Ptr()); // empty arguments, because there is no locals or actor MWScript::InterpreterContext interpreterContext(nullptr, MWWorld::Ptr()); // empty arguments, because there is no locals or actor
mText = Interpreter::fixDefinesBook(mText, interpreterContext); mText = Interpreter::fixDefinesBook(mText, interpreterContext);
boost::algorithm::replace_all(mText, "\r", ""); Misc::StringUtils::replaceAll(mText, "\r", "");
// vanilla game does not show any text after the last EOL tag. // vanilla game does not show any text after the last EOL tag.
const std::string lowerText = Misc::StringUtils::lowerCase(mText); const std::string lowerText = Misc::StringUtils::lowerCase(mText);

@ -39,7 +39,6 @@
#include "itemmodel.hpp" #include "itemmodel.hpp"
#include "draganddrop.hpp" #include "draganddrop.hpp"
#include "itemmodel.hpp"
#include "itemwidget.hpp" #include "itemwidget.hpp"
namespace MWGui namespace MWGui

@ -37,9 +37,9 @@ size_t InventoryItemModel::getItemCount()
ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item) ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item)
{ {
size_t i = 0; size_t i = 0;
for (std::vector<ItemStack>::iterator it = mItems.begin(); it != mItems.end(); ++it) for (ItemStack& itemStack : mItems)
{ {
if (*it == item) if (itemStack == item)
return i; return i;
++i; ++i;
} }

@ -130,13 +130,13 @@ namespace MWGui
{ {
int currentY = 0; int currentY = 0;
for (Lines::const_iterator iter = mLines.begin(); iter != mLines.end(); ++iter) for (Line& line : mLines)
{ {
iter->mText->setCoord(8, currentY, mScrollView->getWidth()-8, 18); line.mText->setCoord(8, currentY, mScrollView->getWidth()-8, 18);
currentY += 19; currentY += 19;
iter->mIcon->setCoord(16, currentY, 32, 32); line.mIcon->setCoord(16, currentY, 32, 32);
iter->mCharge->setCoord(72, currentY+2, std::max(199, mScrollView->getWidth()-72-38), 20); line.mCharge->setCoord(72, currentY+2, std::max(199, mScrollView->getWidth()-72-38), 20);
currentY += 32 + 4; currentY += 32 + 4;
} }

@ -1,13 +1,9 @@
#include "itemmodel.hpp" #include "itemmodel.hpp"
#include <set>
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/store.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"

@ -156,12 +156,19 @@ namespace MWGui
void SpellWidget::setSpellIcon(const std::string& icon) void SpellWidget::setSpellIcon(const std::string& icon)
{ {
if (mFrame) if (mFrame && !mCurrentFrame.empty())
{
mCurrentFrame.clear();
mFrame->setImageTexture(""); mFrame->setImageTexture("");
if (mItemShadow) }
mItemShadow->setImageTexture(icon); if (mCurrentIcon != icon)
if (mItem) {
mItem->setImageTexture(icon); mCurrentIcon = icon;
if (mItemShadow)
mItemShadow->setImageTexture(icon);
if (mItem)
mItem->setImageTexture(icon);
}
} }
} }

@ -178,16 +178,12 @@ namespace MWGui
End of tes3mp addition End of tes3mp addition
*/ */
std::stringstream dayStr; Misc::StringUtils::replace(message, "%d", std::to_string(mDays).c_str(), 2);
dayStr << mDays;
if (message.find("%d") != std::string::npos)
message.replace(message.find("%d"), 2, dayStr.str());
for (std::set<int>::iterator it = skills.begin(); it != skills.end(); ++it) for (const int& skill : skills)
{ {
std::string skillName = gmst.find(ESM::Skill::sSkillNameIds[*it])->mValue.getString(); std::string skillName = gmst.find(ESM::Skill::sSkillNameIds[skill])->mValue.getString();
std::stringstream skillValue; int skillValue = player.getClass().getNpcStats(player).getSkill(skill).getBase();
skillValue << player.getClass().getNpcStats(player).getSkill(*it).getBase();
std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString(); std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString();
/* /*
@ -196,16 +192,14 @@ namespace MWGui
Account for usage of ignoreJailSkillIncreases Account for usage of ignoreJailSkillIncreases
*/ */
if (!localPlayer->ignoreJailSkillIncreases && if (!localPlayer->ignoreJailSkillIncreases &&
(*it == ESM::Skill::Sneak || *it == ESM::Skill::Security)) (skill == ESM::Skill::Sneak || skill == ESM::Skill::Security))
/* /*
End of tes3mp change (minor) End of tes3mp change (minor)
*/ */
skillMsg = gmst.find("sNotifyMessage39")->mValue.getString(); skillMsg = gmst.find("sNotifyMessage39")->mValue.getString();
if (skillMsg.find("%s") != std::string::npos) Misc::StringUtils::replace(skillMsg, "%s", skillName.c_str(), 2);
skillMsg.replace(skillMsg.find("%s"), 2, skillName); Misc::StringUtils::replace(skillMsg, "%d", std::to_string(skillValue).c_str(), 2);
if (skillMsg.find("%d") != std::string::npos)
skillMsg.replace(skillMsg.find("%d"), 2, skillValue.str());
message += "\n" + skillMsg; message += "\n" + skillMsg;
} }

@ -1,7 +1,5 @@
#include "journalbooks.hpp" #include "journalbooks.hpp"
#include <MyGUI_LanguageManager.h>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"

@ -1,6 +1,5 @@
#include "journalwindow.hpp" #include "journalwindow.hpp"
#include <sstream>
#include <set> #include <set>
#include <stack> #include <stack>
#include <string> #include <string>

@ -21,11 +21,11 @@ namespace MWGui
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent); mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
const std::string main_name = mPrefix + MAIN_WINDOW; const std::string main_name = mPrefix + MAIN_WINDOW;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter) for (MyGUI::Widget* widget : mListWindowRoot)
{ {
if ((*iter)->getName() == main_name) if (widget->getName() == main_name)
{ {
mMainWidget = (*iter); mMainWidget = widget;
break; break;
} }
} }
@ -66,10 +66,9 @@ namespace MWGui
MyGUI::Widget* Layout::getWidget(const std::string &_name) MyGUI::Widget* Layout::getWidget(const std::string &_name)
{ {
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); for (MyGUI::Widget* widget : mListWindowRoot)
iter!=mListWindowRoot.end(); ++iter)
{ {
MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); MyGUI::Widget* find = widget->findWidget(mPrefix + _name);
if (nullptr != find) if (nullptr != find)
{ {
return find; return find;

@ -12,7 +12,6 @@
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"

@ -1,6 +1,8 @@
#ifndef MWGUI_LOADINGSCREEN_H #ifndef MWGUI_LOADINGSCREEN_H
#define MWGUI_LOADINGSCREEN_H #define MWGUI_LOADINGSCREEN_H
#include <memory>
#include <osg/Timer> #include <osg/Timer>
#include <osg/ref_ptr> #include <osg/ref_ptr>

@ -270,36 +270,36 @@ namespace MWGui
// Create new buttons if needed // Create new buttons if needed
std::vector<std::string> allButtons { "return", "newgame", "savegame", "loadgame", "options", "credits", "exitgame"}; std::vector<std::string> allButtons { "return", "newgame", "savegame", "loadgame", "options", "credits", "exitgame"};
for (std::vector<std::string>::iterator it = allButtons.begin(); it != allButtons.end(); ++it) for (std::string& buttonId : allButtons)
{ {
if (mButtons.find(*it) == mButtons.end()) if (mButtons.find(buttonId) == mButtons.end())
{ {
Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton> Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton>
("ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default); ("ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default);
button->setProperty("ImageHighlighted", "textures\\menu_" + *it + "_over.dds"); button->setProperty("ImageHighlighted", "textures\\menu_" + buttonId + "_over.dds");
button->setProperty("ImageNormal", "textures\\menu_" + *it + ".dds"); button->setProperty("ImageNormal", "textures\\menu_" + buttonId + ".dds");
button->setProperty("ImagePushed", "textures\\menu_" + *it + "_pressed.dds"); button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked);
button->setUserData(std::string(*it)); button->setUserData(std::string(buttonId));
mButtons[*it] = button; mButtons[buttonId] = button;
} }
} }
// Start by hiding all buttons // Start by hiding all buttons
int maxwidth = 0; int maxwidth = 0;
for (std::map<std::string, Gui::ImageButton*>::iterator it = mButtons.begin(); it != mButtons.end(); ++it) for (auto& buttonPair : mButtons)
{ {
it->second->setVisible(false); buttonPair.second->setVisible(false);
MyGUI::IntSize requested = it->second->getRequestedSize(); MyGUI::IntSize requested = buttonPair.second->getRequestedSize();
if (requested.width > maxwidth) if (requested.width > maxwidth)
maxwidth = requested.width; maxwidth = requested.width;
} }
// Now show and position the ones we want // Now show and position the ones we want
for (std::vector<std::string>::iterator it = buttons.begin(); it != buttons.end(); ++it) for (std::string& buttonId : buttons)
{ {
assert(mButtons.find(*it) != mButtons.end()); assert(mButtons.find(buttonId) != mButtons.end());
Gui::ImageButton* button = mButtons[*it]; Gui::ImageButton* button = mButtons[buttonId];
button->setVisible(true); button->setVisible(true);
MyGUI::IntSize requested = button->getRequestedSize(); MyGUI::IntSize requested = button->getRequestedSize();

@ -343,8 +343,8 @@ namespace MWGui
void LocalMapBase::updateCustomMarkers() void LocalMapBase::updateCustomMarkers()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mCustomMarkerWidgets.begin(); it != mCustomMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mCustomMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mCustomMarkerWidgets.clear(); mCustomMarkerWidgets.clear();
for (int dX = -mCellDistance; dX <= mCellDistance; ++dX) for (int dX = -mCellDistance; dX <= mCellDistance; ++dX)
@ -546,9 +546,9 @@ namespace MWGui
} }
int counter = 0; int counter = 0;
for (std::vector<MWWorld::Ptr>::iterator it = markers.begin(); it != markers.end(); ++it) for (const MWWorld::Ptr& ptr : markers)
{ {
const ESM::Position& worldPos = it->getRefData().getPosition(); const ESM::Position& worldPos = ptr.getRefData().getPosition();
MarkerUserData markerPos (mLocalMapRender); MarkerUserData markerPos (mLocalMapRender);
MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos);
MyGUI::IntCoord widgetCoord(widgetPos.left - 4, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
@ -585,8 +585,8 @@ namespace MWGui
void LocalMapBase::updateDoorMarkers() void LocalMapBase::updateDoorMarkers()
{ {
// clear all previous door markers // clear all previous door markers
for (std::vector<MyGUI::Widget*>::iterator it = mDoorMarkerWidgets.begin(); it != mDoorMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mDoorMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mDoorMarkerWidgets.clear(); mDoorMarkerWidgets.clear();
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
@ -612,10 +612,8 @@ namespace MWGui
// Create a widget for each marker // Create a widget for each marker
int counter = 0; int counter = 0;
for (std::vector<MWBase::World::DoorMarker>::iterator it = doors.begin(); it != doors.end(); ++it) for (MWBase::World::DoorMarker& marker : doors)
{ {
MWBase::World::DoorMarker marker = *it;
std::vector<std::string> destNotes; std::vector<std::string> destNotes;
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest); CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest);
for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second; ++iter) for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second; ++iter)
@ -648,8 +646,8 @@ namespace MWGui
void LocalMapBase::updateMagicMarkers() void LocalMapBase::updateMagicMarkers()
{ {
// clear all previous markers // clear all previous markers
for (std::vector<MyGUI::Widget*>::iterator it = mMagicMarkerWidgets.begin(); it != mMagicMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mMagicMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mMagicMarkerWidgets.clear(); mMagicMarkerWidgets.clear();
addDetectionMarkers(MWBase::World::Detect_Creature); addDetectionMarkers(MWBase::World::Detect_Creature);
@ -907,9 +905,9 @@ namespace MWGui
mGlobalMapRender->cleanupCameras(); mGlobalMapRender->cleanupCameras();
for (std::vector<CellId>::iterator it = mQueuedToExplore.begin(); it != mQueuedToExplore.end(); ++it) for (CellId& cellId : mQueuedToExplore)
{ {
mGlobalMapRender->exploreCell(it->first, it->second, mLocalMapRender->getMapTexture(it->first, it->second)); mGlobalMapRender->exploreCell(cellId.first, cellId.second, mLocalMapRender->getMapTexture(cellId.first, cellId.second));
} }
mQueuedToExplore.clear(); mQueuedToExplore.clear();
@ -961,11 +959,11 @@ namespace MWGui
{ {
LocalMapBase::updateCustomMarkers(); LocalMapBase::updateCustomMarkers();
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator widgetIt = mGlobalMapMarkers.begin(); widgetIt != mGlobalMapMarkers.end(); ++widgetIt) for (auto& widgetPair : mGlobalMapMarkers)
{ {
int x = widgetIt->first.first; int x = widgetPair.first.first;
int y = widgetIt->first.second; int y = widgetPair.first.second;
MyGUI::Widget* markerWidget = widgetIt->second; MyGUI::Widget* markerWidget = widgetPair.second;
setGlobalMapMarkerTooltip(markerWidget, x, y); setGlobalMapMarkerTooltip(markerWidget, x, y);
} }
} }
@ -1090,8 +1088,8 @@ namespace MWGui
mGlobalMapRender->clear(); mGlobalMapRender->clear();
mChanged = true; mChanged = true;
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it) for (auto& widgetPair : mGlobalMapMarkers)
MyGUI::Gui::getInstance().destroyWidget(it->second); MyGUI::Gui::getInstance().destroyWidget(widgetPair.second);
mGlobalMapMarkers.clear(); mGlobalMapMarkers.clear();
} }
@ -1116,11 +1114,11 @@ namespace MWGui
mGlobalMapRender->read(map); mGlobalMapRender->read(map);
for (std::set<ESM::GlobalMap::CellId>::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) for (const ESM::GlobalMap::CellId& cellId : map.mMarkers)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(it->first, it->second); const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(cellId.first, cellId.second);
if (cell && !cell->mName.empty()) if (cell && !cell->mName.empty())
addVisitedLocation(cell->mName, it->first, it->second); addVisitedLocation(cell->mName, cellId.first, cellId.second);
} }
} }
} }
@ -1130,8 +1128,8 @@ namespace MWGui
NoDrop::setAlpha(alpha); NoDrop::setAlpha(alpha);
// can't allow showing map with partial transparency, as the fog of war will also go transparent // can't allow showing map with partial transparency, as the fog of war will also go transparent
// and reveal parts of the map you shouldn't be able to see // and reveal parts of the map you shouldn't be able to see
for (std::vector<MyGUI::ImageBox*>::iterator it = mMapWidgets.begin(); it != mMapWidgets.end(); ++it) for (MyGUI::ImageBox* widget : mMapWidgets)
(*it)->setVisible(alpha == 1); widget->setVisible(alpha == 1);
} }
void MapWindow::customMarkerCreated(MyGUI::Widget *marker) void MapWindow::customMarkerCreated(MyGUI::Widget *marker)

@ -2,6 +2,7 @@
#define MWGUI_MAPWINDOW_H #define MWGUI_MAPWINDOW_H
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "windowpinnablebase.hpp" #include "windowpinnablebase.hpp"

@ -28,10 +28,9 @@ namespace MWGui
MessageBoxManager::~MessageBoxManager () MessageBoxManager::~MessageBoxManager ()
{ {
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin()); for (MessageBox* messageBox : mMessageBoxes)
for (; it != mMessageBoxes.end(); ++it)
{ {
delete *it; delete messageBox;
} }
} }
@ -50,12 +49,11 @@ namespace MWGui
mInterMessageBoxe = nullptr; mInterMessageBoxe = nullptr;
} }
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin()); for (MessageBox* messageBox : mMessageBoxes)
for (; it != mMessageBoxes.end(); ++it)
{ {
if (*it == mStaticMessageBox) if (messageBox == mStaticMessageBox)
mStaticMessageBox = nullptr; mStaticMessageBox = nullptr;
delete *it; delete messageBox;
} }
mMessageBoxes.clear(); mMessageBoxes.clear();
@ -81,9 +79,9 @@ namespace MWGui
it = mMessageBoxes.begin(); it = mMessageBoxes.begin();
while(it != mMessageBoxes.end()) while(it != mMessageBoxes.end())
{ {
(*it)->update(static_cast<int>(height)); (*it)->update(static_cast<int>(height));
height += (*it)->getHeight(); height += (*it)->getHeight();
++it; ++it;
} }
if(mInterMessageBoxe != nullptr && mInterMessageBoxe->mMarkedToDelete) { if(mInterMessageBoxe != nullptr && mInterMessageBoxe->mMarkedToDelete) {
@ -114,10 +112,10 @@ namespace MWGui
} }
int height = 0; int height = 0;
for(std::vector<MessageBox*>::iterator it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) for (MessageBox* messageBox : mMessageBoxes)
{ {
(*it)->update(height); messageBox->update(height);
height += (*it)->getHeight(); height += messageBox->getHeight();
} }
} }
@ -240,14 +238,14 @@ namespace MWGui
int buttonHeight = 0; int buttonHeight = 0;
MyGUI::IntCoord dummyCoord(0, 0, 0, 0); MyGUI::IntCoord dummyCoord(0, 0, 0, 0);
for(std::vector<std::string>::const_iterator it = buttons.begin(); it != buttons.end(); ++it) for(const std::string& buttonId : buttons)
{ {
MyGUI::Button* button = mButtonsWidget->createWidget<MyGUI::Button>( MyGUI::Button* button = mButtonsWidget->createWidget<MyGUI::Button>(
MyGUI::WidgetStyle::Child, MyGUI::WidgetStyle::Child,
std::string("MW_Button"), std::string("MW_Button"),
dummyCoord, dummyCoord,
MyGUI::Align::Default); MyGUI::Align::Default);
button->setCaptionWithReplacing(*it); button->setCaptionWithReplacing(buttonId);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
@ -300,16 +298,16 @@ namespace MWGui
MyGUI::IntSize buttonSize(0, buttonHeight); MyGUI::IntSize buttonSize(0, buttonHeight);
int left = (mainWidgetSize.width - buttonsWidth)/2; int left = (mainWidgetSize.width - buttonsWidth)/2;
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
buttonCord.left = left; buttonCord.left = left;
buttonCord.top = messageWidgetCoord.top + textSize.height + textButtonPadding; buttonCord.top = messageWidgetCoord.top + textSize.height + textButtonPadding;
buttonSize.width = (*button)->getTextSize().width + 2*buttonLabelLeftPadding; buttonSize.width = button->getTextSize().width + 2*buttonLabelLeftPadding;
buttonSize.height = (*button)->getTextSize().height + 2*buttonLabelTopPadding; buttonSize.height = button->getTextSize().height + 2*buttonLabelTopPadding;
(*button)->setCoord(buttonCord); button->setCoord(buttonCord);
(*button)->setSize(buttonSize); button->setSize(buttonSize);
left += buttonSize.width + buttonLeftPadding; left += buttonSize.width + buttonLeftPadding;
} }
@ -329,16 +327,16 @@ namespace MWGui
int top = textPadding + textSize.height + textButtonPadding; int top = textPadding + textSize.height + textButtonPadding;
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
buttonSize.width = (*button)->getTextSize().width + buttonLabelLeftPadding*2; buttonSize.width = button->getTextSize().width + buttonLabelLeftPadding*2;
buttonSize.height = (*button)->getTextSize().height + buttonLabelTopPadding*2; buttonSize.height = button->getTextSize().height + buttonLabelTopPadding*2;
buttonCord.top = top; buttonCord.top = top;
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2; buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2;
(*button)->setCoord(buttonCord); button->setCoord(buttonCord);
(*button)->setSize(buttonSize); button->setSize(buttonSize);
top += buttonSize.height + buttonTopPadding; top += buttonSize.height + buttonTopPadding;
} }
@ -368,13 +366,13 @@ namespace MWGui
MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus() MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus()
{ {
std::vector<std::string> keywords { "sOk", "sYes" }; std::vector<std::string> keywords { "sOk", "sYes" };
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
for (const std::string& keyword : keywords) for (const std::string& keyword : keywords)
{ {
if(Misc::StringUtils::ciEqual(MyGUI::LanguageManager::getInstance().replaceTags("#{" + keyword + "}"), (*button)->getCaption())) if(Misc::StringUtils::ciEqual(MyGUI::LanguageManager::getInstance().replaceTags("#{" + keyword + "}"), button->getCaption()))
{ {
return *button; return button;
} }
} }
} }
@ -390,10 +388,9 @@ namespace MWGui
{ {
mMarkedToDelete = true; mMarkedToDelete = true;
int index = 0; int index = 0;
std::vector<MyGUI::Button*>::const_iterator button; for(const MyGUI::Button* button : mButtons)
for(button = mButtons.begin(); button != mButtons.end(); ++button)
{ {
if(*button == pressed) if(button == pressed)
{ {
mButtonPressed = index; mButtonPressed = index;
mMessageBoxManager.onButtonPressed(mButtonPressed); mMessageBoxManager.onButtonPressed(mButtonPressed);

@ -667,32 +667,32 @@ namespace MWGui
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
int i=0; int i=0;
for (std::vector<ESM::QuickKeys::QuickKey>::const_iterator it = keys.mKeys.begin(); it != keys.mKeys.end(); ++it) for (ESM::QuickKeys::QuickKey& quickKey : keys.mKeys)
{ {
if (i >= 10) if (i >= 10)
return; return;
mSelected = &mKey[i]; mSelected = &mKey[i];
switch (it->mType) switch (quickKey.mType)
{ {
case Type_Magic: case Type_Magic:
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->mId)) if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(quickKey.mId))
onAssignMagic(it->mId); onAssignMagic(quickKey.mId);
break; break;
case Type_Item: case Type_Item:
case Type_MagicItem: case Type_MagicItem:
{ {
// Find the item by id // Find the item by id
MWWorld::Ptr item = store.findReplacement(it->mId); MWWorld::Ptr item = store.findReplacement(quickKey.mId);
if (item.isEmpty()) if (item.isEmpty())
unassign(mSelected); unassign(mSelected);
else else
{ {
if (it->mType == Type_Item) if (quickKey.mType == Type_Item)
onAssignItem(item); onAssignItem(item);
else // if (it->mType == Type_MagicItem) else // if (quickKey.mType == Type_MagicItem)
onAssignMagicItem(item); onAssignMagicItem(item);
} }

@ -301,9 +301,8 @@ namespace MWGui
const MWWorld::Store<ESM::BodyPart> &store = const MWWorld::Store<ESM::BodyPart> &store =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
for (MWWorld::Store<ESM::BodyPart>::iterator it = store.begin(); it != store.end(); ++it) for (const ESM::BodyPart& bodypart : store)
{ {
const ESM::BodyPart& bodypart = *it;
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable) if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
continue; continue;
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin) if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
@ -364,22 +363,21 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>();
std::vector<std::pair<std::string, std::string> > items; // ID, name std::vector<std::pair<std::string, std::string> > items; // ID, name
MWWorld::Store<ESM::Race>::iterator it = races.begin(); for (const ESM::Race& race : races)
for (; it != races.end(); ++it)
{ {
bool playable = it->mData.mFlags & ESM::Race::Playable; bool playable = race.mData.mFlags & ESM::Race::Playable;
if (!playable) // Only display playable races if (!playable) // Only display playable races
continue; continue;
items.push_back(std::make_pair(it->mId, it->mName)); items.push_back(std::make_pair(race.mId, race.mName));
} }
std::sort(items.begin(), items.end(), sortRaces); std::sort(items.begin(), items.end(), sortRaces);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, std::string> >::const_iterator iter = items.begin(); iter != items.end(); ++iter) for (auto& item : items)
{ {
mRaceList->addItem(iter->second, iter->first); mRaceList->addItem(item.second, item.first);
if (Misc::StringUtils::ciEqual(iter->first, mCurrentRaceId)) if (Misc::StringUtils::ciEqual(item.first, mCurrentRaceId))
mRaceList->setIndexSelected(index); mRaceList->setIndexSelected(index);
++index; ++index;
} }
@ -387,9 +385,9 @@ namespace MWGui
void RaceDialog::updateSkills() void RaceDialog::updateSkills()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it) for (MyGUI::Widget* widget : mSkillItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSkillItems.clear(); mSkillItems.clear();
@ -424,9 +422,9 @@ namespace MWGui
void RaceDialog::updateSpellPowers() void RaceDialog::updateSpellPowers()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it) for (MyGUI::Widget* widget : mSpellPowerItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSpellPowerItems.clear(); mSpellPowerItems.clear();
@ -439,11 +437,9 @@ namespace MWGui
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId); const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->mPowers.mList.begin(); int i = 0;
std::vector<std::string>::const_iterator end = race->mPowers.mList.end(); for (const std::string& spellpower : race->mPowers.mList)
for (int i = 0; it != end; ++it)
{ {
const std::string &spellpower = *it;
Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i)); Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i));
spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setSpellId(spellpower);
spellPowerWidget->setUserString("ToolTipType", "Spell"); spellPowerWidget->setUserString("ToolTipType", "Spell");

@ -1,6 +1,8 @@
#ifndef MWGUI_RACE_H #ifndef MWGUI_RACE_H
#define MWGUI_RACE_H #define MWGUI_RACE_H
#include <memory>
#include "windowbase.hpp" #include "windowbase.hpp"
#include <MyGUI_RenderManager.h> #include <MyGUI_RenderManager.h>

@ -1,7 +1,5 @@
#include "recharge.hpp" #include "recharge.hpp"
#include <boost/format.hpp>
#include <MyGUI_ScrollView.h> #include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
@ -209,7 +207,8 @@ void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item)
if (gem.getRefData().getCount() == 0) if (gem.getRefData().getCount() == 0)
{ {
std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage51")->mValue.getString(); std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage51")->mValue.getString();
message = boost::str(boost::format(message) % gem.getClass().getName(gem)); Misc::StringUtils::replace(message, "%s", gem.getClass().getName(gem).c_str(), 2);
MWBase::Environment::get().getWindowManager()->messageBox(message); MWBase::Environment::get().getWindowManager()->messageBox(message);
// special case: readd Azura's Star // special case: readd Azura's Star

@ -228,11 +228,9 @@ namespace MWGui
std::set<int> skillSet; std::set<int> skillSet;
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::sSkillIds.end();
mMiscSkills.clear(); mMiscSkills.clear();
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::sSkillIds.begin(); it != end; ++it) for (const int skill : ESM::Skill::sSkillIds)
{ {
int skill = *it;
if (skillSet.find(skill) == skillSet.end()) if (skillSet.find(skill) == skillSet.end())
mMiscSkills.push_back(skill); mMiscSkills.push_back(skill);
} }
@ -355,9 +353,9 @@ namespace MWGui
void ReviewDialog::updateSkillArea() void ReviewDialog::updateSkillArea()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) for (MyGUI::Widget* skillWidget : mSkillWidgets)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(skillWidget);
} }
mSkillWidgets.clear(); mSkillWidgets.clear();
@ -390,19 +388,18 @@ namespace MWGui
attributes[i] = mAttributeWidgets[i]->getAttributeValue().getBase(); attributes[i] = mAttributeWidgets[i]->getAttributeValue().getBase();
std::vector<std::string> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race); std::vector<std::string> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race);
for (std::vector<std::string>::iterator iter = selectedSpells.begin(); iter != selectedSpells.end(); ++iter) for (std::string& spellId : selectedSpells)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
if (race) if (race)
{ {
for (std::vector<std::string>::const_iterator iter = race->mPowers.mList.begin(); for (const std::string& spellId : race->mPowers.mList)
iter != race->mPowers.mList.end(); ++iter)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
@ -411,10 +408,9 @@ namespace MWGui
if (!mBirthSignId.empty()) if (!mBirthSignId.empty())
{ {
const ESM::BirthSign* sign = MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId); const ESM::BirthSign* sign = MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId);
for (std::vector<std::string>::const_iterator iter = sign->mPowers.mList.begin(); for (const std::string& spellId : sign->mPowers.mList)
iter != sign->mPowers.mList.end(); ++iter)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
@ -423,27 +419,27 @@ namespace MWGui
if (!mSkillWidgets.empty()) if (!mSkillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeAbility", "Abilities"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeAbility", "Abilities"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Ability) if (spell->mData.mType == ESM::Spell::ST_Ability)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypePower", "Powers"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypePower", "Powers"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeSpell", "Spells"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeSpell", "Spells"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Spell) if (spell->mData.mType == ESM::Spell::ST_Spell)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }

@ -1,6 +1,8 @@
#ifndef OPENMW_MWGUI_SAVEGAMEDIALOG_H #ifndef OPENMW_MWGUI_SAVEGAMEDIALOG_H
#define OPENMW_MWGUI_SAVEGAMEDIALOG_H #define OPENMW_MWGUI_SAVEGAMEDIALOG_H
#include <memory>
#include "windowbase.hpp" #include "windowbase.hpp"
namespace MWState namespace MWState

@ -2,6 +2,7 @@
#define OPENMW_MWGUI_SCREENFADER_H #define OPENMW_MWGUI_SCREENFADER_H
#include <deque> #include <deque>
#include <memory>
#include "windowbase.hpp" #include "windowbase.hpp"

@ -8,11 +8,12 @@
#include <MyGUI_TabControl.h> #include <MyGUI_TabControl.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/math/common_factor.hpp>
#include <SDL_video.h> #include <SDL_video.h>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp>
#include <components/misc/gcd.hpp>
#include <components/widgets/sharedstatebutton.hpp> #include <components/widgets/sharedstatebutton.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -58,7 +59,7 @@ namespace
std::string getAspect (int x, int y) std::string getAspect (int x, int y)
{ {
int gcd = boost::math::gcd (x, y); int gcd = Misc::gcd (x, y);
int xaspect = x / gcd; int xaspect = x / gcd;
int yaspect = y / gcd; int yaspect = y / gcd;
// special case: 8 : 5 is usually referred to as 16:10 // special case: 8 : 5 is usually referred to as 16:10
@ -174,7 +175,7 @@ namespace MWGui
MyGUI::TextBox* textBox; MyGUI::TextBox* textBox;
getWidget(textBox, labelWidgetName); getWidget(textBox, labelWidgetName);
std::string labelCaption = scroller->getUserString("SettingLabelCaption"); std::string labelCaption = scroller->getUserString("SettingLabelCaption");
boost::algorithm::replace_all(labelCaption, "%s", value); Misc::StringUtils::replaceAll(labelCaption, "%s", value.c_str(), 2);
textBox->setCaptionWithReplacing(labelCaption); textBox->setCaptionWithReplacing(labelCaption);
} }
} }
@ -199,6 +200,7 @@ namespace MWGui
getWidget(mKeyboardSwitch, "KeyboardButton"); getWidget(mKeyboardSwitch, "KeyboardButton");
getWidget(mControllerSwitch, "ControllerButton"); getWidget(mControllerSwitch, "ControllerButton");
getWidget(mWaterTextureSize, "WaterTextureSize"); getWidget(mWaterTextureSize, "WaterTextureSize");
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
#ifndef WIN32 #ifndef WIN32
// hide gamma controls since it currently does not work under Linux // hide gamma controls since it currently does not work under Linux
@ -222,6 +224,7 @@ namespace MWGui
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected); mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged); mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged);
mWaterReflectionDetail->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterReflectionDetailChanged);
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked); mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked); mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
@ -241,11 +244,10 @@ namespace MWGui
resolutions.push_back(std::make_pair(mode.w, mode.h)); resolutions.push_back(std::make_pair(mode.w, mode.h));
} }
std::sort(resolutions.begin(), resolutions.end(), sortResolutions); std::sort(resolutions.begin(), resolutions.end(), sortResolutions);
for (std::vector < std::pair<int, int> >::const_iterator it=resolutions.begin(); for (std::pair<int, int>& resolution : resolutions)
it!=resolutions.end(); ++it)
{ {
std::string str = MyGUI::utility::toString(it->first) + " x " + MyGUI::utility::toString(it->second) std::string str = MyGUI::utility::toString(resolution.first) + " x " + MyGUI::utility::toString(resolution.second)
+ " (" + getAspect(it->first,it->second) + ")"; + " (" + getAspect(resolution.first, resolution.second) + ")";
if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE) if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE)
mResolutionList->addItem(str); mResolutionList->addItem(str);
@ -255,7 +257,7 @@ namespace MWGui
std::string tmip = Settings::Manager::getString("texture mipmap", "General"); std::string tmip = Settings::Manager::getString("texture mipmap", "General");
mTextureFilteringButton->setCaption(textureMipmappingToStr(tmip)); mTextureFilteringButton->setCaption(textureMipmappingToStr(tmip));
int waterTextureSize = Settings::Manager::getInt ("rtt size", "Water"); int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
if (waterTextureSize >= 512) if (waterTextureSize >= 512)
mWaterTextureSize->setIndexSelected(0); mWaterTextureSize->setIndexSelected(0);
if (waterTextureSize >= 1024) if (waterTextureSize >= 1024)
@ -263,6 +265,10 @@ namespace MWGui
if (waterTextureSize >= 2048) if (waterTextureSize >= 2048)
mWaterTextureSize->setIndexSelected(2); mWaterTextureSize->setIndexSelected(2);
int waterReflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
waterReflectionDetail = std::min(4, std::max(0, waterReflectionDetail));
mWaterReflectionDetail->setIndexSelected(waterReflectionDetail);
mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video")); mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));
mKeyboardSwitch->setStateSelected(true); mKeyboardSwitch->setStateSelected(true);
@ -342,6 +348,13 @@ namespace MWGui
apply(); apply();
} }
void SettingsWindow::onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
{
unsigned int level = std::min((unsigned int)4, (unsigned int)pos);
Settings::Manager::setInt("reflection detail", "Water", level);
apply();
}
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender) void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
{ {
std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On"); std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On");
@ -490,17 +503,17 @@ namespace MWGui
else else
actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting(); actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting();
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it) for (const int& action : actions)
{ {
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it); std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (action);
if (desc == "") if (desc == "")
continue; continue;
std::string binding; std::string binding;
if(mKeyboardMode) if(mKeyboardMode)
binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(*it); binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(action);
else else
binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(*it); binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(action);
Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
leftText->setCaptionWithReplacing(desc); leftText->setCaptionWithReplacing(desc);
@ -508,7 +521,7 @@ namespace MWGui
Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
rightText->setCaptionWithReplacing(binding); rightText->setCaptionWithReplacing(binding);
rightText->setTextAlign (MyGUI::Align::Right); rightText->setTextAlign (MyGUI::Align::Right);
rightText->setUserData(*it); // save the action id for callbacks rightText->setUserData(action); // save the action id for callbacks
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction); rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel); rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);

@ -33,6 +33,7 @@ namespace MWGui
MyGUI::Widget* mAnisotropyBox; MyGUI::Widget* mAnisotropyBox;
MyGUI::ComboBox* mWaterTextureSize; MyGUI::ComboBox* mWaterTextureSize;
MyGUI::ComboBox* mWaterReflectionDetail;
// controls // controls
MyGUI::ScrollView* mControlsBox; MyGUI::ScrollView* mControlsBox;
@ -52,6 +53,7 @@ namespace MWGui
void highlightCurrentResolution(); void highlightCurrentResolution();
void onWaterTextureSizeChanged(MyGUI::ComboBox* _sender, size_t pos); void onWaterTextureSizeChanged(MyGUI::ComboBox* _sender, size_t pos);
void onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos);
void onRebindAction(MyGUI::Widget* _sender); void onRebindAction(MyGUI::Widget* _sender);
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel); void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);

@ -133,9 +133,9 @@ namespace MWGui
std::stable_sort(spellsToSort.begin(), spellsToSort.end(), sortSpells); std::stable_sort(spellsToSort.begin(), spellsToSort.end(), sortSpells);
for (std::vector<const ESM::Spell*>::iterator it = spellsToSort.begin() ; it != spellsToSort.end(); ++it) for (const ESM::Spell* spell : spellsToSort)
{ {
addSpell(**it); addSpell(*spell);
} }
spellsToSort.clear(); spellsToSort.clear();

@ -481,10 +481,8 @@ namespace MWGui
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effect : mEffects)
{ {
const ESM::ENAMstruct& effect = *it;
y += std::max(1.f, MWMechanics::calcEffectCost(effect)); y += std::max(1.f, MWMechanics::calcEffectCost(effect));
if (effect.mRange == ESM::RT_Target) if (effect.mRange == ESM::RT_Target)
@ -556,18 +554,17 @@ namespace MWGui
if (spell->mData.mType != ESM::Spell::ST_Spell) if (spell->mData.mType != ESM::Spell::ST_Spell)
continue; continue;
const std::vector<ESM::ENAMstruct>& list = spell->mEffects.mList; for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2)
{ {
const ESM::MagicEffect * effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it2->mEffectID); const ESM::MagicEffect * effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectInfo.mEffectID);
// skip effects that do not allow spellmaking/enchanting // skip effects that do not allow spellmaking/enchanting
int requiredFlags = (mType == Spellmaking) ? ESM::MagicEffect::AllowSpellmaking : ESM::MagicEffect::AllowEnchanting; int requiredFlags = (mType == Spellmaking) ? ESM::MagicEffect::AllowSpellmaking : ESM::MagicEffect::AllowEnchanting;
if (!(effect->mData.mFlags & requiredFlags)) if (!(effect->mData.mFlags & requiredFlags))
continue; continue;
if (std::find(knownEffects.begin(), knownEffects.end(), it2->mEffectID) == knownEffects.end()) if (std::find(knownEffects.begin(), knownEffects.end(), effectInfo.mEffectID) == knownEffects.end())
knownEffects.push_back(it2->mEffectID); knownEffects.push_back(effectInfo.mEffectID);
} }
} }
@ -576,23 +573,23 @@ namespace MWGui
mAvailableEffectsList->clear (); mAvailableEffectsList->clear ();
int i=0; int i=0;
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (const short effectId : knownEffects)
{ {
mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->mValue.getString()); ESM::MagicEffect::effectIdToString(effectId))->mValue.getString());
mButtonMapping[i] = *it; mButtonMapping[i] = effectId;
++i; ++i;
} }
mAvailableEffectsList->adjustSize (); mAvailableEffectsList->adjustSize ();
mAvailableEffectsList->scrollToTop(); mAvailableEffectsList->scrollToTop();
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (const short effectId : knownEffects)
{ {
std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->mValue.getString(); ESM::MagicEffect::effectIdToString(effectId))->mValue.getString();
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
ToolTips::createMagicEffectToolTip (w, *it); ToolTips::createMagicEffectToolTip (w, effectId);
} }
mEffects.clear(); mEffects.clear();
@ -672,9 +669,9 @@ namespace MWGui
} }
else else
{ {
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effectInfo : mEffects)
{ {
if (it->mEffectID == mSelectedKnownEffectId) if (effectInfo.mEffectID == mSelectedKnownEffectId)
{ {
MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}");
return; return;
@ -706,17 +703,17 @@ namespace MWGui
MyGUI::IntSize size(0,0); MyGUI::IntSize size(0,0);
int i = 0; int i = 0;
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effectInfo : mEffects)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mArea = it->mArea; params.mArea = effectInfo.mArea;
params.mIsConstant = mConstantEffect; params.mIsConstant = mConstantEffect;
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);

@ -65,10 +65,11 @@ namespace MWGui
int w=2; int w=2;
for (std::map <int, std::vector<MagicEffectInfo> >::const_iterator it = effects.begin(); it != effects.end(); ++it) for (auto& effectInfoPair : effects)
{ {
const int effectId = effectInfoPair.first;
const ESM::MagicEffect* effect = const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first); MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(effectId);
float remainingDuration = 0; float remainingDuration = 0;
float totalDuration = 0; float totalDuration = 0;
@ -77,46 +78,50 @@ namespace MWGui
static const float fadeTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMagicStartIconBlink")->mValue.getFloat(); static const float fadeTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMagicStartIconBlink")->mValue.getFloat();
for (std::vector<MagicEffectInfo>::const_iterator effectIt = it->second.begin(); std::vector<MagicEffectInfo>& effectInfos = effectInfoPair.second;
effectIt != it->second.end(); ++effectIt) bool addNewLine = true;
for (const MagicEffectInfo& effectInfo : effectInfos)
{ {
if (effectIt != it->second.begin()) if (addNewLine)
{
sourcesDescription += "\n"; sourcesDescription += "\n";
addNewLine = false;
}
// if at least one of the effect sources is permanent, the effect will never wear off // if at least one of the effect sources is permanent, the effect will never wear off
if (effectIt->mPermanent) if (effectInfo.mPermanent)
{ {
remainingDuration = fadeTime; remainingDuration = fadeTime;
totalDuration = fadeTime; totalDuration = fadeTime;
} }
else else
{ {
remainingDuration = std::max(remainingDuration, effectIt->mRemainingTime); remainingDuration = std::max(remainingDuration, effectInfo.mRemainingTime);
totalDuration = std::max(totalDuration, effectIt->mTotalTime); totalDuration = std::max(totalDuration, effectInfo.mTotalTime);
} }
sourcesDescription += effectIt->mSource; sourcesDescription += effectInfo.mSource;
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill) if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
sourcesDescription += " (" + sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString( MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Skill::sSkillNameIds[effectIt->mKey.mArg], "") + ")"; ESM::Skill::sSkillNameIds[effectInfo.mKey.mArg], "") + ")";
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute) if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
sourcesDescription += " (" + sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString( MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")"; ESM::Attribute::sGmstAttributeIds[effectInfo.mKey.mArg], "") + ")";
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType(); ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt) if (displayType == ESM::MagicEffect::MDT_TimesInt)
{ {
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", ""); std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::stringstream formatter; std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt; formatter << std::fixed << std::setprecision(1) << " " << (effectInfo.mMagnitude / 10.0f) << timesInt;
sourcesDescription += formatter.str(); sourcesDescription += formatter.str();
} }
else if ( displayType != ESM::MagicEffect::MDT_None ) else if ( displayType != ESM::MagicEffect::MDT_None )
{ {
sourcesDescription += ": " + MyGUI::utility::toString(effectIt->mMagnitude); sourcesDescription += ": " + MyGUI::utility::toString(effectInfo.mMagnitude);
if ( displayType == ESM::MagicEffect::MDT_Percentage ) if ( displayType == ESM::MagicEffect::MDT_Percentage )
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", ""); sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
@ -124,32 +129,35 @@ namespace MWGui
sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", ""); sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
else if ( displayType == ESM::MagicEffect::MDT_Level ) else if ( displayType == ESM::MagicEffect::MDT_Level )
{ {
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") : MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") ); MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") );
} }
else // ESM::MagicEffect::MDT_Points else // ESM::MagicEffect::MDT_Points
{ {
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") : MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") ); MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") );
} }
} }
if (effectIt->mRemainingTime > -1 && if (effectInfo.mRemainingTime > -1 &&
Settings::Manager::getBool("show effect duration","Game")) { Settings::Manager::getBool("show effect duration","Game")) {
sourcesDescription += " #{sDuration}: "; sourcesDescription += " #{sDuration}: ";
float duration = effectIt->mRemainingTime; float duration = effectInfo.mRemainingTime;
if (duration > 3600) { if (duration > 3600)
{
int hour = duration / 3600; int hour = duration / 3600;
duration -= hour*3600; duration -= hour*3600;
sourcesDescription += MWGui::ToolTips::toString(hour) + "h"; sourcesDescription += MWGui::ToolTips::toString(hour) + "h";
} }
if (duration > 60) { if (duration > 60)
{
int minute = duration / 60; int minute = duration / 60;
duration -= minute*60; duration -= minute*60;
sourcesDescription += MWGui::ToolTips::toString(minute) + "m"; sourcesDescription += MWGui::ToolTips::toString(minute) + "m";
} }
if (duration > 0.1) { if (duration > 0.1)
{
sourcesDescription += MWGui::ToolTips::toString(duration) + "s"; sourcesDescription += MWGui::ToolTips::toString(duration) + "s";
} }
} }
@ -158,15 +166,15 @@ namespace MWGui
if (remainingDuration > 0.f) if (remainingDuration > 0.f)
{ {
MyGUI::ImageBox* image; MyGUI::ImageBox* image;
if (mWidgetMap.find(it->first) == mWidgetMap.end()) if (mWidgetMap.find(effectId) == mWidgetMap.end())
{ {
image = parent->createWidget<MyGUI::ImageBox> image = parent->createWidget<MyGUI::ImageBox>
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default); ("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
mWidgetMap[it->first] = image; mWidgetMap[effectId] = image;
image->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon)); image->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon));
std::string name = ESM::MagicEffect::effectIdToString (it->first); std::string name = ESM::MagicEffect::effectIdToString (effectId);
ToolTipInfo tooltipInfo; ToolTipInfo tooltipInfo;
tooltipInfo.caption = "#{" + name + "}"; tooltipInfo.caption = "#{" + name + "}";
@ -178,7 +186,7 @@ namespace MWGui
image->setUserString("ToolTipType", "ToolTipInfo"); image->setUserString("ToolTipType", "ToolTipInfo");
} }
else else
image = mWidgetMap[it->first]; image = mWidgetMap[effectId];
image->setPosition(w,2); image->setPosition(w,2);
image->setVisible(true); image->setVisible(true);
@ -191,9 +199,9 @@ namespace MWGui
if (totalDuration >= fadeTime && fadeTime > 0.f) if (totalDuration >= fadeTime && fadeTime > 0.f)
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f)); image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
} }
else if (mWidgetMap.find(it->first) != mWidgetMap.end()) else if (mWidgetMap.find(effectId) != mWidgetMap.end())
{ {
mWidgetMap[it->first]->setVisible(false); mWidgetMap[effectId]->setVisible(false);
} }
} }
@ -208,10 +216,10 @@ namespace MWGui
} }
// hide inactive effects // hide inactive effects
for (std::map<int, MyGUI::ImageBox*>::iterator it = mWidgetMap.begin(); it != mWidgetMap.end(); ++it) for (auto& widgetPair : mWidgetMap)
{ {
if (effects.find(it->first) == effects.end()) if (effects.find(widgetPair.first) == effects.end())
it->second->setVisible(false); widgetPair.second->setVisible(false);
} }
} }

@ -149,13 +149,13 @@ namespace MWGui
mModel->update(); mModel->update();
bool fullUpdateRequired = false; bool fullUpdateRequired = false;
SpellModel::ModelIndex maxSpellIndexFound = -1; SpellModel::ModelIndex maxSpellIndexFound = -1;
for (std::vector< LineInfo >::iterator it = mLines.begin(); it != mLines.end(); ++it) for (LineInfo& line : mLines)
{ {
// only update the lines that are "updateable" // only update the lines that are "updateable"
SpellModel::ModelIndex spellIndex(it->mSpellIndex); SpellModel::ModelIndex spellIndex(line.mSpellIndex);
if (spellIndex != NoSpellIndex) if (spellIndex != NoSpellIndex)
{ {
Gui::SharedStateButton* nameButton = reinterpret_cast<Gui::SharedStateButton*>(it->mLeftWidget); Gui::SharedStateButton* nameButton = reinterpret_cast<Gui::SharedStateButton*>(line.mLeftWidget);
// match model against line // match model against line
// if don't match, then major change has happened, so do a full update // if don't match, then major change has happened, so do a full update
@ -176,7 +176,7 @@ namespace MWGui
else else
{ {
maxSpellIndexFound = spellIndex; maxSpellIndexFound = spellIndex;
Gui::SharedStateButton* costButton = reinterpret_cast<Gui::SharedStateButton*>(it->mRightWidget); Gui::SharedStateButton* costButton = reinterpret_cast<Gui::SharedStateButton*>(line.mRightWidget);
if ((costButton != nullptr) && (costButton->getCaption() != spell.mCostColumn)) if ((costButton != nullptr) && (costButton->getCaption() != spell.mCostColumn))
{ {
costButton->setCaption(spell.mCostColumn); costButton->setCaption(spell.mCostColumn);
@ -198,27 +198,25 @@ namespace MWGui
void SpellView::layoutWidgets() void SpellView::layoutWidgets()
{ {
int height = 0; int height = 0;
for (std::vector< LineInfo >::iterator it = mLines.begin(); for (LineInfo& line : mLines)
it != mLines.end(); ++it)
{ {
height += (it->mLeftWidget)->getHeight(); height += line.mLeftWidget->getHeight();
} }
bool scrollVisible = height > mScrollView->getHeight(); bool scrollVisible = height > mScrollView->getHeight();
int width = mScrollView->getWidth() - (scrollVisible ? 18 : 0); int width = mScrollView->getWidth() - (scrollVisible ? 18 : 0);
height = 0; height = 0;
for (std::vector< LineInfo >::iterator it = mLines.begin(); for (LineInfo& line : mLines)
it != mLines.end(); ++it)
{ {
int lineHeight = (it->mLeftWidget)->getHeight(); int lineHeight = line.mLeftWidget->getHeight();
(it->mLeftWidget)->setCoord(4, height, width - 8, lineHeight); line.mLeftWidget->setCoord(4, height, width - 8, lineHeight);
if (it->mRightWidget) if (line.mRightWidget)
{ {
(it->mRightWidget)->setCoord(4, height, width - 8, lineHeight); line.mRightWidget->setCoord(4, height, width - 8, lineHeight);
MyGUI::TextBox* second = (it->mRightWidget)->castType<MyGUI::TextBox>(false); MyGUI::TextBox* second = line.mRightWidget->castType<MyGUI::TextBox>(false);
if (second) if (second)
(it->mLeftWidget)->setSize(width - 8 - second->getTextSize().width, lineHeight); line.mLeftWidget->setSize(width - 8 - second->getTextSize().width, lineHeight);
} }
height += lineHeight; height += lineHeight;

@ -1,6 +1,7 @@
#ifndef OPENMW_GUI_SPELLVIEW_H #ifndef OPENMW_GUI_SPELLVIEW_H
#define OPENMW_GUI_SPELLVIEW_H #define OPENMW_GUI_SPELLVIEW_H
#include <memory>
#include <tuple> #include <tuple>
#include <MyGUI_Widget.h> #include <MyGUI_Widget.h>

@ -1,10 +1,9 @@
#include "spellwindow.hpp" #include "spellwindow.hpp"
#include <boost/format.hpp>
#include <MyGUI_EditBox.h> #include <MyGUI_EditBox.h>
#include <MyGUI_InputManager.h> #include <MyGUI_InputManager.h>
#include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
/* /*
@ -168,7 +167,7 @@ namespace MWGui
mSpellToDelete = spellId; mSpellToDelete = spellId;
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
std::string question = MWBase::Environment::get().getWindowManager()->getGameSettingString("sQuestionDeleteSpell", "Delete %s?"); std::string question = MWBase::Environment::get().getWindowManager()->getGameSettingString("sQuestionDeleteSpell", "Delete %s?");
question = boost::str(boost::format(question) % spell->mName); Misc::StringUtils::replace(question, "%s", spell->mName.c_str(), 2);
dialog->askForConfirmation(question); dialog->askForConfirmation(question);
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept); dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept);

@ -278,11 +278,9 @@ namespace MWGui
std::set<int> skillSet; std::set<int> skillSet;
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::sSkillIds.end();
mMiscSkills.clear(); mMiscSkills.clear();
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::sSkillIds.begin(); it != end; ++it) for (const int skill : ESM::Skill::sSkillIds)
{ {
int skill = *it;
if (skillSet.find(skill) == skillSet.end()) if (skillSet.find(skill) == skillSet.end())
mMiscSkills.push_back(skill); mMiscSkills.push_back(skill);
} }
@ -435,16 +433,11 @@ namespace MWGui
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
SkillList::const_iterator end = skills.end(); for (const int skillId : skills)
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
{ {
int skillId = *it;
if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes
continue; continue;
const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
const MWMechanics::SkillValue &stat = mSkillValues.find(skillId)->second;
int base = stat.getBase();
int modified = stat.getModified();
const MWWorld::ESMStore &esmStore = const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
@ -456,13 +449,9 @@ namespace MWGui
const ESM::Attribute* attr = const ESM::Attribute* attr =
esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute); esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute);
std::string state = "normal";
if (modified > base)
state = "increased";
else if (modified < base)
state = "decreased";
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets = addValueItem(MWBase::Environment::get().getWindowManager()->getGameSettingString(skillNameId, skillNameId), std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets = addValueItem(MWBase::Environment::get().getWindowManager()->getGameSettingString(skillNameId, skillNameId),
MyGUI::utility::toString(static_cast<int>(modified)), state, coord1, coord2); "", "normal", coord1, coord2);
mSkillWidgetMap[skillId] = widgets;
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
@ -473,27 +462,9 @@ namespace MWGui
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon);
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100");
if (base < 100)
{
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Visible_SkillMaxed", "false");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("UserData^Hidden_SkillMaxed", "true");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Visible_SkillProgressVBox", "true");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("UserData^Hidden_SkillProgressVBox", "false");
setSkillProgress(mSkillWidgets[mSkillWidgets.size()-1-i], stat.getProgress(), skillId);
}
else
{
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Visible_SkillMaxed", "true");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("UserData^Hidden_SkillMaxed", "false");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Visible_SkillProgressVBox", "false");
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("UserData^Hidden_SkillProgressVBox", "true");
}
} }
mSkillWidgetMap[skillId] = widgets; setValue(static_cast<ESM::Skill::SkillEnum>(skillId), mSkillValues.find(skillId)->second);
} }
} }
@ -501,9 +472,9 @@ namespace MWGui
{ {
mChanged = false; mChanged = false;
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) for (MyGUI::Widget* widget : mSkillWidgets)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSkillWidgets.clear(); mSkillWidgets.clear();
@ -552,11 +523,11 @@ namespace MWGui
const std::set<std::string> &expelled = PCstats.getExpelled(); const std::set<std::string> &expelled = PCstats.getExpelled();
bool firstFaction=true; bool firstFaction=true;
FactionList::const_iterator end = mFactions.end(); for (auto& factionPair : mFactions)
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
{ {
const std::string& factionId = factionPair.first;
const ESM::Faction *faction = const ESM::Faction *faction =
store.get<ESM::Faction>().find(it->first); store.get<ESM::Faction>().find(factionId);
if (faction->mData.mIsHidden == 1) if (faction->mData.mIsHidden == 1)
continue; continue;
@ -577,11 +548,11 @@ namespace MWGui
text += std::string("#{fontcolourhtml=header}") + faction->mName; text += std::string("#{fontcolourhtml=header}") + faction->mName;
if (expelled.find(it->first) != expelled.end()) if (expelled.find(factionId) != expelled.end())
text += "\n#{fontcolourhtml=normal}#{sExpelled}"; text += "\n#{fontcolourhtml=normal}#{sExpelled}";
else else
{ {
int rank = it->second; int rank = factionPair.second;
rank = std::max(0, std::min(9, rank)); rank = std::max(0, std::min(9, rank));
text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank]; text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank];

@ -1,8 +1,5 @@
#include "timeadvancer.hpp" #include "timeadvancer.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
namespace MWGui namespace MWGui
{ {
TimeAdvancer::TimeAdvancer(float delay) TimeAdvancer::TimeAdvancer(float delay)

@ -226,18 +226,17 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell")); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell"));
info.caption = spell->mName; info.caption = spell->mName;
Widgets::SpellEffectList effects; Widgets::SpellEffectList effects;
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); for (const ESM::ENAMstruct& spellEffect : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = spellEffect.mEffectID;
params.mSkill = it->mSkill; params.mSkill = spellEffect.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = spellEffect.mAttribute;
params.mDuration = it->mDuration; params.mDuration = spellEffect.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = spellEffect.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = spellEffect.mMagnMax;
params.mRange = it->mRange; params.mRange = spellEffect.mRange;
params.mArea = it->mArea; params.mArea = spellEffect.mArea;
params.mIsConstant = (spell->mData.mType == ESM::Spell::ST_Ability); params.mIsConstant = (spell->mData.mType == ESM::Spell::ST_Ability);
params.mNoTarget = false; params.mNoTarget = false;
effects.push_back(params); effects.push_back(params);
@ -260,14 +259,13 @@ namespace MWGui
tooltip->setVisible(true); tooltip->setVisible(true);
std::map<std::string, std::string> userStrings = focus->getUserStrings(); std::map<std::string, std::string> userStrings = focus->getUserStrings();
for (std::map<std::string, std::string>::iterator it = userStrings.begin(); for (auto& userStringPair : userStrings)
it != userStrings.end(); ++it)
{ {
size_t underscorePos = it->first.find("_"); size_t underscorePos = userStringPair.first.find("_");
if (underscorePos == std::string::npos) if (underscorePos == std::string::npos)
continue; continue;
std::string key = it->first.substr(0, underscorePos); std::string key = userStringPair.first.substr(0, underscorePos);
std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1)); std::string widgetName = userStringPair.first.substr(underscorePos+1, userStringPair.first.size()-(underscorePos+1));
type = "Property"; type = "Property";
size_t caretPos = key.find("^"); size_t caretPos = key.find("^");
@ -280,9 +278,9 @@ namespace MWGui
MyGUI::Widget* w; MyGUI::Widget* w;
getWidget(w, widgetName); getWidget(w, widgetName);
if (type == "Property") if (type == "Property")
w->setProperty(key, it->second); w->setProperty(key, userStringPair.second);
else if (type == "UserData") else if (type == "UserData")
w->setUserString(key, it->second); w->setUserString(key, userStringPair.second);
} }
tooltipSize = tooltip->getSize(); tooltipSize = tooltip->getSize();
@ -458,7 +456,7 @@ namespace MWGui
MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth), MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
for (std::vector<std::string>::const_iterator it = info.notes.begin(); it != info.notes.end(); ++it) for (const std::string& note : info.notes)
{ {
MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton", MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton",
MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default); MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default);
@ -468,7 +466,7 @@ namespace MWGui
MyGUI::Align::Default); MyGUI::Align::Default);
edit->setEditMultiLine(true); edit->setEditMultiLine(true);
edit->setEditWordWrap(true); edit->setEditWordWrap(true);
edit->setCaption(*it); edit->setCaption(note);
edit->setSize(edit->getWidth(), edit->getTextSize().height); edit->setSize(edit->getWidth(), edit->getTextSize().height);
icon->setPosition(icon->getLeft(),(edit->getTop()+edit->getBottom())/2-icon->getHeight()/2); icon->setPosition(icon->getLeft(),(edit->getTop()+edit->getBottom())/2-icon->getHeight()/2);
totalSize.height += std::max(edit->getHeight(), icon->getHeight()); totalSize.height += std::max(edit->getHeight(), icon->getHeight());
@ -653,12 +651,12 @@ namespace MWGui
std::vector<std::pair<std::string, int> > itemOwners = std::vector<std::pair<std::string, int> > itemOwners =
MWBase::Environment::get().getMechanicsManager()->getStolenItemOwners(cellref.getRefId()); MWBase::Environment::get().getMechanicsManager()->getStolenItemOwners(cellref.getRefId());
for (std::vector<std::pair<std::string, int> >::const_iterator it = itemOwners.begin(); it != itemOwners.end(); ++it) for (std::pair<std::string, int>& owner : itemOwners)
{ {
if (it->second == std::numeric_limits<int>::max()) if (owner.second == std::numeric_limits<int>::max())
ret += std::string("\nStolen from ") + it->first; // for legacy (ESS) savegames ret += std::string("\nStolen from ") + owner.first; // for legacy (ESS) savegames
else else
ret += std::string("\nStolen ") + MyGUI::utility::toString(it->second) + " from " + it->first; ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from " + owner.first;
} }
ret += getMiscString(cellref.getGlobalVariable(), "Global"); ret += getMiscString(cellref.getGlobalVariable(), "Global");
@ -732,17 +730,16 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
bool isFirst = true; bool isFirst = true;
MWWorld::Store<ESM::Skill>::iterator it = skills.begin(); for (auto& skillPair : skills)
for (; it != skills.end(); ++it)
{ {
if (it->second.mData.mSpecialization == specId) if (skillPair.second.mData.mSpecialization == specId)
{ {
if (isFirst) if (isFirst)
isFirst = false; isFirst = false;
else else
specText += "\n"; specText += "\n";
specText += std::string("#{") + ESM::Skill::sSkillNameIds[it->first] + "}"; specText += std::string("#{") + ESM::Skill::sSkillNameIds[skillPair.first] + "}";
} }
} }
widget->setUserString("Caption_ColumnText", specText); widget->setUserString("Caption_ColumnText", specText);
@ -767,9 +764,8 @@ namespace MWGui
std::vector<std::string> abilities, powers, spells; std::vector<std::string> abilities, powers, spells;
for (std::vector<std::string>::const_iterator it = sign->mPowers.mList.begin(); it != sign->mPowers.mList.end(); ++it) for (const std::string& spellId : sign->mPowers.mList)
{ {
const std::string &spellId = *it;
const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId);
if (!spell) if (!spell)
continue; // Skip spells which cannot be found continue; // Skip spells which cannot be found
@ -797,15 +793,15 @@ namespace MWGui
for (int category = 0; category < 3; ++category) for (int category = 0; category < 3; ++category)
{ {
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != categories[category].spells.end(); ++it) bool addHeader = true;
for (const std::string& spellId : categories[category].spells)
{ {
if (it == categories[category].spells.begin()) if (addHeader)
{ {
text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}"; text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}";
addHeader = false;
} }
const std::string &spellId = *it;
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId);
text += "\n#{fontcolourhtml=normal}" + spell->mName; text += "\n#{fontcolourhtml=normal}" + spell->mName;
} }

@ -36,13 +36,12 @@ namespace MWGui
void TradeItemModel::borrowImpl(const ItemStack &item, std::vector<ItemStack> &out) void TradeItemModel::borrowImpl(const ItemStack &item, std::vector<ItemStack> &out)
{ {
std::vector<ItemStack>::iterator it = out.begin();
bool found = false; bool found = false;
for (; it != out.end(); ++it) for (ItemStack& itemStack : out)
{ {
if (it->mBase == item.mBase) if (itemStack.mBase == item.mBase)
{ {
it->mCount += item.mCount; itemStack.mCount += item.mCount;
found = true; found = true;
break; break;
} }
@ -100,15 +99,15 @@ namespace MWGui
void TradeItemModel::adjustEncumbrance(float &encumbrance) void TradeItemModel::adjustEncumbrance(float &encumbrance)
{ {
for (std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); it != mBorrowedToUs.end(); ++it) for (ItemStack& itemStack : mBorrowedToUs)
{ {
MWWorld::Ptr item = it->mBase; MWWorld::Ptr& item = itemStack.mBase;
encumbrance += item.getClass().getWeight(item) * it->mCount; encumbrance += item.getClass().getWeight(item) * itemStack.mCount;
} }
for (std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin(); it != mBorrowedFromUs.end(); ++it) for (ItemStack& itemStack : mBorrowedFromUs)
{ {
MWWorld::Ptr item = it->mBase; MWWorld::Ptr& item = itemStack.mBase;
encumbrance -= item.getClass().getWeight(item) * it->mCount; encumbrance -= item.getClass().getWeight(item) * itemStack.mCount;
} }
encumbrance = std::max(0.f, encumbrance); encumbrance = std::max(0.f, encumbrance);
} }
@ -126,15 +125,14 @@ namespace MWGui
void TradeItemModel::transferItems() void TradeItemModel::transferItems()
{ {
std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); for (ItemStack& itemStack : mBorrowedToUs)
for (; it != mBorrowedToUs.end(); ++it)
{ {
// get index in the source model // get index in the source model
ItemModel* sourceModel = it->mCreator; ItemModel* sourceModel = itemStack.mCreator;
size_t i=0; size_t i=0;
for (; i<sourceModel->getItemCount(); ++i) for (; i<sourceModel->getItemCount(); ++i)
{ {
if (it->mBase == sourceModel->getItem(i).mBase) if (itemStack.mBase == sourceModel->getItem(i).mBase)
break; break;
} }
if (i == sourceModel->getItemCount()) if (i == sourceModel->getItemCount())
@ -142,9 +140,9 @@ namespace MWGui
const ItemStack& item = sourceModel->getItem(i); const ItemStack& item = sourceModel->getItem(i);
// copy the borrowed items to our model // copy the borrowed items to our model
copyItem(item, it->mCount); copyItem(item, itemStack.mCount);
// then remove them from the source model // then remove them from the source model
sourceModel->removeItem(item, it->mCount); sourceModel->removeItem(item, itemStack.mCount);
} }
mBorrowedToUs.clear(); mBorrowedToUs.clear();
mBorrowedFromUs.clear(); mBorrowedFromUs.clear();
@ -189,14 +187,13 @@ namespace MWGui
} }
// don't show items that we borrowed to someone else // don't show items that we borrowed to someone else
std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin(); for (ItemStack& itemStack : mBorrowedFromUs)
for (; it != mBorrowedFromUs.end(); ++it)
{ {
if (it->mBase == item.mBase) if (itemStack.mBase == item.mBase)
{ {
if (item.mCount < it->mCount) if (item.mCount < itemStack.mCount)
throw std::runtime_error("Lent more items than present"); throw std::runtime_error("Lent more items than present");
item.mCount -= it->mCount; item.mCount -= itemStack.mCount;
} }
} }
@ -205,12 +202,10 @@ namespace MWGui
} }
// add items borrowed to us // add items borrowed to us
std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); for (ItemStack& itemStack : mBorrowedToUs)
for (; it != mBorrowedToUs.end(); ++it)
{ {
ItemStack item = *it; itemStack.mType = ItemStack::Type_Barter;
item.mType = ItemStack::Type_Barter; mItems.push_back(itemStack);
mItems.push_back(item);
} }
} }

@ -106,9 +106,9 @@ namespace MWGui
// Also restock any containers owned by this merchant, which are also available to buy in the trade window // Also restock any containers owned by this merchant, which are also available to buy in the trade window
std::vector<MWWorld::Ptr> itemSources; std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources); MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources);
for (std::vector<MWWorld::Ptr>::iterator it = itemSources.begin(); it != itemSources.end(); ++it) for (MWWorld::Ptr& source : itemSources)
{ {
it->getClass().restock(*it); source.getClass().restock(source);
} }
} }
@ -306,16 +306,15 @@ namespace MWGui
} }
// check if the player is attempting to sell back an item stolen from this actor // check if the player is attempting to sell back an item stolen from this actor
for (std::vector<ItemStack>::iterator it = merchantBought.begin(); it != merchantBought.end(); ++it) for (ItemStack& itemStack : merchantBought)
{ {
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(it->mBase.getCellRef().getRefId(), mPtr)) if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(itemStack.mBase.getCellRef().getRefId(), mPtr))
{ {
std::string msg = gmst.find("sNotifyMessage49")->mValue.getString(); std::string msg = gmst.find("sNotifyMessage49")->mValue.getString();
if (msg.find("%s") != std::string::npos) Misc::StringUtils::replace(msg, "%s", itemStack.mBase.getClass().getName(itemStack.mBase).c_str(), 2);
msg.replace(msg.find("%s"), 2, it->mBase.getClass().getName(it->mBase));
MWBase::Environment::get().getWindowManager()->messageBox(msg); MWBase::Environment::get().getWindowManager()->messageBox(msg);
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, it->mBase, mPtr, it->mCount); MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, itemStack.mBase, mPtr, itemStack.mCount);
onCancelButtonClicked(mCancelButton); onCancelButtonClicked(mCancelButton);
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
@ -470,15 +469,15 @@ namespace MWGui
int merchantOffer = 0; int merchantOffer = 0;
std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs();
for (std::vector<ItemStack>::const_iterator it = playerBorrowed.begin(); it != playerBorrowed.end(); ++it) for (const ItemStack& itemStack : playerBorrowed)
{ {
merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), true); merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), true);
} }
std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs();
for (std::vector<ItemStack>::const_iterator it = merchantBorrowed.begin(); it != merchantBorrowed.end(); ++it) for (const ItemStack& itemStack : merchantBorrowed)
{ {
merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), false); merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), false);
} }
int diff = merchantOffer - mCurrentMerchantOffer; int diff = merchantOffer - mCurrentMerchantOffer;

@ -1,6 +1,8 @@
#ifndef OPENMW_MWGUI_VIDEOWIDGET_H #ifndef OPENMW_MWGUI_VIDEOWIDGET_H
#define OPENMW_MWGUI_VIDEOWIDGET_H #define OPENMW_MWGUI_VIDEOWIDGET_H
#include <memory>
#include <MyGUI_Widget.h> #include <MyGUI_Widget.h>
namespace Video namespace Video

@ -222,18 +222,17 @@ namespace MWGui
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId); const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
{ {
MWSpellEffectPtr effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default); MWSpellEffectPtr effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
SpellEffectParams params; SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0; params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0;
params.mNoTarget = (flags & MWEffectList::EF_NoTarget); params.mNoTarget = (flags & MWEffectList::EF_NoTarget);
effect->setSpellEffect(params); effect->setSpellEffect(params);
@ -289,13 +288,12 @@ namespace MWGui
MWSpellEffectPtr effect = nullptr; MWSpellEffectPtr effect = nullptr;
int maxwidth = coord.width; int maxwidth = coord.width;
for (SpellEffectList::iterator it=mEffectList.begin(); for (auto& effectInfo : mEffectList)
it != mEffectList.end(); ++it)
{ {
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default); effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
it->mIsConstant = (flags & EF_Constant) || it->mIsConstant; effectInfo.mIsConstant = (flags & EF_Constant) || effectInfo.mIsConstant;
it->mNoTarget = (flags & EF_NoTarget) || it->mNoTarget; effectInfo.mNoTarget = (flags & EF_NoTarget) || effectInfo.mNoTarget;
effect->setSpellEffect(*it); effect->setSpellEffect(effectInfo);
effects.push_back(effect); effects.push_back(effect);
if (effect->getRequestedWidth() > maxwidth) if (effect->getRequestedWidth() > maxwidth)
maxwidth = effect->getRequestedWidth(); maxwidth = effect->getRequestedWidth();
@ -304,9 +302,9 @@ namespace MWGui
} }
// ... then adjust the size for all widgets // ... then adjust the size for all widgets
for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it) for (MyGUI::Widget* effectWidget : effects)
{ {
effect = (*it)->castType<MWSpellEffect>(); effect = effectWidget->castType<MWSpellEffect>();
bool needcenter = center && (maxwidth > effect->getRequestedWidth()); bool needcenter = center && (maxwidth > effect->getRequestedWidth());
int diff = maxwidth - effect->getRequestedWidth(); int diff = maxwidth - effect->getRequestedWidth();
if (needcenter) if (needcenter)
@ -339,18 +337,17 @@ namespace MWGui
SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects) SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
{ {
SpellEffectList result; SpellEffectList result;
std::vector<ESM::ENAMstruct>::const_iterator end = effects->mList.end(); for (const ESM::ENAMstruct& effectInfo : effects->mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = effects->mList.begin(); it != end; ++it)
{ {
SpellEffectParams params; SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mArea = it->mArea; params.mArea = effectInfo.mArea;
result.push_back(params); result.push_back(params);
} }
return result; return result;

@ -3,8 +3,6 @@
#include <MyGUI_InputManager.h> #include <MyGUI_InputManager.h>
#include <MyGUI_RenderManager.h> #include <MyGUI_RenderManager.h>
#include <components/settings/settings.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"

@ -1,13 +1,11 @@
#include "windowmanagerimp.hpp" #include "windowmanagerimp.hpp"
#include <cassert> #include <cassert>
#include <iterator>
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include <MyGUI_UString.h> #include <MyGUI_UString.h>
#include <MyGUI_IPointer.h> #include <MyGUI_IPointer.h>
#include <MyGUI_ResourceImageSetPointer.h>
#include <MyGUI_TextureUtility.h> #include <MyGUI_TextureUtility.h>
#include <MyGUI_FactoryManager.h> #include <MyGUI_FactoryManager.h>
#include <MyGUI_LanguageManager.h> #include <MyGUI_LanguageManager.h>
@ -50,7 +48,6 @@
#include <components/translation/translation.hpp> #include <components/translation/translation.hpp>
#include <components/myguiplatform/myguiplatform.hpp> #include <components/myguiplatform/myguiplatform.hpp>
#include <components/myguiplatform/myguidatamanager.hpp>
#include <components/myguiplatform/myguirendermanager.hpp> #include <components/myguiplatform/myguirendermanager.hpp>
#include <components/myguiplatform/additivelayer.hpp> #include <components/myguiplatform/additivelayer.hpp>
#include <components/myguiplatform/scalinglayer.hpp> #include <components/myguiplatform/scalinglayer.hpp>
@ -59,8 +56,6 @@
#include <components/widgets/tags.hpp> #include <components/widgets/tags.hpp>
#include <components/sdlutil/sdlcursormanager.hpp>
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
@ -696,9 +691,9 @@ namespace MWGui
// Delete any dialogs which are no longer in use // Delete any dialogs which are no longer in use
if (!mGarbageDialogs.empty()) if (!mGarbageDialogs.empty())
{ {
for (std::vector<Layout*>::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it) for (Layout* widget : mGarbageDialogs)
{ {
delete *it; delete widget;
} }
mGarbageDialogs.clear(); mGarbageDialogs.clear();
} }
@ -1287,14 +1282,13 @@ namespace MWGui
{ {
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI")); mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));
for (Settings::CategorySettingVector::const_iterator it = changed.begin(); for (const auto& setting : changed)
it != changed.end(); ++it)
{ {
if (it->first == "HUD" && it->second == "crosshair") if (setting.first == "HUD" && setting.second == "crosshair")
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD"); mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
else if (it->first == "GUI" && it->second == "subtitles") else if (setting.first == "GUI" && setting.second == "subtitles")
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI"); mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
else if (it->first == "GUI" && it->second == "menu transparency") else if (setting.first == "GUI" && setting.second == "menu transparency")
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
} }
} }

@ -16,10 +16,10 @@ namespace MWGui
MyGUI::Button* button = nullptr; MyGUI::Button* button = nullptr;
MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action"); MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action");
for (MyGUI::VectorWidgetPtr::iterator it = widgets.begin(); it != widgets.end(); ++it) for (MyGUI::Widget* widget : widgets)
{ {
if ((*it)->isUserString("HideWindowOnDoubleClick")) if (widget->isUserString("HideWindowOnDoubleClick"))
button = (*it)->castType<MyGUI::Button>(); button = widget->castType<MyGUI::Button>();
} }
if (button) if (button)

@ -74,14 +74,18 @@ namespace MWInput
, mTimeIdle(0.f) , mTimeIdle(0.f)
, mMouseLookEnabled(false) , mMouseLookEnabled(false)
, mGuiCursorEnabled(true) , mGuiCursorEnabled(true)
, mGamepadGuiCursorEnabled(true)
, mDetectingKeyboard(false) , mDetectingKeyboard(false)
, mOverencumberedMessageDelay(0.f) , mOverencumberedMessageDelay(0.f)
, mGuiCursorX(0) , mGuiCursorX(0)
, mGuiCursorY(0) , mGuiCursorY(0)
, mMouseWheel(0) , mMouseWheel(0)
, mGamepadZoom(0)
, mUserFileExists(userFileExists) , mUserFileExists(userFileExists)
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
, mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input")) , mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input"))
, mSneakToggleShortcutTimer(0.f)
, mSneakGamepadShortcut(false)
, mSneaking(false) , mSneaking(false)
, mAttemptJump(false) , mAttemptJump(false)
, mInvUiScalingFactor(1.f) , mInvUiScalingFactor(1.f)
@ -204,6 +208,8 @@ namespace MWInput
void InputManager::handleGuiArrowKey(int action) void InputManager::handleGuiArrowKey(int action)
{ {
// Temporary shut-down of this function until deemed necessary.
return;
if (SDL_IsTextInputActive()) if (SDL_IsTextInputActive())
return; return;
@ -231,6 +237,96 @@ namespace MWInput
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false); MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
} }
bool InputManager::gamepadToGuiControl(const SDL_ControllerButtonEvent &arg, bool release=false)
{
// Presumption of GUI mode will be removed in the future.
// MyGUI KeyCodes *may* change.
// Currently button releases are ignored.
if (release)
return false;
MyGUI::KeyCode key = MyGUI::KeyCode::None;
switch (arg.button)
{
case SDL_CONTROLLER_BUTTON_DPAD_UP:
key = MyGUI::KeyCode::ArrowUp;
break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
key = MyGUI::KeyCode::ArrowRight;
break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
key = MyGUI::KeyCode::ArrowDown;
break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
key = MyGUI::KeyCode::ArrowLeft;
break;
case SDL_CONTROLLER_BUTTON_A:
// If we are using the joystick as a GUI mouse, A must be handled via mouse.
if (mGamepadGuiCursorEnabled)
return false;
key = MyGUI::KeyCode::Space;
break;
case SDL_CONTROLLER_BUTTON_B:
if (MyGUI::InputManager::getInstance().isModalAny())
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
else
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
return true;
case SDL_CONTROLLER_BUTTON_X:
key = MyGUI::KeyCode::Semicolon;
break;
case SDL_CONTROLLER_BUTTON_Y:
key = MyGUI::KeyCode::Apostrophe;
break;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
key = MyGUI::KeyCode::Period;
break;
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
key = MyGUI::KeyCode::Slash;
break;
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
mGamepadGuiCursorEnabled = !mGamepadGuiCursorEnabled;
MWBase::Environment::get().getWindowManager()->setCursorActive(mGamepadGuiCursorEnabled);
return true;
default:
return false;
}
// Some keys will work even when Text Input windows/modals are in focus.
if (SDL_IsTextInputActive())
return false;
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
return true;
}
bool InputManager::gamepadToGuiControl(const SDL_ControllerAxisEvent &arg)
{
switch (arg.axis)
{
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
if (arg.value == 32767) // Treat like a button.
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Minus, 0, false);
break;
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
if (arg.value == 32767) // Treat like a button.
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Equals, 0, false);
break;
case SDL_CONTROLLER_AXIS_LEFTX:
case SDL_CONTROLLER_AXIS_LEFTY:
case SDL_CONTROLLER_AXIS_RIGHTX:
case SDL_CONTROLLER_AXIS_RIGHTY:
// If we are using the joystick as a GUI mouse, process mouse movement elsewhere.
if (mGamepadGuiCursorEnabled)
return false;
break;
default:
return false;
}
return true;
}
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue) void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
{ {
resetIdleTime (); resetIdleTime ();
@ -265,11 +361,29 @@ namespace MWInput
{ {
if (action == A_Use) if (action == A_Use)
{ {
MWMechanics::DrawState_ state = MWBase::Environment::get().getWorld()->getPlayer().getDrawState(); if(mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleWeapon))
mPlayer->setAttackingOrSpell(currentValue != 0 && state != MWMechanics::DrawState_Nothing); action = A_CycleWeaponRight;
else if (mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleSpell))
action = A_CycleSpellRight;
else
{
MWMechanics::DrawState_ state = MWBase::Environment::get().getWorld()->getPlayer().getDrawState();
mPlayer->setAttackingOrSpell(currentValue != 0 && state != MWMechanics::DrawState_Nothing);
}
} }
else if (action == A_Jump) else if (action == A_Jump)
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0); {
if(mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleWeapon))
action = A_CycleWeaponLeft;
else if (mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleSpell))
action = A_CycleSpellLeft;
else
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
}
} }
if (currentValue == 1) if (currentValue == 1)
@ -280,6 +394,9 @@ namespace MWInput
case A_GameMenu: case A_GameMenu:
toggleMainMenu (); toggleMainMenu ();
break; break;
case A_OptionsMenu:
toggleOptionsMenu();
break;
case A_Screenshot: case A_Screenshot:
screenshot(); screenshot();
break; break;
@ -442,7 +559,7 @@ namespace MWInput
updateCursorMode(); updateCursorMode();
if (mGuiCursorEnabled) if (mGuiCursorEnabled && !(mJoystickLastUsed && !mGamepadGuiCursorEnabled))
{ {
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f; float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f;
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f; float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f;
@ -506,28 +623,17 @@ namespace MWInput
// joystick movement // joystick movement
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue(); float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue();
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue(); float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue();
if (xAxis < .5) if (xAxis != .5)
{ {
triedToMove = true; triedToMove = true;
mPlayer->setLeftRight (-1); mPlayer->setLeftRight((xAxis - 0.5f) * 2);
}
else if (xAxis > .5)
{
triedToMove = true;
mPlayer->setLeftRight (1);
} }
if (yAxis < .5) if (yAxis != .5)
{
triedToMove = true;
mPlayer->setAutoMove (false);
mPlayer->setForwardBackward (1);
}
else if (yAxis > .5)
{ {
triedToMove = true; triedToMove = true;
mPlayer->setAutoMove (false); mPlayer->setAutoMove (false);
mPlayer->setForwardBackward (-1); mPlayer->setForwardBackward((yAxis - 0.5f) * 2 * -1);
} }
else if(mPlayer->getAutoMove()) else if(mPlayer->getAutoMove())
{ {
@ -572,7 +678,35 @@ namespace MWInput
if (!mSneakToggles) if (!mSneakToggles)
{ {
mPlayer->setSneak(actionIsActive(A_Sneak)); if(mJoystickLastUsed)
{
if(actionIsActive(A_Sneak))
{
if(mSneakToggleShortcutTimer) // New Sneak Button Press
{
if(mSneakToggleShortcutTimer <= 0.3f)
{
mSneakGamepadShortcut = true;
toggleSneaking();
}
else
mSneakGamepadShortcut = false;
}
if(!mSneaking)
toggleSneaking();
mSneakToggleShortcutTimer = 0.f;
}
else
{
if(!mSneakGamepadShortcut && mSneaking)
toggleSneaking();
if(mSneakToggleShortcutTimer <= 0.3f)
mSneakToggleShortcutTimer += dt;
}
}
else
mPlayer->setSneak(actionIsActive(A_Sneak));
} }
if (mAttemptJump && mControlSwitch["playerjumping"]) if (mAttemptJump && mControlSwitch["playerjumping"])
@ -619,6 +753,13 @@ namespace MWInput
MWBase::Environment::get().getWorld()->togglePOV(); MWBase::Environment::get().getWorld()->togglePOV();
} }
mPreviewPOVDelay = 0.f; mPreviewPOVDelay = 0.f;
mGamepadZoom = 0;
}
if(mGamepadZoom)
{
MWBase::Environment::get().getWorld()->changeVanityModeScale(mGamepadZoom);
MWBase::Environment::get().getWorld()->setCameraDistance(mGamepadZoom, true, true);
} }
} }
} }
@ -635,6 +776,8 @@ namespace MWInput
updateIdleTime(dt); updateIdleTime(dt);
} }
} }
else
mGamepadZoom = 0;
mAttemptJump = false; // Can only jump on first frame input is on mAttemptJump = false; // Can only jump on first frame input is on
} }
@ -649,7 +792,7 @@ namespace MWInput
mMouseLookEnabled = !guiMode; mMouseLookEnabled = !guiMode;
if (guiMode) if (guiMode)
MWBase::Environment::get().getWindowManager()->showCrosshair(false); MWBase::Environment::get().getWindowManager()->showCrosshair(false);
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode); MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (mJoystickLastUsed && !mGamepadGuiCursorEnabled));
// if not in gui mode, the camera decides whether to show crosshair or not. // if not in gui mode, the camera decides whether to show crosshair or not.
} }
@ -830,6 +973,8 @@ namespace MWInput
if (mGuiCursorEnabled) if (mGuiCursorEnabled)
{ {
if (!mGamepadGuiCursorEnabled)
mGamepadGuiCursorEnabled = true;
// We keep track of our own mouse position, so that moving the mouse while in // We keep track of our own mouse position, so that moving the mouse while in
// game mode does not move the position of the GUI cursor // game mode does not move the position of the GUI cursor
mGuiCursorX = static_cast<float>(arg.x) * mInvUiScalingFactor; mGuiCursorX = static_cast<float>(arg.x) * mInvUiScalingFactor;
@ -875,36 +1020,37 @@ namespace MWInput
void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg ) void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg )
{ {
if (!mJoystickEnabled) if (!mJoystickEnabled || mInputBinder->detectingBindingState())
return; return;
mJoystickLastUsed = true; mJoystickLastUsed = true;
bool guiMode = false; if (MWBase::Environment::get().getWindowManager()->isGuiMode())
if (arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B) // We'll pretend that A is left click and B is right click
{ {
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); if (gamepadToGuiControl(arg, false))
if(!mInputBinder->detectingBindingState()) return;
else if (mGamepadGuiCursorEnabled)
{ {
guiMode = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), // Temporary mouse binding until keyboard controls are available:
sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode; if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); bool mousePressSuccess = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(SDL_BUTTON_LEFT));
if (b && b->getEnabled()) if (MyGUI::InputManager::getInstance().getMouseFocusWidget())
{ {
MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); MyGUI::Button* b = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false);
if (b && b->getEnabled())
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
} }
setPlayerControlsEnabled(!mousePressSuccess);
} }
} }
} }
else
setPlayerControlsEnabled(!guiMode); setPlayerControlsEnabled(true);
//esc, to leave initial movie screen //esc, to leave initial movie screen
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0); setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0));
setPlayerControlsEnabled(!guiFocus);
if (!mControlsDisabled) if (!mControlsDisabled)
mInputBinder->buttonPressed(deviceID, arg); mInputBinder->buttonPressed(deviceID, arg);
@ -912,34 +1058,69 @@ namespace MWInput
void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg ) void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg )
{ {
if (!mJoystickEnabled) if(mInputBinder->detectingBindingState())
{
mInputBinder->buttonReleased(deviceID, arg);
return;
}
if (!mJoystickEnabled || mControlsDisabled)
return; return;
mJoystickLastUsed = true; mJoystickLastUsed = true;
if(mInputBinder->detectingBindingState()) if (MWBase::Environment::get().getWindowManager()->isGuiMode())
mInputBinder->buttonReleased(deviceID, arg);
else if(arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B)
{ {
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); if (gamepadToGuiControl(arg, true))
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode; return;
else if (mGamepadGuiCursorEnabled)
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind {
// Temporary mouse binding until keyboard controls are available:
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
{
bool mousePressSuccess = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(SDL_BUTTON_LEFT));
if (mInputBinder->detectingBindingState()) // If the player just triggered binding, don't let button release bind.
return;
setPlayerControlsEnabled(!guiMode); setPlayerControlsEnabled(!mousePressSuccess);
mInputBinder->buttonReleased(deviceID, arg); }
}
} }
else else
mInputBinder->buttonReleased(deviceID, arg); setPlayerControlsEnabled(true);
///to escape initial movie //esc, to leave initial movie screen
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc))); setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
mInputBinder->buttonReleased(deviceID, arg);
} }
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg ) void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
{ {
if (!mControlsDisabled && mJoystickEnabled) if(!mJoystickEnabled || mControlsDisabled)
mInputBinder->axisMoved(deviceID, arg); return;
mJoystickLastUsed = true;
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{
gamepadToGuiControl(arg);
}
else
{
if(mPreviewPOVDelay == 1.f && arg.value) // Preview Mode Gamepad Zooming
{
if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
{
mGamepadZoom = static_cast<float>(arg.value / 10000 * 8.5f);
return; // Do not propogate event.
}
else if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
{
mGamepadZoom = static_cast<float>(-(arg.value / 10000 * 8.5f));
return; // Do not propogate event.
}
}
}
mInputBinder->axisMoved(deviceID, arg);
} }
void InputManager::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg) void InputManager::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg)
@ -975,19 +1156,38 @@ namespace MWInput
void InputManager::toggleMainMenu() void InputManager::toggleMainMenu()
{ {
if (MyGUI::InputManager::getInstance().isModalAny()) { if (MyGUI::InputManager::getInstance().isModalAny())
{
MWBase::Environment::get().getWindowManager()->exitCurrentModal(); MWBase::Environment::get().getWindowManager()->exitCurrentModal();
return; return;
} }
if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame;
{ MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
} if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings)
else //Close current GUI MWBase::Environment::get().getWindowManager()->popGuiMode();
if (inGame && mode != MWGui::GM_MainMenu)
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu);
}
void InputManager::toggleOptionsMenu()
{
if (MyGUI::InputManager::getInstance().isModalAny())
{ {
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); MWBase::Environment::get().getWindowManager()->exitCurrentModal();
return;
} }
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame;
if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings)
MWBase::Environment::get().getWindowManager()->popGuiMode();
if (inGame && mode != MWGui::GM_Settings)
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Settings);
} }
void InputManager::quickLoad() { void InputManager::quickLoad() {
@ -1397,20 +1597,20 @@ namespace MWInput
defaultButtonBindings[A_Activate] = SDL_CONTROLLER_BUTTON_A; defaultButtonBindings[A_Activate] = SDL_CONTROLLER_BUTTON_A;
defaultButtonBindings[A_ToggleWeapon] = SDL_CONTROLLER_BUTTON_X; defaultButtonBindings[A_ToggleWeapon] = SDL_CONTROLLER_BUTTON_X;
defaultButtonBindings[A_ToggleSpell] = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; defaultButtonBindings[A_ToggleSpell] = SDL_CONTROLLER_BUTTON_Y;
//defaultButtonBindings[A_QuickButtonsMenu] = SDL_GetButtonFromScancode(SDL_SCANCODE_F1); // Need to implement, should be ToggleSpell(5) AND Wait(9) //defaultButtonBindings[A_QuickButtonsMenu] = SDL_GetButtonFromScancode(SDL_SCANCODE_F1); // Need to implement, should be ToggleSpell(5) AND Wait(9)
defaultButtonBindings[A_Sneak] = SDL_CONTROLLER_BUTTON_RIGHTSTICK; defaultButtonBindings[A_Sneak] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
defaultButtonBindings[A_Jump] = SDL_CONTROLLER_BUTTON_Y; defaultButtonBindings[A_Journal] = SDL_CONTROLLER_BUTTON_LEFTSHOULDER;
defaultButtonBindings[A_Journal] = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; defaultButtonBindings[A_Rest] = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
defaultButtonBindings[A_Rest] = SDL_CONTROLLER_BUTTON_BACK; defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B; defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B;
defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START; defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START;
defaultButtonBindings[A_OptionsMenu] = SDL_CONTROLLER_BUTTON_BACK;
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE; defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP; defaultButtonBindings[A_MoveForward] = SDL_CONTROLLER_BUTTON_DPAD_UP;
defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT; defaultButtonBindings[A_MoveLeft] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
defaultButtonBindings[A_QuickKey3] = SDL_CONTROLLER_BUTTON_DPAD_DOWN; defaultButtonBindings[A_MoveBackward] = SDL_CONTROLLER_BUTTON_DPAD_DOWN;
defaultButtonBindings[A_QuickKey4] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; defaultButtonBindings[A_MoveRight] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT;
std::map<int, int> defaultAxisBindings; std::map<int, int> defaultAxisBindings;
defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY; defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY;
@ -1418,6 +1618,7 @@ namespace MWInput
defaultAxisBindings[A_LookUpDown] = SDL_CONTROLLER_AXIS_RIGHTY; defaultAxisBindings[A_LookUpDown] = SDL_CONTROLLER_AXIS_RIGHTY;
defaultAxisBindings[A_LookLeftRight] = SDL_CONTROLLER_AXIS_RIGHTX; defaultAxisBindings[A_LookLeftRight] = SDL_CONTROLLER_AXIS_RIGHTX;
defaultAxisBindings[A_Use] = SDL_CONTROLLER_AXIS_TRIGGERRIGHT; defaultAxisBindings[A_Use] = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
defaultAxisBindings[A_Jump] = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
for (int i = 0; i < A_Last; i++) for (int i = 0; i < A_Last; i++)
{ {
@ -1485,6 +1686,7 @@ namespace MWInput
descriptions[A_Journal] = "sJournal"; descriptions[A_Journal] = "sJournal";
descriptions[A_Rest] = "sRestKey"; descriptions[A_Rest] = "sRestKey";
descriptions[A_Inventory] = "sInventory"; descriptions[A_Inventory] = "sInventory";
descriptions[A_OptionsMenu] = "sPreferences";
descriptions[A_TogglePOV] = "sTogglePOVCmd"; descriptions[A_TogglePOV] = "sTogglePOVCmd";
descriptions[A_QuickKeysMenu] = "sQuickMenu"; descriptions[A_QuickKeysMenu] = "sQuickMenu";
descriptions[A_QuickKey1] = "sQuick1Cmd"; descriptions[A_QuickKey1] = "sQuick1Cmd";
@ -1622,6 +1824,7 @@ namespace MWInput
ret.push_back(A_Inventory); ret.push_back(A_Inventory);
ret.push_back(A_Journal); ret.push_back(A_Journal);
ret.push_back(A_Rest); ret.push_back(A_Rest);
ret.push_back(A_OptionsMenu);
ret.push_back(A_Console); ret.push_back(A_Console);
ret.push_back(A_QuickSave); ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad); ret.push_back(A_QuickLoad);
@ -1654,6 +1857,7 @@ namespace MWInput
ret.push_back(A_Inventory); ret.push_back(A_Inventory);
ret.push_back(A_Journal); ret.push_back(A_Journal);
ret.push_back(A_Rest); ret.push_back(A_Rest);
ret.push_back(A_OptionsMenu);
ret.push_back(A_QuickSave); ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad); ret.push_back(A_QuickLoad);
ret.push_back(A_Screenshot); ret.push_back(A_Screenshot);

@ -188,6 +188,7 @@ namespace MWInput
bool mMouseLookEnabled; bool mMouseLookEnabled;
bool mGuiCursorEnabled; bool mGuiCursorEnabled;
bool mGamepadGuiCursorEnabled;
bool mDetectingKeyboard; bool mDetectingKeyboard;
@ -196,9 +197,12 @@ namespace MWInput
float mGuiCursorX; float mGuiCursorX;
float mGuiCursorY; float mGuiCursorY;
int mMouseWheel; int mMouseWheel;
float mGamepadZoom;
bool mUserFileExists; bool mUserFileExists;
bool mAlwaysRunActive; bool mAlwaysRunActive;
bool mSneakToggles; bool mSneakToggles;
float mSneakToggleShortcutTimer;
bool mSneakGamepadShortcut;
bool mSneaking; bool mSneaking;
bool mAttemptJump; bool mAttemptJump;
@ -219,6 +223,9 @@ namespace MWInput
void setPlayerControlsEnabled(bool enabled); void setPlayerControlsEnabled(bool enabled);
void handleGuiArrowKey(int action); void handleGuiArrowKey(int action);
// Return true if GUI consumes input.
bool gamepadToGuiControl(const SDL_ControllerButtonEvent &arg, bool release);
bool gamepadToGuiControl(const SDL_ControllerAxisEvent &arg);
void updateCursorMode(); void updateCursorMode();
@ -226,6 +233,7 @@ namespace MWInput
private: private:
void toggleMainMenu(); void toggleMainMenu();
void toggleOptionsMenu();
void toggleSpell(); void toggleSpell();
void toggleWeapon(); void toggleWeapon();
void toggleInventory(); void toggleInventory();
@ -318,6 +326,8 @@ namespace MWInput
A_MoveForwardBackward, A_MoveForwardBackward,
A_MoveLeftRight, A_MoveLeftRight,
A_OptionsMenu,
A_Last // Marker for the last item A_Last // Marker for the last item
}; };
}; };

@ -20,7 +20,6 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "steering.hpp"
#include "movement.hpp" #include "movement.hpp"
namespace MWMechanics namespace MWMechanics

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

Loading…
Cancel
Save