post merge

actorid
Jason Hooks 13 years ago
commit 083e3537b4

1
.gitignore vendored

@ -13,3 +13,4 @@ cmake_install.cmake
Makefile Makefile
makefile makefile
data data
*.kdev4

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "extern/shiny"]
path = extern/shiny
url = git://github.com/scrawl/shiny.git

@ -37,6 +37,9 @@ option(USE_FFMPEG "use ffmpeg for sound" OFF)
option(USE_AUDIERE "use audiere for sound" OFF) option(USE_AUDIERE "use audiere for sound" OFF)
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON) option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
# OS X deployment
option(OPENMW_OSX_DEPLOYMENT OFF)
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
# Location of morrowind data files # Location of morrowind data files
@ -93,9 +96,8 @@ ENDIF()
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs) set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
set(MANGLE_VFS ${LIBDIR}/mangle/vfs/servers/ogre_vfs.cpp)
set(MANGLE_INPUT ${LIBDIR}/mangle/input/servers/ois_driver.cpp) set(MANGLE_INPUT ${LIBDIR}/mangle/input/servers/ois_driver.cpp)
set(MANGLE_ALL ${MANGLE_VFS} ${MANGLE_INPUT}) set(MANGLE_ALL ${MANGLE_INPUT})
source_group(libs\\mangle FILES ${MANGLE_ALL}) source_group(libs\\mangle FILES ${MANGLE_ALL})
set(OENGINE_OGRE set(OENGINE_OGRE
@ -187,14 +189,24 @@ if (UNIX AND NOT APPLE)
find_package (Threads) find_package (Threads)
endif() endif()
# find boost without components so we can use Boost_VERSION
find_package(Boost REQUIRED)
set(BOOST_COMPONENTS system filesystem program_options thread)
if (Boost_VERSION LESS 104900)
set(SHINY_USE_WAVE_SYSTEM_INSTALL "TRUE")
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} wave)
endif()
find_package(OGRE REQUIRED) find_package(OGRE REQUIRED)
find_package(MyGUI REQUIRED) find_package(MyGUI REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_package(OIS REQUIRED) find_package(OIS REQUIRED)
find_package(OpenAL REQUIRED) find_package(OpenAL REQUIRED)
find_package(Bullet REQUIRED) find_package(Bullet REQUIRED)
IF(OGRE_STATIC) IF(OGRE_STATIC)
find_package(Cg REQUIRED) find_package(Cg)
IF(WIN32) IF(WIN32)
set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS}) set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS})
ELSE(WIN32) ELSE(WIN32)
@ -221,8 +233,48 @@ if (APPLE)
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
${OGRE_Plugin_ParticleFX_LIBRARY_REL}) ${OGRE_Plugin_ParticleFX_LIBRARY_REL})
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
#set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE) endif (APPLE)
# Set up Ogre plugin folder & debug suffix
# Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt)
if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE)
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
else()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
endif()
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}")
if (APPLE AND OPENMW_OSX_DEPLOYMENT)
add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins")
else()
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}")
endif()
add_subdirectory(files/) add_subdirectory(files/)
add_subdirectory(files/mygui) add_subdirectory(files/mygui)
@ -247,53 +299,12 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
"${OpenMW_BINARY_DIR}/openmw.cfg.install") "${OpenMW_BINARY_DIR}/openmw.cfg.install")
if (WIN32)
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
endif (WIN32)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
"${OpenMW_BINARY_DIR}/plugins.cfg")
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop
"${OpenMW_BINARY_DIR}/openmw.desktop") "${OpenMW_BINARY_DIR}/openmw.desktop")
endif() endif()
if (APPLE)
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac
"${OpenMW_BINARY_DIR}/plugins.cfg")
set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR})
set(OGRE_PLUGIN_DIR "")
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac
"${OpenMW_BINARY_DIR}/plugins.cfg.install")
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2})
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE)
# Compiler settings # Compiler settings
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCC)
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder) add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)
@ -330,7 +341,6 @@ if(DPKG_PROGRAM)
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
#Install resources #Install resources
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources") INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources")
@ -347,7 +357,7 @@ if(DPKG_PROGRAM)
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "nvidia-cg-toolkit (>= 2.1), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
@ -368,7 +378,6 @@ if(WIN32)
INSTALL(FILES ${dll_files} DESTINATION ".") INSTALL(FILES ${dll_files} DESTINATION ".")
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
INSTALL(FILES INSTALL(FILES
"${OpenMW_BINARY_DIR}/plugins.cfg"
"${OpenMW_SOURCE_DIR}/readme.txt" "${OpenMW_SOURCE_DIR}/readme.txt"
"${OpenMW_SOURCE_DIR}/GPL3.txt" "${OpenMW_SOURCE_DIR}/GPL3.txt"
"${OpenMW_SOURCE_DIR}/OFL.txt" "${OpenMW_SOURCE_DIR}/OFL.txt"
@ -432,6 +441,9 @@ if(WIN32)
include(CPack) include(CPack)
endif(WIN32) endif(WIN32)
# Extern
add_subdirectory (extern/shiny)
# Components # Components
add_subdirectory (components) add_subdirectory (components)
@ -537,7 +549,6 @@ if (APPLE)
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg.install" RENAME "plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)

@ -187,7 +187,7 @@ int main(int argc, char**argv)
case REC_ALCH: case REC_ALCH:
{ {
Potion p; Potion p;
p.load(esm); p.load(esm, id);
if(quiet) break; if(quiet) break;
cout << " Name: " << p.name << endl; cout << " Name: " << p.name << endl;
break; break;

@ -1,8 +1,12 @@
#include <QtGui> #include <QtGui>
#include <cstdlib>
#include <boost/math/common_factor.hpp> #include <boost/math/common_factor.hpp>
#include <boost/filesystem.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/files/ogreplugin.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "graphicspage.hpp" #include "graphicspage.hpp"
@ -70,20 +74,13 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent)
bool GraphicsPage::setupOgre() bool GraphicsPage::setupOgre()
{ {
QString pluginCfg = mCfgMgr.getPluginsConfigPath().string().c_str();
QFile file(pluginCfg);
// Create a log manager so we can surpress debug text to stdout/stderr // Create a log manager so we can surpress debug text to stdout/stderr
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager; Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
logMgr->createLog((mCfgMgr.getLogPath().string() + "/launcherOgre.log"), true, false, false); logMgr->createLog((mCfgMgr.getLogPath().string() + "/launcherOgre.log"), true, false, false);
try try
{ {
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9)
mOgre = new Ogre::Root("", "", "./launcherOgre.log"); mOgre = new Ogre::Root("", "", "./launcherOgre.log");
#else
mOgre = new Ogre::Root(pluginCfg.toStdString(), "", "./launcherOgre.log");
#endif
} }
catch(Ogre::Exception &ex) catch(Ogre::Exception &ex)
{ {
@ -93,7 +90,6 @@ bool GraphicsPage::setupOgre()
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>Failed to create the Ogre::Root object</b><br><br> \ msgBox.setText(tr("<br><b>Failed to create the Ogre::Root object</b><br><br> \
Make sure the plugins.cfg is present and valid.<br><br> \
Press \"Show Details...\" for more information.<br>")); Press \"Show Details...\" for more information.<br>"));
msgBox.setDetailedText(ogreError); msgBox.setDetailedText(ogreError);
msgBox.exec(); msgBox.exec();
@ -102,6 +98,31 @@ bool GraphicsPage::setupOgre()
return false; return false;
} }
std::string pluginDir;
const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
if (pluginEnv)
pluginDir = pluginEnv;
else
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
pluginDir = ".\\";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
pluginDir = OGRE_PLUGIN_DIR;
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
pluginDir = OGRE_PLUGIN_DIR_REL;
#endif
}
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
pluginDir = absPluginPath.string();
Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
#ifdef ENABLE_PLUGIN_GL #ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin(); mGLPlugin = new Ogre::GLPlugin();
mOgre->installPlugin(mGLPlugin); mOgre->installPlugin(mGLPlugin);

@ -15,7 +15,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender add_openmw_dir (mwrender
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
renderinginterface localmap occlusionquery terrain terrainmaterial water shadows shaderhelper renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
compositors compositors
) )
@ -39,7 +39,7 @@ add_openmw_dir (mwscript
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions locals scriptmanager compilercontext interpretercontext cellextensions miscextensions
guiextensions soundextensions skyextensions statsextensions containerextensions guiextensions soundextensions skyextensions statsextensions containerextensions
aiextensions controlextensions extensions globalscripts ref dialogueextensions aiextensions controlextensions extensions globalscripts ref dialogueextensions
animationextensions animationextensions transformationextensions consoleextensions userextensions
) )
add_openmw_dir (mwsound add_openmw_dir (mwsound
@ -50,7 +50,7 @@ add_openmw_dir (mwworld
refdata worldimp physicssystem scene globals class action nullaction actionteleport refdata worldimp physicssystem scene globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellfunctors containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore ptr actionopen actionread cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionalchemy cellstore actionequip timestamp actionalchemy cellstore actionapply
) )
add_openmw_dir (mwclass add_openmw_dir (mwclass
@ -60,7 +60,7 @@ add_openmw_dir (mwclass
add_openmw_dir (mwmechanics add_openmw_dir (mwmechanics
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells
activespells activespells npcstats
) )
add_openmw_dir (mwbase add_openmw_dir (mwbase
@ -79,7 +79,6 @@ ENDIF(WIN32)
ENDIF(OGRE_STATIC) ENDIF(OGRE_STATIC)
add_executable(openmw add_executable(openmw
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
${COMPONENT_FILES}
${OPENMW_FILES} ${OPENMW_FILES}
${GAME} ${GAME_HEADER} ${GAME} ${GAME_HEADER}
${APPLE_BUNDLE_RESOURCES} ${APPLE_BUNDLE_RESOURCES}
@ -101,6 +100,8 @@ target_link_libraries(openmw
${BULLET_LIBRARIES} ${BULLET_LIBRARIES}
${MYGUI_LIBRARIES} ${MYGUI_LIBRARIES}
${MYGUI_PLATFORM_LIBRARIES} ${MYGUI_PLATFORM_LIBRARIES}
"shiny"
"shiny.OgrePlatform"
components components
) )

@ -1,25 +1,13 @@
#include "engine.hpp" #include "engine.hpp"
#include "components/esm/loadcell.hpp" #include "components/esm/loadcell.hpp"
#include <cassert>
#include <iostream>
#include <utility>
#include <OgreRoot.h> #include <OgreRoot.h>
#include <OgreRenderWindow.h> #include <OgreRenderWindow.h>
#include <MyGUI_WidgetManager.h> #include <MyGUI_WidgetManager.h>
#include <openengine/ogre/renderer.hpp>
#include <openengine/gui/manager.hpp>
#include <components/esm/records.hpp>
#include <components/bsa/bsa_archive.hpp> #include <components/bsa/bsa_archive.hpp>
#include <components/esm/esm_reader.hpp>
#include <components/files/fixedpath.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/settings/settings.hpp>
#include <components/nifoverrides/nifoverrides.hpp> #include <components/nifoverrides/nifoverrides.hpp>
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bullet_nif_loader.hpp>
@ -31,16 +19,12 @@
#include "mwgui/cursorreplace.hpp" #include "mwgui/cursorreplace.hpp"
#include "mwscript/scriptmanager.hpp" #include "mwscript/scriptmanager.hpp"
#include "mwscript/compilercontext.hpp"
#include "mwscript/interpretercontext.hpp"
#include "mwscript/extensions.hpp" #include "mwscript/extensions.hpp"
#include "mwscript/globalscripts.hpp"
#include "mwsound/soundmanager.hpp" #include "mwsound/soundmanager.hpp"
#include "mwworld/class.hpp" #include "mwworld/class.hpp"
#include "mwworld/player.hpp" #include "mwworld/player.hpp"
#include "mwworld/cellstore.hpp"
#include "mwworld/worldimp.hpp" #include "mwworld/worldimp.hpp"
#include "mwclass/classes.hpp" #include "mwclass/classes.hpp"
@ -50,9 +34,6 @@
#include "mwmechanics/mechanicsmanager.hpp" #include "mwmechanics/mechanicsmanager.hpp"
#include "mwbase/environment.hpp"
#include "mwbase/world.hpp"
void OMW::Engine::executeLocalScripts() void OMW::Engine::executeLocalScripts()
{ {
@ -75,11 +56,8 @@ void OMW::Engine::executeLocalScripts()
localScripts.setIgnore (MWWorld::Ptr()); localScripts.setIgnore (MWWorld::Ptr());
} }
void OMW::Engine::setAnimationVerbose(bool animverbose){ void OMW::Engine::setAnimationVerbose(bool animverbose)
if(animverbose){ {
NifOgre::NIFLoader::getSingletonPtr()->setOutputAnimFiles(true);
NifOgre::NIFLoader::getSingletonPtr()->setVerbosePath(mCfgMgr.getLogPath().string());
}
} }
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
@ -151,6 +129,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mCompileAll (false) , mCompileAll (false)
, mScriptContext (0) , mScriptContext (0)
, mFSStrict (false) , mFSStrict (false)
, mScriptConsoleMode (false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
{ {
std::srand ( std::time(NULL) ); std::srand ( std::time(NULL) );
@ -311,7 +290,6 @@ void OMW::Engine::go()
} }
mOgre->configure( mOgre->configure(
mCfgMgr.getLogPath().string(), mCfgMgr.getLogPath().string(),
mCfgMgr.getPluginsConfigPath().string(),
renderSystem, renderSystem,
false); false);
@ -349,7 +327,8 @@ void OMW::Engine::go()
MWScript::registerExtensions (mExtensions); MWScript::registerExtensions (mExtensions);
mEnvironment.setWindowManager (new MWGui::WindowManager( mEnvironment.setWindowManager (new MWGui::WindowManager(
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"))); mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
mScriptConsoleMode));
// Create sound system // Create sound system
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
@ -411,6 +390,9 @@ void OMW::Engine::go()
<< std::endl; << std::endl;
} }
if (!mStartupScript.empty())
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
// Start the main rendering loop // Start the main rendering loop
mOgre->start(); mOgre->start();
@ -513,3 +495,13 @@ void OMW::Engine::setFallbackValues(std::map<std::string,std::string> fallbackMa
{ {
mFallbackMap = fallbackMap; mFallbackMap = fallbackMap;
} }
void OMW::Engine::setScriptConsoleMode (bool enabled)
{
mScriptConsoleMode = enabled;
}
void OMW::Engine::setStartupScript (const std::string& path)
{
mStartupScript = path;
}

@ -1,10 +1,6 @@
#ifndef ENGINE_H #ifndef ENGINE_H
#define ENGINE_H #define ENGINE_H
#include <string>
#include <boost/filesystem.hpp>
#include <OgreFrameListener.h> #include <OgreFrameListener.h>
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
@ -77,6 +73,8 @@ namespace OMW
bool mCompileAll; bool mCompileAll;
std::string mFocusName; std::string mFocusName;
std::map<std::string,std::string> mFallbackMap; std::map<std::string,std::string> mFallbackMap;
bool mScriptConsoleMode;
std::string mStartupScript;
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
@ -162,6 +160,12 @@ namespace OMW
void setFallbackValues(std::map<std::string,std::string> map); void setFallbackValues(std::map<std::string,std::string> map);
/// Enable console-only script functionality
void setScriptConsoleMode (bool enabled);
/// Set path for a script that is run on startup in the console.
void setStartupScript (const std::string& path);
private: private:
Files::ConfigurationManager& mCfgMgr; Files::ConfigurationManager& mCfgMgr;
}; };

@ -1,13 +1,5 @@
#include <iostream> #include <iostream>
#include <string>
#include <fstream>
#include <boost/program_options.hpp>
#include <components/files/fileops.hpp>
#include <components/files/fixedpath.hpp>
#include <components/files/collections.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include "engine.hpp" #include "engine.hpp"
@ -16,15 +8,10 @@
#include <boost/iostreams/concepts.hpp> #include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream_buffer.hpp> #include <boost/iostreams/stream_buffer.hpp>
# if !defined(_DEBUG)
# include <iostream>
# include <fstream>
# endif
// For OutputDebugString // For OutputDebugString
#include <Windows.h> #include <Windows.h>
// makes __argc and __argv available on windows // makes __argc and __argv available on windows
#include <stdlib.h> #include <cstdlib>
#endif #endif
@ -52,8 +39,6 @@ inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string
} /* namespace boost */ } /* namespace boost */
#endif /* (BOOST_VERSION <= 104600) */ #endif /* (BOOST_VERSION <= 104600) */
using namespace std;
struct FallbackMap { struct FallbackMap {
std::map<std::string,std::string> mMap; std::map<std::string,std::string> mMap;
}; };
@ -139,12 +124,20 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("script-verbose", bpo::value<bool>()->implicit_value(true) ("script-verbose", bpo::value<bool>()->implicit_value(true)
->default_value(false), "verbose script output") ->default_value(false), "verbose script output")
("new-game", bpo::value<bool>()->implicit_value(true)
->default_value(false), "activate char gen/new game mechanics")
("script-all", bpo::value<bool>()->implicit_value(true) ("script-all", bpo::value<bool>()->implicit_value(true)
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
("script-console", bpo::value<bool>()->implicit_value(true)
->default_value(false), "enable console-only script functionality")
("script-run", bpo::value<std::string>()->default_value(""),
"select a file that is executed in the console on startup\n\n"
"Note: The file contains a list of script lines, but not a complete scripts. "
"That means no begin/end and no variable declarations.")
("new-game", bpo::value<bool>()->implicit_value(true)
->default_value(false), "activate char gen/new game mechanics")
("fs-strict", bpo::value<bool>()->implicit_value(true) ("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)") ->default_value(false), "strict file system handling (no case folding)")
@ -264,6 +257,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setCompileAll(variables["script-all"].as<bool>()); engine.setCompileAll(variables["script-all"].as<bool>());
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>()); engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap); engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
engine.setStartupScript (variables["script-run"].as<std::string>());
return true; return true;
} }

@ -1,8 +1,6 @@
#ifndef GAME_MWBASE_WORLD_H #ifndef GAME_MWBASE_WORLD_H
#define GAME_MWBASE_WORLD_H #define GAME_MWBASE_WORLD_H
#include <string>
#include <map>
#include <vector> #include <vector>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -56,6 +54,14 @@ namespace MWBase
World& operator= (const World&); World& operator= (const World&);
///< not implemented ///< not implemented
protected:
virtual void
placeObject(
const MWWorld::Ptr &ptr,
MWWorld::CellStore &cell,
const ESM::Position &pos) = 0;
public: public:
enum RenderMode enum RenderMode
@ -178,6 +184,10 @@ namespace MWBase
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0; virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z) = 0;
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const = 0; const = 0;
///< Convert cell numbers to position. ///< Convert cell numbers to position.
@ -239,6 +249,9 @@ namespace MWBase
///< @return true if it is possible to place on object at specified cursor location ///< @return true if it is possible to place on object at specified cursor location
virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0; virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0;
virtual bool isSwimming(const MWWorld::Ptr &object) = 0;
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) = 0;
}; };
} }

@ -19,32 +19,33 @@ namespace MWClass
{ {
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Activator> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Activator>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Activator::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Activator> *ref = MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Activator::getName (const MWWorld::Ptr& ptr) const std::string Activator::getName (const MWWorld::Ptr& ptr) const
@ -93,4 +94,14 @@ namespace MWClass
return info; return info;
} }
MWWorld::Ptr
Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>();
return MWWorld::Ptr(&cell.activators.insert(*ref), &cell);
}
} }

@ -7,6 +7,10 @@ namespace MWClass
{ {
class Activator : public MWWorld::Class class Activator : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -28,6 +32,8 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -22,34 +22,35 @@
namespace MWClass namespace MWClass
{ {
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Apparatus> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Apparatus>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); ptr.get<ESM::Apparatus>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
@ -148,4 +149,13 @@ namespace MWClass
{ {
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy()); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
} }
MWWorld::Ptr
Apparatus::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>();
return MWWorld::Ptr(&cell.appas.insert(*ref), &cell);
}
} }

@ -7,6 +7,10 @@ namespace MWClass
{ {
class Apparatus : public MWWorld::Class class Apparatus : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -48,6 +52,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -27,31 +27,33 @@ namespace MWClass
{ {
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Armor> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Armor>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Armor::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Armor::getName (const MWWorld::Ptr& ptr) const std::string Armor::getName (const MWWorld::Ptr& ptr) const
@ -274,4 +276,13 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Armor::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
return MWWorld::Ptr(&cell.armors.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Armor : public MWWorld::Class class Armor : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -66,6 +69,7 @@ namespace MWClass
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -23,32 +23,33 @@ namespace MWClass
{ {
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Book> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Book>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Book::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Book::getName (const MWWorld::Ptr& ptr) const std::string Book::getName (const MWWorld::Ptr& ptr) const
@ -156,4 +157,12 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
} }
MWWorld::Ptr
Book::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
return MWWorld::Ptr(&cell.books.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Book : public MWWorld::Class class Book : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -50,6 +53,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const; virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -25,32 +25,33 @@ namespace MWClass
{ {
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Clothing> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Clothing>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Clothing::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Clothing::getName (const MWWorld::Ptr& ptr) const std::string Clothing::getName (const MWWorld::Ptr& ptr) const
@ -226,4 +227,13 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Clothing::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Clothing : public MWWorld::Class class Clothing : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -59,6 +62,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -54,32 +54,33 @@ namespace MWClass
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Container> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Container>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Container::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); ptr.get<ESM::Container>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
@ -206,4 +207,13 @@ namespace MWClass
{ {
ptr.getCellRef().lockLevel = 0; ptr.getCellRef().lockLevel = 0;
} }
MWWorld::Ptr
Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
return MWWorld::Ptr(&cell.containers.insert(*ref), &cell);
}
} }

@ -9,6 +9,10 @@ namespace MWClass
{ {
void ensureCustomData (const MWWorld::Ptr& ptr) const; void ensureCustomData (const MWWorld::Ptr& ptr) const;
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -51,6 +55,8 @@ namespace MWClass
///< Unlock object ///< Unlock object
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -47,24 +47,24 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
// creature stats // creature stats
data->mCreatureStats.mAttributes[0].set (ref->base->data.strength); data->mCreatureStats.getAttribute(0).set (ref->base->data.strength);
data->mCreatureStats.mAttributes[1].set (ref->base->data.intelligence); data->mCreatureStats.getAttribute(1).set (ref->base->data.intelligence);
data->mCreatureStats.mAttributes[2].set (ref->base->data.willpower); data->mCreatureStats.getAttribute(2).set (ref->base->data.willpower);
data->mCreatureStats.mAttributes[3].set (ref->base->data.agility); data->mCreatureStats.getAttribute(3).set (ref->base->data.agility);
data->mCreatureStats.mAttributes[4].set (ref->base->data.speed); data->mCreatureStats.getAttribute(4).set (ref->base->data.speed);
data->mCreatureStats.mAttributes[5].set (ref->base->data.endurance); data->mCreatureStats.getAttribute(5).set (ref->base->data.endurance);
data->mCreatureStats.mAttributes[6].set (ref->base->data.personality); data->mCreatureStats.getAttribute(6).set (ref->base->data.personality);
data->mCreatureStats.mAttributes[7].set (ref->base->data.luck); data->mCreatureStats.getAttribute(7).set (ref->base->data.luck);
data->mCreatureStats.mDynamic[0].set (ref->base->data.health); data->mCreatureStats.getHealth().set (ref->base->data.health);
data->mCreatureStats.mDynamic[1].set (ref->base->data.mana); data->mCreatureStats.getMagicka().set (ref->base->data.mana);
data->mCreatureStats.mDynamic[2].set (ref->base->data.fatigue); data->mCreatureStats.getFatigue().set (ref->base->data.fatigue);
data->mCreatureStats.mLevel = ref->base->data.level; data->mCreatureStats.setLevel(ref->base->data.level);
data->mCreatureStats.mHello = ref->base->AI.hello; data->mCreatureStats.setHello(ref->base->AI.hello);
data->mCreatureStats.mFight = ref->base->AI.fight; data->mCreatureStats.setFight(ref->base->AI.fight);
data->mCreatureStats.mFlee = ref->base->AI.flee; data->mCreatureStats.setFlee(ref->base->AI.flee);
data->mCreatureStats.mAlarm = ref->base->AI.alarm; data->mCreatureStats.setAlarm(ref->base->AI.alarm);
// store // store
ptr.getRefData().setCustomData (data.release()); ptr.getRefData().setCustomData (data.release());
@ -86,17 +86,25 @@ namespace MWClass
} }
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()){
physics.insertActorPhysics(ptr, model);
}
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
}
std::string Creature::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
assert (ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertActorPhysics(ptr, "meshes\\" + model);
} }
return "";
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
} }
std::string Creature::getName (const MWWorld::Ptr& ptr) const std::string Creature::getName (const MWWorld::Ptr& ptr) const
@ -169,7 +177,7 @@ namespace MWClass
float Creature::getCapacity (const MWWorld::Ptr& ptr) const float Creature::getCapacity (const MWWorld::Ptr& ptr) const
{ {
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr); const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
return stats.mAttributes[0].getModified()*5; return stats.getAttribute(0).getModified()*5;
} }
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
@ -178,13 +186,22 @@ namespace MWClass
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr); const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
if (weight<0) if (weight<0)
weight = 0; weight = 0;
return weight; return weight;
} }
MWWorld::Ptr
Creature::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>();
return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell);
}
} }

@ -1,7 +1,6 @@
#ifndef GAME_MWCLASS_CREATURE_H #ifndef GAME_MWCLASS_CREATURE_H
#define GAME_MWCLASS_CREATURE_H #define GAME_MWCLASS_CREATURE_H
#include "../mwworld/class.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/actors.hpp" #include "../mwrender/actors.hpp"
@ -12,6 +11,9 @@ namespace MWClass
{ {
void ensureCustomData (const MWWorld::Ptr& ptr) const; void ensureCustomData (const MWWorld::Ptr& ptr) const;
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual std::string getId (const MWWorld::Ptr& ptr) const; virtual std::string getId (const MWWorld::Ptr& ptr) const;
@ -55,6 +57,8 @@ namespace MWClass
/// effects). Throws an exception, if the object can't hold other objects. /// effects). Throws an exception, if the object can't hold other objects.
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -25,30 +25,33 @@ namespace MWClass
{ {
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Door> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Door>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
MWWorld::LiveCellRef<ESM::Door> *ref = const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Door::getModel(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Door::getName (const MWWorld::Ptr& ptr) const std::string Door::getName (const MWWorld::Ptr& ptr) const
@ -94,18 +97,18 @@ namespace MWClass
if (ref->ref.teleport) if (ref->ref.teleport)
{ {
// teleport door // teleport door
/// \todo remove this if clause once ActionTeleport can also support other actors
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
{ {
// the player is using the door // the player is using the door
// The reason this is not 3D is that it would get interrupted when you teleport // The reason this is not 3D is that it would get interrupted when you teleport
MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
} }
else else
{ {
// another NPC or a creature is using the door // another NPC or a creature is using the door
// TODO return action for teleporting other NPC/creature
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
} }
@ -206,4 +209,13 @@ namespace MWClass
return info; return info;
} }
MWWorld::Ptr
Door::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>();
return MWWorld::Ptr(&cell.doors.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Door : public MWWorld::Class class Door : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -38,6 +41,8 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -23,30 +23,33 @@ namespace MWClass
{ {
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Ingredient> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Ingredient>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
@ -153,4 +156,13 @@ namespace MWClass
return info; return info;
} }
MWWorld::Ptr
Ingredient::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>();
return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Ingredient : public MWWorld::Class class Ingredient : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -44,6 +47,8 @@ namespace MWClass
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
///< Return name of inventory icon. ///< Return name of inventory icon.
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -28,8 +28,8 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
@ -50,18 +50,29 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if(!model.empty()){ if(!model.empty()) {
physics.insertObjectPhysics(ptr, "meshes\\" + model); physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
if (!ref->base->sound.empty()) {
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop);
}
}
std::string Light::getModel(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
assert (ref->base != NULL);
if (!ref->base->sound.empty()) const std::string &model = ref->base->model;
{ if (!model.empty()) {
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); return "meshes\\" + model;
} }
return "";
} }
std::string Light::getName (const MWWorld::Ptr& ptr) const std::string Light::getName (const MWWorld::Ptr& ptr) const
@ -185,4 +196,13 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Light::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
return MWWorld::Ptr(&cell.lights.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Light : public MWWorld::Class class Light : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -52,6 +55,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -25,35 +25,35 @@ namespace MWClass
{ {
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Tool> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Tool>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>(); ptr.get<ESM::Tool>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Tool> *ref = MWWorld::LiveCellRef<ESM::Tool> *ref =
@ -165,4 +165,13 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Lockpick::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Tool> *ref =
ptr.get<ESM::Tool>();
return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Lockpick : public MWWorld::Class class Lockpick : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -52,6 +55,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -12,6 +12,7 @@
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwgui/window_manager.hpp" #include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
@ -27,32 +28,33 @@ namespace MWClass
{ {
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Miscellaneous>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const
@ -182,4 +184,39 @@ namespace MWClass
return info; return info;
} }
MWWorld::Ptr
Miscellaneous::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::Ptr newPtr;
const ESMS::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
if (MWWorld::Class::get(ptr).getName(ptr) == store.gameSettings.search("sGold")->str) {
int goldAmount = ptr.getRefData().getCount();
std::string base = "Gold_001";
if (goldAmount >= 100)
base = "Gold_100";
else if (goldAmount >= 25)
base = "Gold_025";
else if (goldAmount >= 10)
base = "Gold_010";
else if (goldAmount >= 5)
base = "Gold_005";
// Really, I have no idea why moving ref out of conditional
// scope causes list::push_back throwing std::bad_alloc
MWWorld::ManualRef newRef(store, base);
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
} else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
}
return newPtr;
}
} }

@ -7,9 +7,12 @@ namespace MWClass
{ {
class Miscellaneous : public MWWorld::Class class Miscellaneous : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
@ -44,6 +47,8 @@ namespace MWClass
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
///< Return name of inventory icon. ///< Return name of inventory icon.
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -67,11 +67,11 @@ namespace MWClass
boost::algorithm::to_lower(faction); boost::algorithm::to_lower(faction);
if(ref->base->npdt52.gold != -10) if(ref->base->npdt52.gold != -10)
{ {
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt52.rank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt52.rank;
} }
else else
{ {
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt12.rank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt12.rank;
} }
} }
@ -79,31 +79,31 @@ namespace MWClass
if(ref->base->npdt52.gold != -10) if(ref->base->npdt52.gold != -10)
{ {
for (int i=0; i<27; ++i) for (int i=0; i<27; ++i)
data->mNpcStats.mSkill[i].setBase (ref->base->npdt52.skills[i]); data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]);
data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength); data->mCreatureStats.getAttribute(0).set (ref->base->npdt52.strength);
data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence); data->mCreatureStats.getAttribute(1).set (ref->base->npdt52.intelligence);
data->mCreatureStats.mAttributes[2].set (ref->base->npdt52.willpower); data->mCreatureStats.getAttribute(2).set (ref->base->npdt52.willpower);
data->mCreatureStats.mAttributes[3].set (ref->base->npdt52.agility); data->mCreatureStats.getAttribute(3).set (ref->base->npdt52.agility);
data->mCreatureStats.mAttributes[4].set (ref->base->npdt52.speed); data->mCreatureStats.getAttribute(4).set (ref->base->npdt52.speed);
data->mCreatureStats.mAttributes[5].set (ref->base->npdt52.endurance); data->mCreatureStats.getAttribute(5).set (ref->base->npdt52.endurance);
data->mCreatureStats.mAttributes[6].set (ref->base->npdt52.personality); data->mCreatureStats.getAttribute(6).set (ref->base->npdt52.personality);
data->mCreatureStats.mAttributes[7].set (ref->base->npdt52.luck); data->mCreatureStats.getAttribute(7).set (ref->base->npdt52.luck);
data->mCreatureStats.mDynamic[0].set (ref->base->npdt52.health); data->mCreatureStats.getHealth().set (ref->base->npdt52.health);
data->mCreatureStats.mDynamic[1].set (ref->base->npdt52.mana); data->mCreatureStats.getMagicka().set (ref->base->npdt52.mana);
data->mCreatureStats.mDynamic[2].set (ref->base->npdt52.fatigue); data->mCreatureStats.getFatigue().set (ref->base->npdt52.fatigue);
data->mCreatureStats.mLevel = ref->base->npdt52.level; data->mCreatureStats.setLevel(ref->base->npdt52.level);
} }
else else
{ {
/// \todo do something with npdt12 maybe:p /// \todo do something with npdt12 maybe:p
} }
data->mCreatureStats.mHello = ref->base->AI.hello; data->mCreatureStats.setHello(ref->base->AI.hello);
data->mCreatureStats.mFight = ref->base->AI.fight; data->mCreatureStats.setFight(ref->base->AI.fight);
data->mCreatureStats.mFlee = ref->base->AI.flee; data->mCreatureStats.setFlee(ref->base->AI.flee);
data->mCreatureStats.mAlarm = ref->base->AI.alarm; data->mCreatureStats.setAlarm(ref->base->AI.alarm);
// store // store
ptr.getRefData().setCustomData (data.release()); ptr.getRefData().setCustomData (data.release());
@ -125,25 +125,31 @@ namespace MWClass
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {
physics.insertObjectPhysics(ptr, getModel(ptr));
MWBase::Environment::get().getMechanicsManager()->addActor(ptr);
}
std::string Npc::getModel(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
assert(ref->base != NULL);
assert (ref->base != NULL);
std::string headID = ref->base->head; std::string headID = ref->base->head;
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
std::string smodel = "meshes\\base_anim.nif"; int end = headID.find_last_of("head_") - 4;
if(beast) std::string bodyRaceID = headID.substr(0, end);
smodel = "meshes\\base_animkna.nif";
physics.insertObjectPhysics(ptr, smodel);
std::string model = "meshes\\base_anim.nif";
if (bodyRaceID == "b_n_khajiit_m_" ||
bodyRaceID == "b_n_khajiit_f_" ||
bodyRaceID == "b_n_argonian_m_" ||
bodyRaceID == "b_n_argonian_f_")
{
model = "meshes\\base_animkna.nif";
}
return model;
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
} }
std::string Npc::getName (const MWWorld::Ptr& ptr) const std::string Npc::getName (const MWWorld::Ptr& ptr) const
@ -206,12 +212,12 @@ namespace MWClass
{ {
case Run: case Run:
stats.mForceRun = force; stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceRun, force);
break; break;
case Sneak: case Sneak:
stats.mForceSneak = force; stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak, force);
break; break;
case Combat: case Combat:
@ -228,17 +234,18 @@ namespace MWClass
{ {
case Run: case Run:
stats.mRun = set; stats.setMovementFlag (MWMechanics::NpcStats::Flag_Run, set);
break; break;
case Sneak: case Sneak:
stats.mSneak = set; stats.setMovementFlag (MWMechanics::NpcStats::Flag_Sneak, set);
break; break;
case Combat: case Combat:
stats.mCombat = set; // Combat stance ignored for now; need to be determined based on draw state instead of
// being maunally set.
break; break;
} }
} }
@ -251,21 +258,21 @@ namespace MWClass
{ {
case Run: case Run:
if (!ignoreForce && stats.mForceRun) if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun))
return true; return true;
return stats.mRun; return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Run);
case Sneak: case Sneak:
if (!ignoreForce && stats.mForceSneak) if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak))
return true; return true;
return stats.mSneak; return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Sneak);
case Combat: case Combat:
return stats.mCombat; return false;
} }
return false; return false;
@ -329,7 +336,7 @@ namespace MWClass
float Npc::getCapacity (const MWWorld::Ptr& ptr) const float Npc::getCapacity (const MWWorld::Ptr& ptr) const
{ {
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr); const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
return stats.mAttributes[0].getModified()*5; return stats.getAttribute(0).getModified()*5;
} }
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
@ -338,13 +345,50 @@ namespace MWClass
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr); const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
if (weight<0) if (weight<0)
weight = 0; weight = 0;
return weight; return weight;
} }
bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id,
const MWWorld::Ptr& actor) const
{
MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
/// \todo consider instant effects
return stats.getActiveSpells().addSpell (id);
}
void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
{
MWMechanics::NpcStats& stats = getNpcStats (ptr);
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
ref->base->cls);
stats.useSkill (skill, *class_, usageType);
}
void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
{
y = 0;
x = 0;
}
MWWorld::Ptr
Npc::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>();
return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell);
}
} }

@ -9,6 +9,9 @@ namespace MWClass
{ {
void ensureCustomData (const MWWorld::Ptr& ptr) const; void ensureCustomData (const MWWorld::Ptr& ptr) const;
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual std::string getId (const MWWorld::Ptr& ptr) const; virtual std::string getId (const MWWorld::Ptr& ptr) const;
@ -48,7 +51,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const; virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const;
///< Force or unforce a stance. ///< Force or unforce a stance.
virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const; virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const;
@ -76,7 +79,20 @@ namespace MWClass
///< Returns total weight of objects inside this object (including modifications from magic ///< Returns total weight of objects inside this object (including modifications from magic
/// effects). Throws an exception, if the object can't hold other objects. /// effects). Throws an exception, if the object can't hold other objects.
virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id,
const MWWorld::Ptr& actor) const;
///< Apply \a id on \a ptr.
/// \param actor Actor that is resposible for the ID being applied to \a ptr.
/// \return Any effect?
virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const;
///< Inform actor \a ptr that a skill use has succeeded.
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -8,8 +8,10 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/actionapply.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwworld/player.hpp"
#include "../mwgui/window_manager.hpp" #include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
@ -23,32 +25,33 @@ namespace MWClass
{ {
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Potion> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Potion>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Potion::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Potion::getName (const MWWorld::Ptr& ptr) const std::string Potion::getName (const MWWorld::Ptr& ptr) const
@ -144,4 +147,30 @@ namespace MWClass
return info; return info;
} }
boost::shared_ptr<MWWorld::Action> Potion::use (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
ptr.getRefData().setCount (ptr.getRefData().getCount()-1);
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
boost::shared_ptr<MWWorld::Action> action (
new MWWorld::ActionApply (actor, ref->base->mId));
action->setSound ("Drink");
return action;
}
MWWorld::Ptr
Potion::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
return MWWorld::Ptr(&cell.potions.insert(*ref), &cell);
}
} }

@ -7,9 +7,12 @@ namespace MWClass
{ {
class Potion : public MWWorld::Class class Potion : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
@ -34,6 +37,9 @@ namespace MWClass
virtual int getValue (const MWWorld::Ptr& ptr) const; virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded. ///< Return trade value of the object. Throws an exception, if the object can't be traded.
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
///< Generate action for using via inventory menu
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
@ -44,6 +50,8 @@ namespace MWClass
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
///< Return name of inventory icon. ///< Return name of inventory icon.
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -25,35 +25,35 @@ namespace MWClass
{ {
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Probe> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Probe>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Probe::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Probe::getName (const MWWorld::Ptr& ptr) const std::string Probe::getName (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
@ -164,4 +164,14 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Probe::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>();
return MWWorld::Ptr(&cell.probes.insert(*ref), &cell);
}
} }

@ -7,9 +7,12 @@ namespace MWClass
{ {
class Probe : public MWWorld::Class class Probe : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
@ -52,6 +55,8 @@ namespace MWClass
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -23,32 +23,33 @@ namespace MWClass
{ {
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Repair> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Repair>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Repair::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Repair::getName (const MWWorld::Ptr& ptr) const std::string Repair::getName (const MWWorld::Ptr& ptr) const
@ -145,4 +146,13 @@ namespace MWClass
return info; return info;
} }
MWWorld::Ptr
Repair::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>();
return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell);
}
} }

@ -7,9 +7,12 @@ namespace MWClass
{ {
class Repair : public MWWorld::Class class Repair : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
@ -44,6 +47,8 @@ namespace MWClass
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
///< Return name of inventory icon. ///< Return name of inventory icon.
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -13,31 +13,33 @@ namespace MWClass
{ {
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Static> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Static>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Static::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Static> *ref = MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>(); ptr.get<ESM::Static>();
assert(ref->base != NULL);
assert (ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Static::getName (const MWWorld::Ptr& ptr) const std::string Static::getName (const MWWorld::Ptr& ptr) const
@ -51,4 +53,13 @@ namespace MWClass
registerClass (typeid (ESM::Static).name(), instance); registerClass (typeid (ESM::Static).name(), instance);
} }
MWWorld::Ptr
Static::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>();
return MWWorld::Ptr(&cell.statics.insert(*ref), &cell);
}
} }

@ -7,9 +7,12 @@ namespace MWClass
{ {
class Static : public MWWorld::Class class Static : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
@ -19,6 +22,8 @@ namespace MWClass
/// can return an empty string. /// can return an empty string.
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -25,32 +25,33 @@ namespace MWClass
{ {
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
MWWorld::LiveCellRef<ESM::Weapon> *ref = const std::string model = getModel(ptr);
ptr.get<ESM::Weapon>(); if (!model.empty()) {
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, model);
} }
} }
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
physics.insertObjectPhysics(ptr, model);
}
}
std::string Weapon::getModel(const MWWorld::Ptr &ptr) const
{ {
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
assert(ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
assert (ref->base != NULL); if (!model.empty()) {
if(!model.empty()){ return "meshes\\" + model;
physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
return "";
} }
std::string Weapon::getName (const MWWorld::Ptr& ptr) const std::string Weapon::getName (const MWWorld::Ptr& ptr) const
@ -364,4 +365,13 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
} }
MWWorld::Ptr
Weapon::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell);
}
} }

@ -7,6 +7,9 @@ namespace MWClass
{ {
class Weapon : public MWWorld::Class class Weapon : public MWWorld::Class
{ {
virtual MWWorld::Ptr
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
public: public:
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
@ -66,6 +69,7 @@ namespace MWClass
const; const;
///< Generate action for using via inventory menu ///< Generate action for using via inventory menu
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
}; };
} }

@ -203,10 +203,10 @@ namespace MWDialogue
MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor);
int sameFaction = 0; int sameFaction = 0;
if(!NPCstats.mFactionRank.empty()) if(!NPCstats.getFactionRanks().empty())
{ {
std::string NPCFaction = NPCstats.mFactionRank.begin()->first; std::string NPCFaction = NPCstats.getFactionRanks().begin()->first;
if(PCstats.mFactionRank.find(toLower(NPCFaction)) != PCstats.mFactionRank.end()) sameFaction = 1; if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1;
} }
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false; if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
} }
@ -525,8 +525,8 @@ namespace MWDialogue
//MWWorld::Class npcClass = MWWorld::Class::get(actor); //MWWorld::Class npcClass = MWWorld::Class::get(actor);
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.npcFaction)); std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.npcFaction));
if(it!=stats.mFactionRank.end()) if(it!=stats.getFactionRanks().end())
{ {
//check rank //check rank
if(it->second < (int)info.data.rank) return false; if(it->second < (int)info.data.rank) return false;
@ -542,8 +542,8 @@ namespace MWDialogue
if(!info.pcFaction.empty()) if(!info.pcFaction.empty())
{ {
MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.pcFaction)); std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.pcFaction));
if(it!=stats.mFactionRank.end()) if(it!=stats.getFactionRanks().end())
{ {
//check rank //check rank
if(it->second < (int)info.data.PCrank) return false; if(it->second < (int)info.data.PCrank) return false;
@ -591,7 +591,7 @@ namespace MWDialogue
mIsInChoice = false; mIsInChoice = false;
mCompilerContext.setExtensions (&extensions); mCompilerContext.setExtensions (&extensions);
mDialogueMap.clear(); mDialogueMap.clear();
actorKnownTopics.clear(); mActorKnownTopics.clear();
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{ {
@ -601,24 +601,24 @@ namespace MWDialogue
void DialogueManager::addTopic(std::string topic) void DialogueManager::addTopic(std::string topic)
{ {
knownTopics[toLower(topic)] = true; mKnownTopics[toLower(topic)] = true;
} }
void DialogueManager::parseText(std::string text) void DialogueManager::parseText(std::string text)
{ {
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();++it) for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++it)
{ {
size_t pos = find_str_ci(text,*it,0); size_t pos = find_str_ci(text,*it,0);
if(pos !=std::string::npos) if(pos !=std::string::npos)
{ {
if(pos==0) if(pos==0)
{ {
knownTopics[*it] = true; mKnownTopics[*it] = true;
} }
else if(text.substr(pos -1,1) == " ") else if(text.substr(pos -1,1) == " ")
{ {
knownTopics[*it] = true; mKnownTopics[*it] = true;
} }
} }
} }
@ -632,7 +632,7 @@ namespace MWDialogue
mActor = actor; mActor = actor;
actorKnownTopics.clear(); mActorKnownTopics.clear();
//initialise the GUI //initialise the GUI
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue);
@ -742,7 +742,7 @@ namespace MWDialogue
std::list<std::string> keywordList; std::list<std::string> keywordList;
int choice = mChoice; int choice = mChoice;
mChoice = -1; mChoice = -1;
actorKnownTopics.clear(); mActorKnownTopics.clear();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
@ -755,9 +755,9 @@ namespace MWDialogue
{ {
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{ {
actorKnownTopics.push_back(toLower(it->first)); mActorKnownTopics.push_back(toLower(it->first));
//does the player know the topic? //does the player know the topic?
if(knownTopics.find(toLower(it->first)) != knownTopics.end()) if(mKnownTopics.find(toLower(it->first)) != mKnownTopics.end())
{ {
keywordList.push_back(it->first); keywordList.push_back(it->first);
break; break;
@ -903,13 +903,13 @@ namespace MWDialogue
std::string factionID(""); std::string factionID("");
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor); MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
if(stats.mFactionRank.empty()) if(stats.getFactionRanks().empty())
{ {
std::cout << "No faction for this actor!"; std::cout << "No faction for this actor!";
} }
else else
{ {
factionID = stats.mFactionRank.begin()->first; factionID = stats.getFactionRanks().begin()->first;
} }
return factionID; return factionID;
} }

@ -26,8 +26,8 @@ namespace MWDialogue
void updateTopics(); void updateTopics();
std::map<std::string,ESM::Dialogue> mDialogueMap; std::map<std::string,ESM::Dialogue> mDialogueMap;
std::map<std::string,bool> knownTopics;// Those are the topics the player knows. std::map<std::string,bool> mKnownTopics;// Those are the topics the player knows.
std::list<std::string> actorKnownTopics; std::list<std::string> mActorKnownTopics;
MWScript::CompilerContext mCompilerContext; MWScript::CompilerContext mCompilerContext;
std::ostream mErrorStream; std::ostream mErrorStream;

@ -15,15 +15,15 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager)
// Centre dialog // Centre dialog
center(); center();
getWidget(spellArea, "SpellArea"); getWidget(mSpellArea, "SpellArea");
getWidget(birthImage, "BirthsignImage"); getWidget(mBirthImage, "BirthsignImage");
getWidget(birthList, "BirthsignList"); getWidget(mBirthList, "BirthsignList");
birthList->setScrollVisible(true); mBirthList->setScrollVisible(true);
birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); mBirthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); mBirthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
@ -68,14 +68,14 @@ void BirthDialog::open()
void BirthDialog::setBirthId(const std::string &birthId) void BirthDialog::setBirthId(const std::string &birthId)
{ {
currentBirthId = birthId; mCurrentBirthId = birthId;
birthList->setIndexSelected(MyGUI::ITEM_NONE); mBirthList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = birthList->getItemCount(); size_t count = mBirthList->getItemCount();
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
{ {
if (boost::iequals(*birthList->getItemDataAt<std::string>(i), birthId)) if (boost::iequals(*mBirthList->getItemDataAt<std::string>(i), birthId))
{ {
birthList->setIndexSelected(i); mBirthList->setIndexSelected(i);
break; break;
} }
} }
@ -100,11 +100,11 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
const std::string *birthId = birthList->getItemDataAt<std::string>(_index); const std::string *birthId = mBirthList->getItemDataAt<std::string>(_index);
if (boost::iequals(currentBirthId, *birthId)) if (boost::iequals(mCurrentBirthId, *birthId))
return; return;
currentBirthId = *birthId; mCurrentBirthId = *birthId;
updateSpells(); updateSpells();
} }
@ -112,7 +112,7 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
void BirthDialog::updateBirths() void BirthDialog::updateBirths()
{ {
birthList->removeAllItems(); mBirthList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
@ -122,34 +122,34 @@ void BirthDialog::updateBirths()
for (; it != end; ++it) for (; it != end; ++it)
{ {
const ESM::BirthSign &birth = it->second; const ESM::BirthSign &birth = it->second;
birthList->addItem(birth.name, it->first); mBirthList->addItem(birth.name, it->first);
if (boost::iequals(it->first, currentBirthId)) if (boost::iequals(it->first, mCurrentBirthId))
birthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
++index; ++index;
} }
} }
void BirthDialog::updateSpells() void BirthDialog::updateSpells()
{ {
for (std::vector<MyGUI::WidgetPtr>::iterator it = spellItems.begin(); it != spellItems.end(); ++it) for (std::vector<MyGUI::WidgetPtr>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
spellItems.clear(); mSpellItems.clear();
if (currentBirthId.empty()) if (mCurrentBirthId.empty())
return; return;
MWSpellPtr spellWidget; MWSpellPtr spellWidget;
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId); const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId);
std::string texturePath = std::string("textures\\") + birth->texture; std::string texturePath = std::string("textures\\") + birth->texture;
fixTexturePath(texturePath); fixTexturePath(texturePath);
birthImage->setImageTexture(texturePath); mBirthImage->setImageTexture(texturePath);
std::vector<std::string> abilities, powers, spells; std::vector<std::string> abilities, powers, spells;
@ -183,25 +183,25 @@ void BirthDialog::updateSpells()
{ {
if (!categories[category].spells.empty()) if (!categories[category].spells.empty())
{ {
MyGUI::TextBox* label = spellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); MyGUI::TextBox* label = mSpellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
label->setCaption(mWindowManager.getGameSettingString(categories[category].label, "")); label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
spellItems.push_back(label); mSpellItems.push_back(label);
coord.top += lineHeight; coord.top += lineHeight;
std::vector<std::string>::const_iterator end = categories[category].spells.end(); std::vector<std::string>::const_iterator end = categories[category].spells.end();
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it) for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it)
{ {
const std::string &spellId = *it; const std::string &spellId = *it;
spellWidget = spellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i)); spellWidget = mSpellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i));
spellWidget->setWindowManager(&mWindowManager); spellWidget->setWindowManager(&mWindowManager);
spellWidget->setSpellId(spellId); spellWidget->setSpellId(spellId);
spellItems.push_back(spellWidget); mSpellItems.push_back(spellWidget);
coord.top += lineHeight; coord.top += lineHeight;
MyGUI::IntCoord spellCoord = coord; MyGUI::IntCoord spellCoord = coord;
spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template? spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template?
spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0); spellWidget->createEffectWidgets(mSpellItems, mSpellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0);
coord.top = spellCoord.top; coord.top = spellCoord.top;
++i; ++i;

@ -25,7 +25,7 @@ namespace MWGui
GM_Female GM_Female
}; };
const std::string &getBirthId() const { return currentBirthId; } const std::string &getBirthId() const { return mCurrentBirthId; }
void setBirthId(const std::string &raceId); void setBirthId(const std::string &raceId);
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
@ -49,12 +49,12 @@ namespace MWGui
void updateBirths(); void updateBirths();
void updateSpells(); void updateSpells();
MyGUI::ListBox* birthList; MyGUI::ListBox* mBirthList;
MyGUI::WidgetPtr spellArea; MyGUI::WidgetPtr mSpellArea;
MyGUI::ImageBox* birthImage; MyGUI::ImageBox* mBirthImage;
std::vector<MyGUI::WidgetPtr> spellItems; std::vector<MyGUI::WidgetPtr> mSpellItems;
std::string currentBirthId; std::string mCurrentBirthId;
}; };
} }
#endif #endif

@ -3,9 +3,11 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp"
#include "formatting.hpp" #include "formatting.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
@ -99,7 +101,7 @@ void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack); MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack);
MWWorld::ActionTake take(mBook); MWWorld::ActionTake take(mBook);
take.execute(); take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
mWindowManager.removeGuiMode(GM_Book); mWindowManager.removeGuiMode(GM_Book);
} }

@ -1,6 +1,5 @@
#include "class.hpp" #include "class.hpp"
#include <assert.h>
#include <iterator> #include <iterator>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -26,8 +25,8 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", "")); setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", ""));
getWidget(classImage, "ClassImage"); getWidget(mClassImage, "ClassImage");
getWidget(className, "ClassName"); getWidget(mClassName, "ClassName");
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
@ -51,15 +50,15 @@ void GenerateClassResultDialog::open()
std::string GenerateClassResultDialog::getClassId() const std::string GenerateClassResultDialog::getClassId() const
{ {
return className->getCaption(); return mClassName->getCaption();
} }
void GenerateClassResultDialog::setClassId(const std::string &classId) void GenerateClassResultDialog::setClassId(const std::string &classId)
{ {
currentClassId = classId; mCurrentClassId = classId;
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
className->setCaption(store.classes.find(currentClassId)->name); mClassName->setCaption(store.classes.find(mCurrentClassId)->name);
} }
// widget controls // widget controls
@ -82,29 +81,29 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
// Centre dialog // Centre dialog
center(); center();
getWidget(specializationName, "SpecializationName"); getWidget(mSpecializationName, "SpecializationName");
getWidget(favoriteAttribute[0], "FavoriteAttribute0"); getWidget(mFavoriteAttribute[0], "FavoriteAttribute0");
getWidget(favoriteAttribute[1], "FavoriteAttribute1"); getWidget(mFavoriteAttribute[1], "FavoriteAttribute1");
favoriteAttribute[0]->setWindowManager(&mWindowManager); mFavoriteAttribute[0]->setWindowManager(&mWindowManager);
favoriteAttribute[1]->setWindowManager(&mWindowManager); mFavoriteAttribute[1]->setWindowManager(&mWindowManager);
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
char theIndex = '0'+i; char theIndex = '0'+i;
getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex));
getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); getWidget(mMinorSkill[i], std::string("MinorSkill").append(1, theIndex));
majorSkill[i]->setWindowManager(&mWindowManager); mMajorSkill[i]->setWindowManager(&mWindowManager);
minorSkill[i]->setWindowManager(&mWindowManager); mMinorSkill[i]->setWindowManager(&mWindowManager);
} }
getWidget(classList, "ClassList"); getWidget(mClassList, "ClassList");
classList->setScrollVisible(true); mClassList->setScrollVisible(true);
classList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); mClassList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
classList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); mClassList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
classList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); mClassList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
getWidget(classImage, "ClassImage"); getWidget(mClassImage, "ClassImage");
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
@ -148,14 +147,14 @@ void PickClassDialog::open()
void PickClassDialog::setClassId(const std::string &classId) void PickClassDialog::setClassId(const std::string &classId)
{ {
currentClassId = classId; mCurrentClassId = classId;
classList->setIndexSelected(MyGUI::ITEM_NONE); mClassList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = classList->getItemCount(); size_t count = mClassList->getItemCount();
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
{ {
if (boost::iequals(*classList->getItemDataAt<std::string>(i), classId)) if (boost::iequals(*mClassList->getItemDataAt<std::string>(i), classId))
{ {
classList->setIndexSelected(i); mClassList->setIndexSelected(i);
break; break;
} }
} }
@ -180,11 +179,11 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
const std::string *classId = classList->getItemDataAt<std::string>(_index); const std::string *classId = mClassList->getItemDataAt<std::string>(_index);
if (boost::iequals(currentClassId, *classId)) if (boost::iequals(mCurrentClassId, *classId))
return; return;
currentClassId = *classId; mCurrentClassId = *classId;
updateStats(); updateStats();
} }
@ -192,7 +191,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
void PickClassDialog::updateClasses() void PickClassDialog::updateClasses()
{ {
classList->removeAllItems(); mClassList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
@ -207,19 +206,19 @@ void PickClassDialog::updateClasses()
continue; continue;
const std::string &id = it->first; const std::string &id = it->first;
classList->addItem(klass.name, id); mClassList->addItem(klass.name, id);
if (boost::iequals(id, currentClassId)) if (boost::iequals(id, mCurrentClassId))
classList->setIndexSelected(index); mClassList->setIndexSelected(index);
++index; ++index;
} }
} }
void PickClassDialog::updateStats() void PickClassDialog::updateStats()
{ {
if (currentClassId.empty()) if (mCurrentClassId.empty())
return; return;
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::Class *klass = store.classes.search(currentClassId); const ESM::Class *klass = store.classes.search(mCurrentClassId);
if (!klass) if (!klass)
return; return;
@ -231,23 +230,23 @@ void PickClassDialog::updateStats()
"sSpecializationStealth" "sSpecializationStealth"
}; };
std::string specName = mWindowManager.getGameSettingString(specIds[specialization], specIds[specialization]); std::string specName = mWindowManager.getGameSettingString(specIds[specialization], specIds[specialization]);
specializationName->setCaption(specName); mSpecializationName->setCaption(specName);
ToolTips::createSpecializationToolTip(specializationName, specName, specialization); ToolTips::createSpecializationToolTip(mSpecializationName, specName, specialization);
favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); mFavoriteAttribute[0]->setAttributeId(klass->data.attribute[0]);
favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); mFavoriteAttribute[1]->setAttributeId(klass->data.attribute[1]);
ToolTips::createAttributeToolTip(favoriteAttribute[0], favoriteAttribute[0]->getAttributeId()); ToolTips::createAttributeToolTip(mFavoriteAttribute[0], mFavoriteAttribute[0]->getAttributeId());
ToolTips::createAttributeToolTip(favoriteAttribute[1], favoriteAttribute[1]->getAttributeId()); ToolTips::createAttributeToolTip(mFavoriteAttribute[1], mFavoriteAttribute[1]->getAttributeId());
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
minorSkill[i]->setSkillNumber(klass->data.skills[i][0]); mMinorSkill[i]->setSkillNumber(klass->data.skills[i][0]);
majorSkill[i]->setSkillNumber(klass->data.skills[i][1]); mMajorSkill[i]->setSkillNumber(klass->data.skills[i][1]);
ToolTips::createSkillToolTip(minorSkill[i], klass->data.skills[i][0]); ToolTips::createSkillToolTip(mMinorSkill[i], klass->data.skills[i][0]);
ToolTips::createSkillToolTip(majorSkill[i], klass->data.skills[i][1]); ToolTips::createSkillToolTip(mMajorSkill[i], klass->data.skills[i][1]);
} }
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
} }
/* InfoBoxDialog */ /* InfoBoxDialog */
@ -284,59 +283,59 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager) InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager)
: WindowBase("openmw_infobox.layout", parWindowManager) : WindowBase("openmw_infobox.layout", parWindowManager)
, currentButton(-1) , mCurrentButton(-1)
{ {
getWidget(textBox, "TextBox"); getWidget(mTextBox, "TextBox");
getWidget(text, "Text"); getWidget(mText, "Text");
text->getSubWidgetText()->setWordWrap(true); mText->getSubWidgetText()->setWordWrap(true);
getWidget(buttonBar, "ButtonBar"); getWidget(mButtonBar, "ButtonBar");
center(); center();
} }
void InfoBoxDialog::setText(const std::string &str) void InfoBoxDialog::setText(const std::string &str)
{ {
text->setCaption(str); mText->setCaption(str);
textBox->setVisible(!str.empty()); mTextBox->setVisible(!str.empty());
fitToText(text); fitToText(mText);
} }
std::string InfoBoxDialog::getText() const std::string InfoBoxDialog::getText() const
{ {
return text->getCaption(); return mText->getCaption();
} }
void InfoBoxDialog::setButtons(ButtonList &buttons) void InfoBoxDialog::setButtons(ButtonList &buttons)
{ {
for (std::vector<MyGUI::ButtonPtr>::iterator it = this->buttons.begin(); it != this->buttons.end(); ++it) for (std::vector<MyGUI::ButtonPtr>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
this->buttons.clear(); this->mButtons.clear();
currentButton = -1; mCurrentButton = -1;
// 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::ButtonPtr button; MyGUI::ButtonPtr button;
MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, buttonBar->getWidth(), 10); MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10);
ButtonList::const_iterator end = buttons.end(); ButtonList::const_iterator end = buttons.end();
for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it) for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it)
{ {
const std::string &text = *it; const std::string &text = *it;
button = buttonBar->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);
fitToText(button); fitToText(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked);
coord.top += button->getHeight(); coord.top += button->getHeight();
this->buttons.push_back(button); this->mButtons.push_back(button);
} }
} }
void InfoBoxDialog::open() void InfoBoxDialog::open()
{ {
// Fix layout // Fix layout
layoutVertically(textBox, 4); layoutVertically(mTextBox, 4);
layoutVertically(buttonBar, 6); layoutVertically(mButtonBar, 6);
layoutVertically(mMainWidget, 4 + 6); layoutVertically(mMainWidget, 4 + 6);
center(); center();
@ -345,18 +344,18 @@ void InfoBoxDialog::open()
int InfoBoxDialog::getChosenButton() const int InfoBoxDialog::getChosenButton() const
{ {
return currentButton; return mCurrentButton;
} }
void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender) void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
{ {
std::vector<MyGUI::ButtonPtr>::const_iterator end = buttons.end(); std::vector<MyGUI::ButtonPtr>::const_iterator end = mButtons.end();
int i = 0; int i = 0;
for (std::vector<MyGUI::ButtonPtr>::const_iterator it = buttons.begin(); it != end; ++it) for (std::vector<MyGUI::ButtonPtr>::const_iterator it = mButtons.begin(); it != end; ++it)
{ {
if (*it == _sender) if (*it == _sender)
{ {
currentButton = i; mCurrentButton = i;
eventButtonSelected(i); eventButtonSelected(i);
return; return;
} }
@ -382,49 +381,49 @@ ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager)
CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_create_class.layout", parWindowManager) : WindowBase("openmw_chargen_create_class.layout", parWindowManager)
, specDialog(nullptr) , mSpecDialog(nullptr)
, attribDialog(nullptr) , mAttribDialog(nullptr)
, skillDialog(nullptr) , mSkillDialog(nullptr)
, descDialog(nullptr) , mDescDialog(nullptr)
{ {
// Centre dialog // Centre dialog
center(); center();
setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization")); setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
getWidget(specializationName, "SpecializationName"); getWidget(mSpecializationName, "SpecializationName");
specializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); mSpecializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked);
setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
getWidget(favoriteAttribute0, "FavoriteAttribute0"); getWidget(mFavoriteAttribute0, "FavoriteAttribute0");
getWidget(favoriteAttribute1, "FavoriteAttribute1"); getWidget(mFavoriteAttribute1, "FavoriteAttribute1");
favoriteAttribute0->setWindowManager(&mWindowManager); mFavoriteAttribute0->setWindowManager(&mWindowManager);
favoriteAttribute1->setWindowManager(&mWindowManager); mFavoriteAttribute1->setWindowManager(&mWindowManager);
favoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); mFavoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
favoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); mFavoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", "")); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", ""));
setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", ""));
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
char theIndex = '0'+i; char theIndex = '0'+i;
getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex));
getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); getWidget(mMinorSkill[i], std::string("MinorSkill").append(1, theIndex));
skills.push_back(majorSkill[i]); mSkills.push_back(mMajorSkill[i]);
skills.push_back(minorSkill[i]); mSkills.push_back(mMinorSkill[i]);
} }
std::vector<Widgets::MWSkillPtr>::const_iterator end = skills.end(); std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end();
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it) for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
(*it)->setWindowManager(&mWindowManager); (*it)->setWindowManager(&mWindowManager);
(*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); (*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
} }
setText("LabelT", mWindowManager.getGameSettingString("sName", "")); setText("LabelT", mWindowManager.getGameSettingString("sName", ""));
getWidget(editName, "EditName"); getWidget(mEditName, "EditName");
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(editName); MyGUI::InputManager::getInstance().setKeyFocusWidget(mEditName);
MyGUI::ButtonPtr descriptionButton; MyGUI::ButtonPtr descriptionButton;
getWidget(descriptionButton, "DescriptionButton"); getWidget(descriptionButton, "DescriptionButton");
@ -441,20 +440,20 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
// Set default skills, attributes // Set default skills, attributes
favoriteAttribute0->setAttributeId(ESM::Attribute::Strength); mFavoriteAttribute0->setAttributeId(ESM::Attribute::Strength);
favoriteAttribute1->setAttributeId(ESM::Attribute::Agility); mFavoriteAttribute1->setAttributeId(ESM::Attribute::Agility);
majorSkill[0]->setSkillId(ESM::Skill::Block); mMajorSkill[0]->setSkillId(ESM::Skill::Block);
majorSkill[1]->setSkillId(ESM::Skill::Armorer); mMajorSkill[1]->setSkillId(ESM::Skill::Armorer);
majorSkill[2]->setSkillId(ESM::Skill::MediumArmor); mMajorSkill[2]->setSkillId(ESM::Skill::MediumArmor);
majorSkill[3]->setSkillId(ESM::Skill::HeavyArmor); mMajorSkill[3]->setSkillId(ESM::Skill::HeavyArmor);
majorSkill[4]->setSkillId(ESM::Skill::BluntWeapon); mMajorSkill[4]->setSkillId(ESM::Skill::BluntWeapon);
minorSkill[0]->setSkillId(ESM::Skill::LongBlade); mMinorSkill[0]->setSkillId(ESM::Skill::LongBlade);
minorSkill[1]->setSkillId(ESM::Skill::Axe); mMinorSkill[1]->setSkillId(ESM::Skill::Axe);
minorSkill[2]->setSkillId(ESM::Skill::Spear); mMinorSkill[2]->setSkillId(ESM::Skill::Spear);
minorSkill[3]->setSkillId(ESM::Skill::Athletics); mMinorSkill[3]->setSkillId(ESM::Skill::Athletics);
minorSkill[4]->setSkillId(ESM::Skill::Enchant); mMinorSkill[4]->setSkillId(ESM::Skill::Enchant);
setSpecialization(0); setSpecialization(0);
update(); update();
@ -462,44 +461,44 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
CreateClassDialog::~CreateClassDialog() CreateClassDialog::~CreateClassDialog()
{ {
delete specDialog; delete mSpecDialog;
delete attribDialog; delete mAttribDialog;
delete skillDialog; delete mSkillDialog;
delete descDialog; delete mDescDialog;
} }
void CreateClassDialog::update() void CreateClassDialog::update()
{ {
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
ToolTips::createSkillToolTip(majorSkill[i], majorSkill[i]->getSkillId()); ToolTips::createSkillToolTip(mMajorSkill[i], mMajorSkill[i]->getSkillId());
ToolTips::createSkillToolTip(minorSkill[i], minorSkill[i]->getSkillId()); ToolTips::createSkillToolTip(mMinorSkill[i], mMinorSkill[i]->getSkillId());
} }
ToolTips::createAttributeToolTip(favoriteAttribute0, favoriteAttribute0->getAttributeId()); ToolTips::createAttributeToolTip(mFavoriteAttribute0, mFavoriteAttribute0->getAttributeId());
ToolTips::createAttributeToolTip(favoriteAttribute1, favoriteAttribute1->getAttributeId()); ToolTips::createAttributeToolTip(mFavoriteAttribute1, mFavoriteAttribute1->getAttributeId());
} }
std::string CreateClassDialog::getName() const std::string CreateClassDialog::getName() const
{ {
return editName->getOnlyText(); return mEditName->getOnlyText();
} }
std::string CreateClassDialog::getDescription() const std::string CreateClassDialog::getDescription() const
{ {
return description; return mDescription;
} }
ESM::Class::Specialization CreateClassDialog::getSpecializationId() const ESM::Class::Specialization CreateClassDialog::getSpecializationId() const
{ {
return specializationId; return mSpecializationId;
} }
std::vector<int> CreateClassDialog::getFavoriteAttributes() const std::vector<int> CreateClassDialog::getFavoriteAttributes() const
{ {
std::vector<int> v; std::vector<int> v;
v.push_back(favoriteAttribute0->getAttributeId()); v.push_back(mFavoriteAttribute0->getAttributeId());
v.push_back(favoriteAttribute1->getAttributeId()); v.push_back(mFavoriteAttribute1->getAttributeId());
return v; return v;
} }
@ -508,7 +507,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMajorSkills() const
std::vector<ESM::Skill::SkillEnum> v; std::vector<ESM::Skill::SkillEnum> v;
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
v.push_back(majorSkill[i]->getSkillId()); v.push_back(mMajorSkill[i]->getSkillId());
} }
return v; return v;
} }
@ -518,7 +517,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
std::vector<ESM::Skill::SkillEnum> v; std::vector<ESM::Skill::SkillEnum> v;
for(int i=0; i < 5; i++) for(int i=0; i < 5; i++)
{ {
v.push_back(minorSkill[i]->getSkillId()); v.push_back(mMinorSkill[i]->getSkillId());
} }
return v; return v;
} }
@ -557,108 +556,108 @@ void CreateClassDialog::open()
void CreateClassDialog::onDialogCancel() void CreateClassDialog::onDialogCancel()
{ {
if (specDialog) if (mSpecDialog)
{ {
mWindowManager.removeDialog(specDialog); mWindowManager.removeDialog(mSpecDialog);
specDialog = 0; mSpecDialog = 0;
} }
if (attribDialog) if (mAttribDialog)
{ {
mWindowManager.removeDialog(attribDialog); mWindowManager.removeDialog(mAttribDialog);
attribDialog = 0; mAttribDialog = 0;
} }
if (skillDialog) if (mSkillDialog)
{ {
mWindowManager.removeDialog(skillDialog); mWindowManager.removeDialog(mSkillDialog);
skillDialog = 0; mSkillDialog = 0;
} }
if (descDialog) if (mDescDialog)
{ {
mWindowManager.removeDialog(descDialog); mWindowManager.removeDialog(mDescDialog);
descDialog = 0; mDescDialog = 0;
} }
} }
void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
{ {
delete specDialog; delete mSpecDialog;
specDialog = new SelectSpecializationDialog(mWindowManager); mSpecDialog = new SelectSpecializationDialog(mWindowManager);
specDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); mSpecDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
specDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); mSpecDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
specDialog->setVisible(true); mSpecDialog->setVisible(true);
} }
void CreateClassDialog::onSpecializationSelected() void CreateClassDialog::onSpecializationSelected()
{ {
specializationId = specDialog->getSpecializationId(); mSpecializationId = mSpecDialog->getSpecializationId();
setSpecialization(specializationId); setSpecialization(mSpecializationId);
mWindowManager.removeDialog(specDialog); mWindowManager.removeDialog(mSpecDialog);
specDialog = 0; mSpecDialog = 0;
} }
void CreateClassDialog::setSpecialization(int id) void CreateClassDialog::setSpecialization(int id)
{ {
specializationId = (ESM::Class::Specialization) id; mSpecializationId = (ESM::Class::Specialization) id;
static const char *specIds[3] = { static const char *specIds[3] = {
"sSpecializationCombat", "sSpecializationCombat",
"sSpecializationMagic", "sSpecializationMagic",
"sSpecializationStealth" "sSpecializationStealth"
}; };
std::string specName = mWindowManager.getGameSettingString(specIds[specializationId], specIds[specializationId]); std::string specName = mWindowManager.getGameSettingString(specIds[mSpecializationId], specIds[mSpecializationId]);
specializationName->setCaption(specName); mSpecializationName->setCaption(specName);
ToolTips::createSpecializationToolTip(specializationName, specName, specializationId); ToolTips::createSpecializationToolTip(mSpecializationName, specName, mSpecializationId);
} }
void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
{ {
delete attribDialog; delete mAttribDialog;
attribDialog = new SelectAttributeDialog(mWindowManager); mAttribDialog = new SelectAttributeDialog(mWindowManager);
attribDialog->setAffectedWidget(_sender); mAttribDialog->setAffectedWidget(_sender);
attribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); mAttribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
attribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); mAttribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
attribDialog->setVisible(true); mAttribDialog->setVisible(true);
} }
void CreateClassDialog::onAttributeSelected() void CreateClassDialog::onAttributeSelected()
{ {
ESM::Attribute::AttributeID id = attribDialog->getAttributeId(); ESM::Attribute::AttributeID id = mAttribDialog->getAttributeId();
Widgets::MWAttributePtr attribute = attribDialog->getAffectedWidget(); Widgets::MWAttributePtr attribute = mAttribDialog->getAffectedWidget();
if (attribute == favoriteAttribute0) if (attribute == mFavoriteAttribute0)
{ {
if (favoriteAttribute1->getAttributeId() == id) if (mFavoriteAttribute1->getAttributeId() == id)
favoriteAttribute1->setAttributeId(favoriteAttribute0->getAttributeId()); mFavoriteAttribute1->setAttributeId(mFavoriteAttribute0->getAttributeId());
} }
else if (attribute == favoriteAttribute1) else if (attribute == mFavoriteAttribute1)
{ {
if (favoriteAttribute0->getAttributeId() == id) if (mFavoriteAttribute0->getAttributeId() == id)
favoriteAttribute0->setAttributeId(favoriteAttribute1->getAttributeId()); mFavoriteAttribute0->setAttributeId(mFavoriteAttribute1->getAttributeId());
} }
attribute->setAttributeId(id); attribute->setAttributeId(id);
mWindowManager.removeDialog(attribDialog); mWindowManager.removeDialog(mAttribDialog);
attribDialog = 0; mAttribDialog = 0;
update(); update();
} }
void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender) void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
{ {
delete skillDialog; delete mSkillDialog;
skillDialog = new SelectSkillDialog(mWindowManager); mSkillDialog = new SelectSkillDialog(mWindowManager);
skillDialog->setAffectedWidget(_sender); mSkillDialog->setAffectedWidget(_sender);
skillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); mSkillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
skillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); mSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
skillDialog->setVisible(true); mSkillDialog->setVisible(true);
} }
void CreateClassDialog::onSkillSelected() void CreateClassDialog::onSkillSelected()
{ {
ESM::Skill::SkillEnum id = skillDialog->getSkillId(); ESM::Skill::SkillEnum id = mSkillDialog->getSkillId();
Widgets::MWSkillPtr skill = skillDialog->getAffectedWidget(); Widgets::MWSkillPtr skill = mSkillDialog->getAffectedWidget();
// 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 = skills.end(); std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end();
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it) for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
if (*it == skill) if (*it == skill)
continue; continue;
@ -669,25 +668,25 @@ void CreateClassDialog::onSkillSelected()
} }
} }
skill->setSkillId(skillDialog->getSkillId()); skill->setSkillId(mSkillDialog->getSkillId());
mWindowManager.removeDialog(skillDialog); mWindowManager.removeDialog(mSkillDialog);
skillDialog = 0; mSkillDialog = 0;
update(); update();
} }
void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender) void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
{ {
descDialog = new DescriptionDialog(mWindowManager); mDescDialog = new DescriptionDialog(mWindowManager);
descDialog->setTextInput(description); mDescDialog->setTextInput(mDescription);
descDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); mDescDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
descDialog->setVisible(true); mDescDialog->setVisible(true);
} }
void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow) void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow)
{ {
description = descDialog->getTextInput(); mDescription = mDescDialog->getTextInput();
mWindowManager.removeDialog(descDialog); mWindowManager.removeDialog(mDescDialog);
descDialog = 0; mDescDialog = 0;
} }
void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender)
@ -710,24 +709,24 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", "")); setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", ""));
getWidget(specialization0, "Specialization0"); getWidget(mSpecialization0, "Specialization0");
getWidget(specialization1, "Specialization1"); getWidget(mSpecialization1, "Specialization1");
getWidget(specialization2, "Specialization2"); getWidget(mSpecialization2, "Specialization2");
std::string combat = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""); std::string combat = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "");
std::string magic = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""); std::string magic = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], "");
std::string stealth = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""); std::string stealth = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], "");
specialization0->setCaption(combat); mSpecialization0->setCaption(combat);
specialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization1->setCaption(magic); mSpecialization1->setCaption(magic);
specialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization2->setCaption(stealth); mSpecialization2->setCaption(stealth);
specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specializationId = ESM::Class::Combat; mSpecializationId = ESM::Class::Combat;
ToolTips::createSpecializationToolTip(specialization0, combat, ESM::Class::Combat); ToolTips::createSpecializationToolTip(mSpecialization0, combat, ESM::Class::Combat);
ToolTips::createSpecializationToolTip(specialization1, magic, ESM::Class::Magic); ToolTips::createSpecializationToolTip(mSpecialization1, magic, ESM::Class::Magic);
ToolTips::createSpecializationToolTip(specialization2, stealth, ESM::Class::Stealth); ToolTips::createSpecializationToolTip(mSpecialization2, stealth, ESM::Class::Stealth);
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
@ -748,12 +747,12 @@ SelectSpecializationDialog::~SelectSpecializationDialog()
void SelectSpecializationDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) void SelectSpecializationDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
{ {
if (_sender == specialization0) if (_sender == mSpecialization0)
specializationId = ESM::Class::Combat; mSpecializationId = ESM::Class::Combat;
else if (_sender == specialization1) else if (_sender == mSpecialization1)
specializationId = ESM::Class::Magic; mSpecializationId = ESM::Class::Magic;
else if (_sender == specialization2) else if (_sender == mSpecialization2)
specializationId = ESM::Class::Stealth; mSpecializationId = ESM::Class::Stealth;
else else
return; return;
@ -807,7 +806,7 @@ SelectAttributeDialog::~SelectAttributeDialog()
void SelectAttributeDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) void SelectAttributeDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
{ {
// TODO: Change MWAttribute to set and get AttributeID enum instead of int // TODO: Change MWAttribute to set and get AttributeID enum instead of int
attributeId = static_cast<ESM::Attribute::AttributeID>(_sender->getAttributeId()); mAttributeId = static_cast<ESM::Attribute::AttributeID>(_sender->getAttributeId());
eventItemSelected(); eventItemSelected();
} }
@ -833,44 +832,44 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
for(int i = 0; i < 9; i++) for(int i = 0; i < 9; i++)
{ {
char theIndex = '0'+i; char theIndex = '0'+i;
getWidget(combatSkill[i], std::string("CombatSkill").append(1, theIndex)); getWidget(mCombatSkill[i], std::string("CombatSkill").append(1, theIndex));
getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); getWidget(mMagicSkill[i], std::string("MagicSkill").append(1, theIndex));
getWidget(stealthSkill[i], std::string("StealthSkill").append(1, theIndex)); getWidget(mStealthSkill[i], std::string("StealthSkill").append(1, theIndex));
} }
struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} skills[3][9] = { struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} mSkills[3][9] = {
{ {
{combatSkill[0], ESM::Skill::Block}, {mCombatSkill[0], ESM::Skill::Block},
{combatSkill[1], ESM::Skill::Armorer}, {mCombatSkill[1], ESM::Skill::Armorer},
{combatSkill[2], ESM::Skill::MediumArmor}, {mCombatSkill[2], ESM::Skill::MediumArmor},
{combatSkill[3], ESM::Skill::HeavyArmor}, {mCombatSkill[3], ESM::Skill::HeavyArmor},
{combatSkill[4], ESM::Skill::BluntWeapon}, {mCombatSkill[4], ESM::Skill::BluntWeapon},
{combatSkill[5], ESM::Skill::LongBlade}, {mCombatSkill[5], ESM::Skill::LongBlade},
{combatSkill[6], ESM::Skill::Axe}, {mCombatSkill[6], ESM::Skill::Axe},
{combatSkill[7], ESM::Skill::Spear}, {mCombatSkill[7], ESM::Skill::Spear},
{combatSkill[8], ESM::Skill::Athletics} {mCombatSkill[8], ESM::Skill::Athletics}
}, },
{ {
{magicSkill[0], ESM::Skill::Enchant}, {mMagicSkill[0], ESM::Skill::Enchant},
{magicSkill[1], ESM::Skill::Destruction}, {mMagicSkill[1], ESM::Skill::Destruction},
{magicSkill[2], ESM::Skill::Alteration}, {mMagicSkill[2], ESM::Skill::Alteration},
{magicSkill[3], ESM::Skill::Illusion}, {mMagicSkill[3], ESM::Skill::Illusion},
{magicSkill[4], ESM::Skill::Conjuration}, {mMagicSkill[4], ESM::Skill::Conjuration},
{magicSkill[5], ESM::Skill::Mysticism}, {mMagicSkill[5], ESM::Skill::Mysticism},
{magicSkill[6], ESM::Skill::Restoration}, {mMagicSkill[6], ESM::Skill::Restoration},
{magicSkill[7], ESM::Skill::Alchemy}, {mMagicSkill[7], ESM::Skill::Alchemy},
{magicSkill[8], ESM::Skill::Unarmored} {mMagicSkill[8], ESM::Skill::Unarmored}
}, },
{ {
{stealthSkill[0], ESM::Skill::Security}, {mStealthSkill[0], ESM::Skill::Security},
{stealthSkill[1], ESM::Skill::Sneak}, {mStealthSkill[1], ESM::Skill::Sneak},
{stealthSkill[2], ESM::Skill::Acrobatics}, {mStealthSkill[2], ESM::Skill::Acrobatics},
{stealthSkill[3], ESM::Skill::LightArmor}, {mStealthSkill[3], ESM::Skill::LightArmor},
{stealthSkill[4], ESM::Skill::ShortBlade}, {mStealthSkill[4], ESM::Skill::ShortBlade},
{stealthSkill[5] ,ESM::Skill::Marksman}, {mStealthSkill[5] ,ESM::Skill::Marksman},
{stealthSkill[6] ,ESM::Skill::Mercantile}, {mStealthSkill[6] ,ESM::Skill::Mercantile},
{stealthSkill[7] ,ESM::Skill::Speechcraft}, {mStealthSkill[7] ,ESM::Skill::Speechcraft},
{stealthSkill[8] ,ESM::Skill::HandToHand} {mStealthSkill[8] ,ESM::Skill::HandToHand}
} }
}; };
@ -878,10 +877,10 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
{ {
for (int i = 0; i < 9; ++i) for (int i = 0; i < 9; ++i)
{ {
skills[spec][i].widget->setWindowManager(&mWindowManager); mSkills[spec][i].widget->setWindowManager(&mWindowManager);
skills[spec][i].widget->setSkillId(skills[spec][i].skillId); mSkills[spec][i].widget->setSkillId(mSkills[spec][i].skillId);
skills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); mSkills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked);
ToolTips::createSkillToolTip(skills[spec][i].widget, skills[spec][i].widget->getSkillId()); ToolTips::createSkillToolTip(mSkills[spec][i].widget, mSkills[spec][i].widget->getSkillId());
} }
} }
@ -904,7 +903,7 @@ SelectSkillDialog::~SelectSkillDialog()
void SelectSkillDialog::onSkillClicked(Widgets::MWSkillPtr _sender) void SelectSkillDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
{ {
skillId = _sender->getSkillId(); mSkillId = _sender->getSkillId();
eventItemSelected(); eventItemSelected();
} }
@ -921,7 +920,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
// Centre dialog // Centre dialog
center(); center();
getWidget(textEdit, "TextEdit"); getWidget(mTextEdit, "TextEdit");
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
@ -931,7 +930,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24); okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24);
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
} }

@ -45,11 +45,11 @@ namespace MWGui
void fitToText(MyGUI::TextBox* widget); void fitToText(MyGUI::TextBox* widget);
void layoutVertically(MyGUI::WidgetPtr widget, int margin); void layoutVertically(MyGUI::WidgetPtr widget, int margin);
int currentButton; int mCurrentButton;
MyGUI::WidgetPtr textBox; MyGUI::WidgetPtr mTextBox;
MyGUI::TextBox* text; MyGUI::TextBox* mText;
MyGUI::WidgetPtr buttonBar; MyGUI::WidgetPtr mButtonBar;
std::vector<MyGUI::ButtonPtr> buttons; std::vector<MyGUI::ButtonPtr> mButtons;
}; };
// Lets the player choose between 3 ways of creating a class // Lets the player choose between 3 ways of creating a class
@ -90,10 +90,10 @@ namespace MWGui
void onBackClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender);
private: private:
MyGUI::ImageBox* classImage; MyGUI::ImageBox* mClassImage;
MyGUI::TextBox* className; MyGUI::TextBox* mClassName;
std::string currentClassId; std::string mCurrentClassId;
}; };
class PickClassDialog : public WindowBase class PickClassDialog : public WindowBase
@ -101,7 +101,7 @@ namespace MWGui
public: public:
PickClassDialog(WindowManager& parWindowManager); PickClassDialog(WindowManager& parWindowManager);
const std::string &getClassId() const { return currentClassId; } const std::string &getClassId() const { return mCurrentClassId; }
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
@ -125,14 +125,14 @@ namespace MWGui
void updateClasses(); void updateClasses();
void updateStats(); void updateStats();
MyGUI::ImageBox* classImage; MyGUI::ImageBox* mClassImage;
MyGUI::ListBox* classList; MyGUI::ListBox* mClassList;
MyGUI::TextBox* specializationName; MyGUI::TextBox* mSpecializationName;
Widgets::MWAttributePtr favoriteAttribute[2]; Widgets::MWAttributePtr mFavoriteAttribute[2];
Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr minorSkill[5]; Widgets::MWSkillPtr mMinorSkill[5];
std::string currentClassId; std::string mCurrentClassId;
}; };
class SelectSpecializationDialog : public WindowBase class SelectSpecializationDialog : public WindowBase
@ -141,7 +141,7 @@ namespace MWGui
SelectSpecializationDialog(WindowManager& parWindowManager); SelectSpecializationDialog(WindowManager& parWindowManager);
~SelectSpecializationDialog(); ~SelectSpecializationDialog();
ESM::Class::Specialization getSpecializationId() const { return specializationId; } ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
@ -161,9 +161,9 @@ namespace MWGui
void onCancelClicked(MyGUI::Widget* _sender); void onCancelClicked(MyGUI::Widget* _sender);
private: private:
MyGUI::TextBox *specialization0, *specialization1, *specialization2; MyGUI::TextBox *mSpecialization0, *mSpecialization1, *mSpecialization2;
ESM::Class::Specialization specializationId; ESM::Class::Specialization mSpecializationId;
}; };
class SelectAttributeDialog : public WindowBase class SelectAttributeDialog : public WindowBase
@ -172,9 +172,9 @@ namespace MWGui
SelectAttributeDialog(WindowManager& parWindowManager); SelectAttributeDialog(WindowManager& parWindowManager);
~SelectAttributeDialog(); ~SelectAttributeDialog();
ESM::Attribute::AttributeID getAttributeId() const { return attributeId; } ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; } Widgets::MWAttributePtr getAffectedWidget() const { return mAffectedWidget; }
void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; } void setAffectedWidget(Widgets::MWAttributePtr widget) { mAffectedWidget = widget; }
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
@ -194,9 +194,9 @@ namespace MWGui
void onCancelClicked(MyGUI::Widget* _sender); void onCancelClicked(MyGUI::Widget* _sender);
private: private:
Widgets::MWAttributePtr affectedWidget; Widgets::MWAttributePtr mAffectedWidget;
ESM::Attribute::AttributeID attributeId; ESM::Attribute::AttributeID mAttributeId;
}; };
class SelectSkillDialog : public WindowBase class SelectSkillDialog : public WindowBase
@ -205,9 +205,9 @@ namespace MWGui
SelectSkillDialog(WindowManager& parWindowManager); SelectSkillDialog(WindowManager& parWindowManager);
~SelectSkillDialog(); ~SelectSkillDialog();
ESM::Skill::SkillEnum getSkillId() const { return skillId; } ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; } Widgets::MWSkillPtr getAffectedWidget() const { return mAffectedWidget; }
void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; } void setAffectedWidget(Widgets::MWSkillPtr widget) { mAffectedWidget = widget; }
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
@ -227,12 +227,12 @@ namespace MWGui
void onCancelClicked(MyGUI::Widget* _sender); void onCancelClicked(MyGUI::Widget* _sender);
private: private:
Widgets::MWSkillPtr combatSkill[9]; Widgets::MWSkillPtr mCombatSkill[9];
Widgets::MWSkillPtr magicSkill[9]; Widgets::MWSkillPtr mMagicSkill[9];
Widgets::MWSkillPtr stealthSkill[9]; Widgets::MWSkillPtr mStealthSkill[9];
Widgets::MWSkillPtr affectedWidget; Widgets::MWSkillPtr mAffectedWidget;
ESM::Skill::SkillEnum skillId; ESM::Skill::SkillEnum mSkillId;
}; };
class DescriptionDialog : public WindowBase class DescriptionDialog : public WindowBase
@ -241,14 +241,14 @@ namespace MWGui
DescriptionDialog(WindowManager& parWindowManager); DescriptionDialog(WindowManager& parWindowManager);
~DescriptionDialog(); ~DescriptionDialog();
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; }
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); }
protected: protected:
void onOkClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender);
private: private:
MyGUI::EditPtr textEdit; MyGUI::EditPtr mTextEdit;
}; };
class CreateClassDialog : public WindowBase class CreateClassDialog : public WindowBase
@ -294,20 +294,20 @@ namespace MWGui
void update(); void update();
private: private:
MyGUI::EditPtr editName; MyGUI::EditPtr mEditName;
MyGUI::TextBox* specializationName; MyGUI::TextBox* mSpecializationName;
Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1;
Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr minorSkill[5]; Widgets::MWSkillPtr mMinorSkill[5];
std::vector<Widgets::MWSkillPtr> skills; std::vector<Widgets::MWSkillPtr> mSkills;
std::string description; std::string mDescription;
SelectSpecializationDialog *specDialog; SelectSpecializationDialog *mSpecDialog;
SelectAttributeDialog *attribDialog; SelectAttributeDialog *mAttribDialog;
SelectSkillDialog *skillDialog; SelectSkillDialog *mSkillDialog;
DescriptionDialog *descDialog; DescriptionDialog *mDescDialog;
ESM::Class::Specialization specializationId; ESM::Class::Specialization mSpecializationId;
}; };
} }
#endif #endif

@ -2,6 +2,7 @@
#include "console.hpp" #include "console.hpp"
#include <algorithm> #include <algorithm>
#include <fstream>
#include <components/esm_store/reclists.hpp> #include <components/esm_store/reclists.hpp>
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
@ -105,9 +106,10 @@ namespace MWGui
} }
} }
Console::Console(int w, int h, const Compiler::Extensions& extensions) Console::Console(int w, int h, bool consoleOnlyScripts)
: Layout("openmw_console.layout"), : Layout("openmw_console.layout"),
mCompilerContext (MWScript::CompilerContext::Type_Console) mCompilerContext (MWScript::CompilerContext::Type_Console),
mConsoleOnlyScripts (consoleOnlyScripts)
{ {
setCoord(10,10, w-10, h/2); setCoord(10,10, w-10, h/2);
@ -126,7 +128,8 @@ namespace MWGui
history->setVisibleVScroll(true); history->setVisibleVScroll(true);
// compiler // compiler
mCompilerContext.setExtensions (&extensions); MWScript::registerExtensions (mExtensions, mConsoleOnlyScripts);
mCompilerContext.setExtensions (&mExtensions);
} }
void Console::enable() void Console::enable()
@ -173,6 +176,47 @@ namespace MWGui
print("#FF2222" + msg + "\n"); print("#FF2222" + msg + "\n");
} }
void Console::execute (const std::string& command)
{
// Log the command
print("#FFFFFF> " + command + "\n");
Compiler::Locals locals;
Compiler::Output output (locals);
if (compile (command + "\n", output))
{
try
{
ConsoleInterpreterContext interpreterContext (*this, mPtr);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter, mConsoleOnlyScripts);
std::vector<Interpreter::Type_Code> code;
output.getCode (code);
interpreter.run (&code[0], code.size(), interpreterContext);
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
}
}
void Console::executeFile (const std::string& path)
{
std::ifstream stream (path.c_str());
if (!stream.is_open())
printError ("failed to open file: " + path);
else
{
std::string line;
while (std::getline (stream, line))
execute (line);
}
}
void Console::keyPress(MyGUI::WidgetPtr _sender, void Console::keyPress(MyGUI::WidgetPtr _sender,
MyGUI::KeyCode key, MyGUI::KeyCode key,
MyGUI::Char _char) MyGUI::Char _char)
@ -234,28 +278,7 @@ namespace MWGui
current = command_history.end(); current = command_history.end();
editString.clear(); editString.clear();
// Log the command execute (cm);
print("#FFFFFF> " + cm + "\n");
Compiler::Locals locals;
Compiler::Output output (locals);
if (compile (cm + "\n", output))
{
try
{
ConsoleInterpreterContext interpreterContext (*this, mPtr);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
std::vector<Interpreter::Type_Code> code;
output.getCode (code);
interpreter.run (&code[0], code.size(), interpreterContext);
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
}
command->setCaption(""); command->setCaption("");
} }

@ -11,6 +11,7 @@
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
#include <components/compiler/output.hpp> #include <components/compiler/output.hpp>
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp> #include <components/interpreter/interpreter.hpp>
#include "../mwscript/compilercontext.hpp" #include "../mwscript/compilercontext.hpp"
@ -24,8 +25,10 @@ namespace MWGui
{ {
private: private:
Compiler::Extensions mExtensions;
MWScript::CompilerContext mCompilerContext; MWScript::CompilerContext mCompilerContext;
std::vector<std::string> mNames; std::vector<std::string> mNames;
bool mConsoleOnlyScripts;
bool compile (const std::string& cmd, Compiler::Output& output); bool compile (const std::string& cmd, Compiler::Output& output);
@ -62,7 +65,7 @@ namespace MWGui
StringList::iterator current; StringList::iterator current;
std::string editString; std::string editString;
Console(int w, int h, const Compiler::Extensions& extensions); Console(int w, int h, bool consoleOnlyScripts);
void enable(); void enable();
@ -86,6 +89,10 @@ namespace MWGui
/// Error message /// Error message
void printError(const std::string &msg); void printError(const std::string &msg);
void execute (const std::string& command);
void executeFile (const std::string& command);
private: private:
void keyPress(MyGUI::WidgetPtr _sender, void keyPress(MyGUI::WidgetPtr _sender,

@ -1,6 +1,5 @@
#include "dialogue.hpp" #include "dialogue.hpp"
#include <assert.h>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
@ -51,9 +50,9 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
center(); center();
//History view //History view
getWidget(history, "History"); getWidget(mHistory, "History");
history->setOverflowToTheLeft(true); mHistory->setOverflowToTheLeft(true);
history->setMaxTextLength(1000000); mHistory->setMaxTextLength(1000000);
Widget* eventbox; Widget* eventbox;
//An EditBox cannot receive mouse click events, so we use an //An EditBox cannot receive mouse click events, so we use an
@ -63,36 +62,36 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel); eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel);
//Topics list //Topics list
getWidget(topicsList, "TopicsList"); getWidget(mTopicsList, "TopicsList");
topicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
MyGUI::ButtonPtr byeButton; MyGUI::ButtonPtr byeButton;
getWidget(byeButton, "ByeButton"); getWidget(byeButton, "ByeButton");
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
getWidget(pDispositionBar, "Disposition"); getWidget(mDispositionBar, "Disposition");
getWidget(pDispositionText,"DispositionText"); getWidget(mDispositionText,"DispositionText");
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
} }
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
{ {
ISubWidgetText* t = history->getClient()->getSubWidgetText(); ISubWidgetText* t = mHistory->getClient()->getSubWidgetText();
if(t == nullptr) if(t == nullptr)
return; return;
const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left); const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
size_t cursorPosition = t->getCursorPosition(lastPressed); size_t cursorPosition = t->getCursorPosition(lastPressed);
MyGUI::UString color = history->getColorAtPos(cursorPosition); MyGUI::UString color = mHistory->getColorAtPos(cursorPosition);
if (!mEnabled && color == "#572D21") if (!mEnabled && color == "#572D21")
MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
if(color != "#B29154") if(color != "#B29154")
{ {
UString key = history->getColorTextAt(cursorPosition); UString key = mHistory->getColorTextAt(cursorPosition);
if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key));
if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key)); if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key));
@ -101,15 +100,15 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
void DialogueWindow::onWindowResize(MyGUI::Window* _sender) void DialogueWindow::onWindowResize(MyGUI::Window* _sender)
{ {
topicsList->adjustSize(); mTopicsList->adjustSize();
} }
void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (history->getVScrollPosition() - _rel*0.3 < 0) if (mHistory->getVScrollPosition() - _rel*0.3 < 0)
history->setVScrollPosition(0); mHistory->setVScrollPosition(0);
else else
history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3); mHistory->setVScrollPosition(mHistory->getVScrollPosition() - _rel*0.3);
} }
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
@ -136,40 +135,40 @@ void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName)
{ {
mEnabled = true; mEnabled = true;
mPtr = actor; mPtr = actor;
topicsList->setEnabled(true); mTopicsList->setEnabled(true);
setTitle(npcName); setTitle(npcName);
topicsList->clear(); mTopicsList->clear();
history->eraseText(0,history->getTextLength()); mHistory->eraseText(0,mHistory->getTextLength());
updateOptions(); updateOptions();
} }
void DialogueWindow::setKeywords(std::list<std::string> keyWords) void DialogueWindow::setKeywords(std::list<std::string> keyWords)
{ {
topicsList->clear(); mTopicsList->clear();
bool anyService = mShowTrade; bool anyService = mShowTrade;
if (mShowTrade) if (mShowTrade)
topicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str); mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str);
if (anyService) if (anyService)
topicsList->addSeparator(); mTopicsList->addSeparator();
for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it) for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it)
{ {
topicsList->addItem(*it); mTopicsList->addItem(*it);
} }
topicsList->adjustSize(); mTopicsList->adjustSize();
} }
void DialogueWindow::removeKeyword(std::string keyWord) void DialogueWindow::removeKeyword(std::string keyWord)
{ {
if(topicsList->hasItem(keyWord)) if(mTopicsList->hasItem(keyWord))
{ {
topicsList->removeItem(keyWord); mTopicsList->removeItem(keyWord);
} }
topicsList->adjustSize(); mTopicsList->adjustSize();
} }
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2) void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
@ -206,9 +205,9 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c
std::string DialogueWindow::parseText(std::string text) std::string DialogueWindow::parseText(std::string text)
{ {
bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored) bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored)
for(unsigned int i = 0;i<topicsList->getItemCount();i++) for(unsigned int i = 0;i<mTopicsList->getItemCount();i++)
{ {
std::string keyWord = topicsList->getItemNameAt(i); std::string keyWord = mTopicsList->getItemNameAt(i);
if (separatorReached && keyWord != "") if (separatorReached && keyWord != "")
addColorInString(text,keyWord,"#686EBA","#B29154"); addColorInString(text,keyWord,"#686EBA","#B29154");
else else
@ -219,7 +218,7 @@ std::string DialogueWindow::parseText(std::string text)
void DialogueWindow::addText(std::string text) void DialogueWindow::addText(std::string text)
{ {
history->addDialogText("#B29154"+parseText(text)+"#B29154"); mHistory->addDialogText("#B29154"+parseText(text)+"#B29154");
} }
void DialogueWindow::addTitle(std::string text) void DialogueWindow::addTitle(std::string text)
@ -227,37 +226,37 @@ void DialogueWindow::addTitle(std::string text)
// This is called from the dialogue manager, so text is // This is called from the dialogue manager, so text is
// case-smashed - thus we have to retrieve the correct case // case-smashed - thus we have to retrieve the correct case
// of the text through the topic list. // of the text through the topic list.
for (size_t i=0; i<topicsList->getItemCount(); ++i) for (size_t i=0; i<mTopicsList->getItemCount(); ++i)
{ {
std::string item = topicsList->getItemNameAt(i); std::string item = mTopicsList->getItemNameAt(i);
if (lower_string(item) == text) if (lower_string(item) == text)
text = item; text = item;
} }
history->addDialogHeading(text); mHistory->addDialogHeading(text);
} }
void DialogueWindow::askQuestion(std::string question) void DialogueWindow::askQuestion(std::string question)
{ {
history->addDialogText("#572D21"+question+"#B29154"+" "); mHistory->addDialogText("#572D21"+question+"#B29154"+" ");
} }
void DialogueWindow::updateOptions() void DialogueWindow::updateOptions()
{ {
//Clear the list of topics //Clear the list of topics
topicsList->clear(); mTopicsList->clear();
history->eraseText(0,history->getTextLength()); mHistory->eraseText(0, mHistory->getTextLength());
pDispositionBar->setProgressRange(100); mDispositionBar->setProgressRange(100);
pDispositionBar->setProgressPosition(40); mDispositionBar->setProgressPosition(40);
pDispositionText->eraseText(0,pDispositionText->getTextLength()); mDispositionText->eraseText(0, mDispositionText->getTextLength());
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
} }
void DialogueWindow::goodbye() void DialogueWindow::goodbye()
{ {
history->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str); mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str);
topicsList->setEnabled(false); mTopicsList->setEnabled(false);
mEnabled = false; mEnabled = false;
} }

@ -73,10 +73,10 @@ namespace MWGui
bool mEnabled; bool mEnabled;
DialogueHistory* history; DialogueHistory* mHistory;
Widgets::MWList* topicsList; Widgets::MWList* mTopicsList;
MyGUI::ProgressPtr pDispositionBar; MyGUI::ProgressPtr mDispositionBar;
MyGUI::EditPtr pDispositionText; MyGUI::EditPtr mDispositionText;
}; };
} }
#endif #endif

@ -3,7 +3,6 @@
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
#include <assert.h>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>

@ -28,24 +28,24 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
, health(NULL) , health(NULL)
, magicka(NULL) , magicka(NULL)
, stamina(NULL) , stamina(NULL)
, weapImage(NULL) , mWeapImage(NULL)
, spellImage(NULL) , mSpellImage(NULL)
, weapStatus(NULL) , mWeapStatus(NULL)
, spellStatus(NULL) , mSpellStatus(NULL)
, effectBox(NULL) , mEffectBox(NULL)
, effect1(NULL) , mEffect1(NULL)
, minimap(NULL) , mMinimap(NULL)
, compass(NULL) , mCompass(NULL)
, crosshair(NULL) , mCrosshair(NULL)
, fpsbox(NULL) , fpsbox(NULL)
, fpscounter(NULL) , fpscounter(NULL)
, trianglecounter(NULL) , trianglecounter(NULL)
, batchcounter(NULL) , batchcounter(NULL)
, hmsBaseLeft(0) , mHealthManaStaminaBaseLeft(0)
, weapBoxBaseLeft(0) , mWeapBoxBaseLeft(0)
, spellBoxBaseLeft(0) , mSpellBoxBaseLeft(0)
, effectBoxBaseRight(0) , mEffectBoxBaseRight(0)
, minimapBoxBaseRight(0) , mMinimapBoxBaseRight(0)
, mDragAndDrop(dragAndDrop) , mDragAndDrop(dragAndDrop)
, mCellNameTimer(0.0f) , mCellNameTimer(0.0f)
, mCellNameBox(NULL) , mCellNameBox(NULL)
@ -62,7 +62,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
getWidget(magicka, "Magicka"); getWidget(magicka, "Magicka");
getWidget(stamina, "Stamina"); getWidget(stamina, "Stamina");
hmsBaseLeft = mHealthFrame->getLeft(); mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame; MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
getWidget(healthFrame, "HealthFrame"); getWidget(healthFrame, "HealthFrame");
@ -75,33 +75,33 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
// Item and spell images and status bars // Item and spell images and status bars
getWidget(weapBox, "WeapBox"); getWidget(mWeapBox, "WeapBox");
getWidget(weapImage, "WeapImage"); getWidget(mWeapImage, "WeapImage");
getWidget(weapStatus, "WeapStatus"); getWidget(mWeapStatus, "WeapStatus");
weapBoxBaseLeft = weapBox->getLeft(); mWeapBoxBaseLeft = mWeapBox->getLeft();
weapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked); mWeapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked);
getWidget(spellBox, "SpellBox"); getWidget(mSpellBox, "SpellBox");
getWidget(spellImage, "SpellImage"); getWidget(mSpellImage, "SpellImage");
getWidget(spellStatus, "SpellStatus"); getWidget(mSpellStatus, "SpellStatus");
spellBoxBaseLeft = spellBox->getLeft(); mSpellBoxBaseLeft = mSpellBox->getLeft();
spellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
getWidget(effectBox, "EffectBox"); getWidget(mEffectBox, "EffectBox");
getWidget(effect1, "Effect1"); getWidget(mEffect1, "Effect1");
effectBoxBaseRight = viewSize.width - effectBox->getRight(); mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight();
effectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); mEffectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
getWidget(minimapBox, "MiniMapBox"); getWidget(mMinimapBox, "MiniMapBox");
minimapBoxBaseRight = viewSize.width - minimapBox->getRight(); mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
minimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked); mMinimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
getWidget(minimap, "MiniMap"); getWidget(mMinimap, "MiniMap");
getWidget(compass, "Compass"); getWidget(mCompass, "Compass");
getWidget(mCellNameBox, "CellName"); getWidget(mCellNameBox, "CellName");
getWidget(mWeaponSpellBox, "WeaponSpellName"); getWidget(mWeaponSpellBox, "WeaponSpellName");
getWidget(crosshair, "Crosshair"); getWidget(mCrosshair, "Crosshair");
setFpsLevel(fpsLevel); setFpsLevel(fpsLevel);
@ -110,7 +110,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
setEffect("icons\\s\\tx_s_chameleon.dds"); setEffect("icons\\s\\tx_s_chameleon.dds");
LocalMapBase::init(minimap, compass, this); LocalMapBase::init(mMinimap, mCompass, this);
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked); mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver); mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
@ -159,7 +159,7 @@ void HUD::setBatchCount(unsigned int count)
void HUD::setEffect(const char *img) void HUD::setEffect(const char *img)
{ {
effect1->setImageTexture(img); mEffect1->setImageTexture(img);
} }
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& value) void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& value)
@ -202,10 +202,10 @@ void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellV
{ {
int weapDx = 0, spellDx = 0; int weapDx = 0, spellDx = 0;
if (!hmsVisible) if (!hmsVisible)
spellDx = weapDx = weapBoxBaseLeft - hmsBaseLeft; spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft;
if (!weapVisible) if (!weapVisible)
spellDx += spellBoxBaseLeft - weapBoxBaseLeft; spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft;
mWeaponVisible = weapVisible; mWeaponVisible = weapVisible;
mSpellVisible = spellVisible; mSpellVisible = spellVisible;
@ -215,10 +215,10 @@ void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellV
health->setVisible(hmsVisible); health->setVisible(hmsVisible);
stamina->setVisible(hmsVisible); stamina->setVisible(hmsVisible);
magicka->setVisible(hmsVisible); magicka->setVisible(hmsVisible);
weapBox->setPosition(weapBoxBaseLeft - weapDx, weapBox->getTop()); mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop());
weapBox->setVisible(weapVisible); mWeapBox->setVisible(weapVisible);
spellBox->setPosition(spellBoxBaseLeft - spellDx, spellBox->getTop()); mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop());
spellBox->setVisible(spellVisible); mSpellBox->setVisible(spellVisible);
} }
void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible) void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible)
@ -228,12 +228,12 @@ void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible
// effect box can have variable width -> variable left coordinate // effect box can have variable width -> variable left coordinate
int effectsDx = 0; int effectsDx = 0;
if (!minimapBoxVisible) if (!minimapBoxVisible)
effectsDx = (viewSize.width - minimapBoxBaseRight) - (viewSize.width - effectBoxBaseRight); effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
mMapVisible = minimapBoxVisible; mMapVisible = minimapBoxVisible;
minimapBox->setVisible(minimapBoxVisible); mMinimapBox->setVisible(minimapBoxVisible);
effectBox->setPosition((viewSize.width - effectBoxBaseRight) - effectBox->getWidth() + effectsDx, effectBox->getTop()); mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
effectBox->setVisible(effectBoxVisible); mEffectBox->setVisible(effectBoxVisible);
} }
void HUD::onWorldClicked(MyGUI::Widget* _sender) void HUD::onWorldClicked(MyGUI::Widget* _sender)
@ -395,14 +395,14 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
mWeaponSpellBox->setVisible(true); mWeaponSpellBox->setVisible(true);
} }
spellStatus->setProgressRange(100); mSpellStatus->setProgressRange(100);
spellStatus->setProgressPosition(successChancePercent); mSpellStatus->setProgressPosition(successChancePercent);
if (spellImage->getChildCount()) if (mSpellImage->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
spellBox->setUserString("ToolTipType", "Spell"); mSpellBox->setUserString("ToolTipType", "Spell");
spellBox->setUserString("Spell", spellId); mSpellBox->setUserString("Spell", spellId);
// use the icon of the first effect // use the icon of the first effect
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID); const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID);
@ -411,7 +411,7 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
icon.insert(slashPos+1, "b_"); icon.insert(slashPos+1, "b_");
icon = std::string("icons\\") + icon; icon = std::string("icons\\") + icon;
Widgets::fixTexturePath(icon); Widgets::fixTexturePath(icon);
spellImage->setImageTexture(icon); mSpellImage->setImageTexture(icon);
} }
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
@ -425,17 +425,17 @@ void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
mWeaponSpellBox->setVisible(true); mWeaponSpellBox->setVisible(true);
} }
spellStatus->setProgressRange(100); mSpellStatus->setProgressRange(100);
spellStatus->setProgressPosition(chargePercent); mSpellStatus->setProgressPosition(chargePercent);
if (spellImage->getChildCount()) if (mSpellImage->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
spellBox->setUserString("ToolTipType", "ItemPtr"); mSpellBox->setUserString("ToolTipType", "ItemPtr");
spellBox->setUserData(item); mSpellBox->setUserData(item);
spellImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); mSpellImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
MyGUI::ImageBox* itemBox = spellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1) MyGUI::ImageBox* itemBox = mSpellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
, MyGUI::Align::Stretch); , MyGUI::Align::Stretch);
std::string path = std::string("icons\\"); std::string path = std::string("icons\\");
@ -456,14 +456,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
mWeaponSpellBox->setVisible(true); mWeaponSpellBox->setVisible(true);
} }
weapBox->setUserString("ToolTipType", "ItemPtr"); mWeapBox->setUserString("ToolTipType", "ItemPtr");
weapBox->setUserData(item); mWeapBox->setUserData(item);
weapStatus->setProgressRange(100); mWeapStatus->setProgressRange(100);
weapStatus->setProgressPosition(durabilityPercent); mWeapStatus->setProgressPosition(durabilityPercent);
if (weapImage->getChildCount()) if (mWeapImage->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
std::string path = std::string("icons\\"); std::string path = std::string("icons\\");
path+=MWWorld::Class::get(item).getInventoryIcon(item); path+=MWWorld::Class::get(item).getInventoryIcon(item);
@ -471,14 +471,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
if (MWWorld::Class::get(item).getEnchantment(item) != "") if (MWWorld::Class::get(item).getEnchantment(item) != "")
{ {
weapImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
MyGUI::ImageBox* itemBox = weapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1) MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
, MyGUI::Align::Stretch); , MyGUI::Align::Stretch);
itemBox->setImageTexture(path); itemBox->setImageTexture(path);
itemBox->setNeedMouseFocus(false); itemBox->setNeedMouseFocus(false);
} }
else else
weapImage->setImageTexture(path); mWeapImage->setImageTexture(path);
} }
void HUD::unsetSelectedSpell() void HUD::unsetSelectedSpell()
@ -492,12 +492,12 @@ void HUD::unsetSelectedSpell()
mWeaponSpellBox->setVisible(true); mWeaponSpellBox->setVisible(true);
} }
if (spellImage->getChildCount()) if (mSpellImage->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
spellStatus->setProgressRange(100); mSpellStatus->setProgressRange(100);
spellStatus->setProgressPosition(0); mSpellStatus->setProgressPosition(0);
spellImage->setImageTexture(""); mSpellImage->setImageTexture("");
spellBox->clearUserStrings(); mSpellBox->clearUserStrings();
} }
void HUD::unsetSelectedWeapon() void HUD::unsetSelectedWeapon()
@ -511,10 +511,10 @@ void HUD::unsetSelectedWeapon()
mWeaponSpellBox->setVisible(true); mWeaponSpellBox->setVisible(true);
} }
if (weapImage->getChildCount()) if (mWeapImage->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
weapStatus->setProgressRange(100); mWeapStatus->setProgressRange(100);
weapStatus->setProgressPosition(0); mWeapStatus->setProgressPosition(0);
weapImage->setImageTexture("icons\\k\\stealth_handtohand.dds"); mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
weapBox->clearUserStrings(); mWeapBox->clearUserStrings();
} }

@ -37,14 +37,14 @@ namespace MWGui
MyGUI::ProgressPtr health, magicka, stamina; MyGUI::ProgressPtr health, magicka, stamina;
MyGUI::Widget* mHealthFrame; MyGUI::Widget* mHealthFrame;
MyGUI::Widget *weapBox, *spellBox; MyGUI::Widget *mWeapBox, *mSpellBox;
MyGUI::ImageBox *weapImage, *spellImage; MyGUI::ImageBox *mWeapImage, *mSpellImage;
MyGUI::ProgressPtr weapStatus, spellStatus; MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
MyGUI::Widget *effectBox, *minimapBox; MyGUI::Widget *mEffectBox, *mMinimapBox;
MyGUI::ImageBox* effect1; MyGUI::ImageBox* mEffect1;
MyGUI::ScrollView* minimap; MyGUI::ScrollView* mMinimap;
MyGUI::ImageBox* compass; MyGUI::ImageBox* mCompass;
MyGUI::ImageBox* crosshair; MyGUI::ImageBox* mCrosshair;
MyGUI::TextBox* mCellNameBox; MyGUI::TextBox* mCellNameBox;
MyGUI::TextBox* mWeaponSpellBox; MyGUI::TextBox* mWeaponSpellBox;
@ -55,9 +55,9 @@ namespace MWGui
private: private:
// bottom left elements // bottom left elements
int hmsBaseLeft, weapBoxBaseLeft, spellBoxBaseLeft; int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft;
// bottom right elements // bottom right elements
int minimapBoxBaseRight, effectBoxBaseRight; int mMinimapBoxBaseRight, mEffectBoxBaseRight;
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;

@ -175,7 +175,7 @@ namespace MWGui
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr); boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
action->execute(); action->execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
// this is necessary for books/scrolls: if they are already in the player's inventory, // this is necessary for books/scrolls: if they are already in the player's inventory,
// the "Take" button should not be visible. // the "Take" button should not be visible.

@ -84,7 +84,7 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize)
MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
: WindowBase("openmw_journal.layout", parWindowManager) : WindowBase("openmw_journal.layout", parWindowManager)
, lastPos(0) , mLastPos(0)
, mVisible(false) , mVisible(false)
{ {
//setCoord(0,0,498, 342); //setCoord(0,0,498, 342);
@ -148,19 +148,19 @@ void MWGui::JournalWindow::open()
{ {
if(left) if(left)
{ {
leftPages.push_back(*it); mLeftPages.push_back(*it);
} }
else else
{ {
rightPages.push_back(*it); mRightPages.push_back(*it);
} }
left = !left; left = !left;
} }
if(!left) rightPages.push_back(""); if(!left) mRightPages.push_back("");
mPageNumber = leftPages.size()-1; mPageNumber = mLeftPages.size()-1;
displayLeftText(leftPages[mPageNumber]); displayLeftText(mLeftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]); displayRightText(mRightPages[mPageNumber]);
} }
else else
@ -184,13 +184,13 @@ void MWGui::JournalWindow::displayRightText(std::string text)
void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender) void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
{ {
if(mPageNumber < int(leftPages.size())-1) if(mPageNumber < int(mLeftPages.size())-1)
{ {
std::string nextSound = "book page2"; std::string nextSound = "book page2";
MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0);
mPageNumber = mPageNumber + 1; mPageNumber = mPageNumber + 1;
displayLeftText(leftPages[mPageNumber]); displayLeftText(mLeftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]); displayRightText(mRightPages[mPageNumber]);
} }
} }
@ -201,7 +201,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
std::string prevSound = "book page"; std::string prevSound = "book page";
MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0);
mPageNumber = mPageNumber - 1; mPageNumber = mPageNumber - 1;
displayLeftText(leftPages[mPageNumber]); displayLeftText(mLeftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]); displayRightText(mRightPages[mPageNumber]);
} }
} }

@ -31,17 +31,17 @@ namespace MWGui
void notifyNextPage(MyGUI::WidgetPtr _sender); void notifyNextPage(MyGUI::WidgetPtr _sender);
void notifyPrevPage(MyGUI::WidgetPtr _sender); void notifyPrevPage(MyGUI::WidgetPtr _sender);
static const int lineHeight; static const int sLineHeight;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget;
MyGUI::ScrollBar* skillScrollerWidget; MyGUI::ScrollBar* mSkillScrollerWidget;
int lastPos, clientHeight; int mLastPos, mClientHeight;
MyGUI::EditPtr mLeftTextWidget; MyGUI::EditPtr mLeftTextWidget;
MyGUI::EditPtr mRightTextWidget; MyGUI::EditPtr mRightTextWidget;
MyGUI::ButtonPtr mPrevBtn; MyGUI::ButtonPtr mPrevBtn;
MyGUI::ButtonPtr mNextBtn; MyGUI::ButtonPtr mNextBtn;
std::vector<std::string> leftPages; std::vector<std::string> mLeftPages;
std::vector<std::string> rightPages; std::vector<std::string> mRightPages;
int mPageNumber; //store the number of the current left page int mPageNumber; //store the number of the current left page
bool mVisible; bool mVisible;
}; };

@ -149,7 +149,7 @@ int MessageBoxManager::readPressedButton ()
MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message)
: Layout("openmw_messagebox.layout") : Layout("openmw_messagebox.layout")
, mMessageBoxManager(parMessageBoxManager) , mMessageBoxManager(parMessageBoxManager)
, cMessage(message) , mMessage(message)
{ {
// defines // defines
mFixedWidth = 300; mFixedWidth = 300;
@ -160,7 +160,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
getWidget(mMessageWidget, "message"); getWidget(mMessageWidget, "message");
mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setOverflowToTheLeft(true);
mMessageWidget->setCaptionWithReplacing(cMessage); mMessageWidget->setCaptionWithReplacing(mMessage);
MyGUI::IntSize size; MyGUI::IntSize size;
size.width = mFixedWidth; size.width = mFixedWidth;

@ -59,7 +59,7 @@ namespace MWGui
protected: protected:
MessageBoxManager& mMessageBoxManager; MessageBoxManager& mMessageBoxManager;
int mHeight; int mHeight;
const std::string& cMessage; const std::string& mMessage;
MyGUI::EditPtr mMessageWidget; MyGUI::EditPtr mMessageWidget;
int mFixedWidth; int mFixedWidth;
int mBottomPadding; int mBottomPadding;

@ -1,6 +1,5 @@
#include "race.hpp" #include "race.hpp"
#include <assert.h>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
@ -18,11 +17,11 @@ using namespace Widgets;
RaceDialog::RaceDialog(WindowManager& parWindowManager) RaceDialog::RaceDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_race.layout", parWindowManager) : WindowBase("openmw_chargen_race.layout", parWindowManager)
, genderIndex(0) , mGenderIndex(0)
, faceIndex(0) , mFaceIndex(0)
, hairIndex(0) , mHairIndex(0)
, faceCount(10) , mFaceCount(10)
, hairCount(14) , mHairCount(14)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -31,13 +30,13 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
// real calls from outside the class later. // real calls from outside the class later.
setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance")); setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance"));
getWidget(appearanceBox, "AppearanceBox"); getWidget(mAppearanceBox, "AppearanceBox");
getWidget(headRotate, "HeadRotate"); getWidget(mHeadRotate, "HeadRotate");
headRotate->setScrollRange(50); mHeadRotate->setScrollRange(50);
headRotate->setScrollPosition(20); mHeadRotate->setScrollPosition(20);
headRotate->setScrollViewPage(10); mHeadRotate->setScrollViewPage(10);
headRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
// Set up next/previous buttons // Set up next/previous buttons
MyGUI::ButtonPtr prevButton, nextButton; MyGUI::ButtonPtr prevButton, nextButton;
@ -61,16 +60,16 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race")); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race"));
getWidget(raceList, "RaceList"); getWidget(mRaceList, "RaceList");
raceList->setScrollVisible(true); mRaceList->setScrollVisible(true);
raceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); mRaceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); mRaceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); mRaceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus")); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
getWidget(skillList, "SkillList"); getWidget(mSkillList, "SkillList");
setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials")); setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials"));
getWidget(spellPowerList, "SpellPowerList"); getWidget(mSpellPowerList, "SpellPowerList");
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
@ -117,14 +116,14 @@ void RaceDialog::open()
void RaceDialog::setRaceId(const std::string &raceId) void RaceDialog::setRaceId(const std::string &raceId)
{ {
currentRaceId = raceId; mCurrentRaceId = raceId;
raceList->setIndexSelected(MyGUI::ITEM_NONE); mRaceList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = raceList->getItemCount(); size_t count = mRaceList->getItemCount();
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
{ {
if (boost::iequals(*raceList->getItemDataAt<std::string>(i), raceId)) if (boost::iequals(*mRaceList->getItemDataAt<std::string>(i), raceId))
{ {
raceList->setIndexSelected(i); mRaceList->setIndexSelected(i);
break; break;
} }
} }
@ -162,32 +161,32 @@ void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position)
void RaceDialog::onSelectPreviousGender(MyGUI::Widget*) void RaceDialog::onSelectPreviousGender(MyGUI::Widget*)
{ {
genderIndex = wrap(genderIndex - 1, 2); mGenderIndex = wrap(mGenderIndex - 1, 2);
} }
void RaceDialog::onSelectNextGender(MyGUI::Widget*) void RaceDialog::onSelectNextGender(MyGUI::Widget*)
{ {
genderIndex = wrap(genderIndex + 1, 2); mGenderIndex = wrap(mGenderIndex + 1, 2);
} }
void RaceDialog::onSelectPreviousFace(MyGUI::Widget*) void RaceDialog::onSelectPreviousFace(MyGUI::Widget*)
{ {
faceIndex = wrap(faceIndex - 1, faceCount); mFaceIndex = wrap(mFaceIndex - 1, mFaceCount);
} }
void RaceDialog::onSelectNextFace(MyGUI::Widget*) void RaceDialog::onSelectNextFace(MyGUI::Widget*)
{ {
faceIndex = wrap(faceIndex + 1, faceCount); mFaceIndex = wrap(mFaceIndex + 1, mFaceCount);
} }
void RaceDialog::onSelectPreviousHair(MyGUI::Widget*) void RaceDialog::onSelectPreviousHair(MyGUI::Widget*)
{ {
hairIndex = wrap(hairIndex - 1, hairCount); mHairIndex = wrap(mHairIndex - 1, mHairCount);
} }
void RaceDialog::onSelectNextHair(MyGUI::Widget*) void RaceDialog::onSelectNextHair(MyGUI::Widget*)
{ {
hairIndex = wrap(hairIndex - 1, hairCount); mHairIndex = wrap(mHairIndex - 1, mHairCount);
} }
void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
@ -195,11 +194,11 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
const std::string *raceId = raceList->getItemDataAt<std::string>(_index); const std::string *raceId = mRaceList->getItemDataAt<std::string>(_index);
if (boost::iequals(currentRaceId, *raceId)) if (boost::iequals(mCurrentRaceId, *raceId))
return; return;
currentRaceId = *raceId; mCurrentRaceId = *raceId;
updateSkills(); updateSkills();
updateSpellPowers(); updateSpellPowers();
} }
@ -208,7 +207,7 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
void RaceDialog::updateRaces() void RaceDialog::updateRaces()
{ {
raceList->removeAllItems(); mRaceList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
@ -222,30 +221,30 @@ void RaceDialog::updateRaces()
if (!playable) // Only display playable races if (!playable) // Only display playable races
continue; continue;
raceList->addItem(race.name, it->first); mRaceList->addItem(race.name, it->first);
if (boost::iequals(it->first, currentRaceId)) if (boost::iequals(it->first, mCurrentRaceId))
raceList->setIndexSelected(index); mRaceList->setIndexSelected(index);
++index; ++index;
} }
} }
void RaceDialog::updateSkills() void RaceDialog::updateSkills()
{ {
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillItems.begin(); it != skillItems.end(); ++it) for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
skillItems.clear(); mSkillItems.clear();
if (currentRaceId.empty()) if (mCurrentRaceId.empty())
return; return;
MWSkillPtr skillWidget; MWSkillPtr skillWidget;
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18); MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::Race *race = store.races.find(currentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
@ -253,7 +252,7 @@ void RaceDialog::updateSkills()
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
continue; continue;
skillWidget = skillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default, skillWidget = mSkillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
std::string("Skill") + boost::lexical_cast<std::string>(i)); std::string("Skill") + boost::lexical_cast<std::string>(i));
skillWidget->setWindowManager(&mWindowManager); skillWidget->setWindowManager(&mWindowManager);
skillWidget->setSkillNumber(skillId); skillWidget->setSkillNumber(skillId);
@ -261,7 +260,7 @@ void RaceDialog::updateSkills()
ToolTips::createSkillToolTip(skillWidget, skillId); ToolTips::createSkillToolTip(skillWidget, skillId);
skillItems.push_back(skillWidget); mSkillItems.push_back(skillWidget);
coord1.top += lineHeight; coord1.top += lineHeight;
} }
@ -269,34 +268,34 @@ void RaceDialog::updateSkills()
void RaceDialog::updateSpellPowers() void RaceDialog::updateSpellPowers()
{ {
for (std::vector<MyGUI::WidgetPtr>::iterator it = spellPowerItems.begin(); it != spellPowerItems.end(); ++it) for (std::vector<MyGUI::WidgetPtr>::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
spellPowerItems.clear(); mSpellPowerItems.clear();
if (currentRaceId.empty()) if (mCurrentRaceId.empty())
return; return;
MWSpellPtr spellPowerWidget; MWSpellPtr spellPowerWidget;
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::Race *race = store.races.find(currentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->powers.list.begin(); std::vector<std::string>::const_iterator it = race->powers.list.begin();
std::vector<std::string>::const_iterator end = race->powers.list.end(); std::vector<std::string>::const_iterator end = race->powers.list.end();
for (int i = 0; it != end; ++it) for (int i = 0; it != end; ++it)
{ {
const std::string &spellpower = *it; const std::string &spellpower = *it;
spellPowerWidget = spellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i)); spellPowerWidget = mSpellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i));
spellPowerWidget->setWindowManager(&mWindowManager); spellPowerWidget->setWindowManager(&mWindowManager);
spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setSpellId(spellpower);
spellPowerWidget->setUserString("ToolTipType", "Spell"); spellPowerWidget->setUserString("ToolTipType", "Spell");
spellPowerWidget->setUserString("Spell", spellpower); spellPowerWidget->setUserString("Spell", spellpower);
spellPowerItems.push_back(spellPowerWidget); mSpellPowerItems.push_back(spellPowerWidget);
coord.top += lineHeight; coord.top += lineHeight;
++i; ++i;

@ -32,13 +32,13 @@ namespace MWGui
GM_Female GM_Female
}; };
const std::string &getRaceId() const { return currentRaceId; } const std::string &getRaceId() const { return mCurrentRaceId; }
Gender getGender() const { return genderIndex == 0 ? GM_Male : GM_Female; } Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; }
// getFace() // getFace()
// getHair() // getHair()
void setRaceId(const std::string &raceId); void setRaceId(const std::string &raceId);
void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; } void setGender(Gender gender) { mGenderIndex = gender == GM_Male ? 0 : 1; }
// setFace() // setFace()
// setHair() // setHair()
@ -75,20 +75,20 @@ namespace MWGui
void updateSkills(); void updateSkills();
void updateSpellPowers(); void updateSpellPowers();
MyGUI::CanvasPtr appearanceBox; MyGUI::CanvasPtr mAppearanceBox;
MyGUI::ListBox* raceList; MyGUI::ListBox* mRaceList;
MyGUI::ScrollBar* headRotate; MyGUI::ScrollBar* mHeadRotate;
MyGUI::WidgetPtr skillList; MyGUI::WidgetPtr mSkillList;
std::vector<MyGUI::WidgetPtr> skillItems; std::vector<MyGUI::WidgetPtr> mSkillItems;
MyGUI::WidgetPtr spellPowerList; MyGUI::WidgetPtr mSpellPowerList;
std::vector<MyGUI::WidgetPtr> spellPowerItems; std::vector<MyGUI::WidgetPtr> mSpellPowerItems;
int genderIndex, faceIndex, hairIndex; int mGenderIndex, mFaceIndex, mHairIndex;
int faceCount, hairCount; int mFaceCount, mHairCount;
std::string currentRaceId; std::string mCurrentRaceId;
}; };
} }
#endif #endif

@ -17,49 +17,49 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
const int ReviewDialog::lineHeight = 18; const int ReviewDialog::sLineHeight = 18;
ReviewDialog::ReviewDialog(WindowManager& parWindowManager) ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_review.layout", parWindowManager) : WindowBase("openmw_chargen_review.layout", parWindowManager)
, lastPos(0) , mLastPos(0)
{ {
// Centre dialog // Centre dialog
center(); center();
// Setup static stats // Setup static stats
ButtonPtr button; ButtonPtr button;
getWidget(nameWidget, "NameText"); getWidget(mNameWidget, "NameText");
getWidget(button, "NameButton"); getWidget(button, "NameButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
getWidget(raceWidget, "RaceText"); getWidget(mRaceWidget, "RaceText");
getWidget(button, "RaceButton"); getWidget(button, "RaceButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
getWidget(classWidget, "ClassText"); getWidget(mClassWidget, "ClassText");
getWidget(button, "ClassButton"); getWidget(button, "ClassButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
getWidget(birthSignWidget, "SignText"); getWidget(mBirthSignWidget, "SignText");
getWidget(button, "SignButton"); getWidget(button, "SignButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
// Setup dynamic stats // Setup dynamic stats
getWidget(health, "Health"); getWidget(mHealth, "Health");
health->setTitle(mWindowManager.getGameSettingString("sHealth", "")); mHealth->setTitle(mWindowManager.getGameSettingString("sHealth", ""));
health->setValue(45, 45); mHealth->setValue(45, 45);
getWidget(magicka, "Magicka"); getWidget(mMagicka, "Magicka");
magicka->setTitle(mWindowManager.getGameSettingString("sMagic", "")); mMagicka->setTitle(mWindowManager.getGameSettingString("sMagic", ""));
magicka->setValue(50, 50); mMagicka->setValue(50, 50);
getWidget(fatigue, "Fatigue"); getWidget(mFatigue, "Fatigue");
fatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", "")); mFatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", ""));
fatigue->setValue(160, 160); mFatigue->setValue(160, 160);
// Setup attributes // Setup attributes
@ -67,24 +67,24 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
for (int idx = 0; idx < ESM::Attribute::Length; ++idx) for (int idx = 0; idx < ESM::Attribute::Length; ++idx)
{ {
getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx)); getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx));
attributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute)); mAttributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute));
attribute->setWindowManager(&mWindowManager); attribute->setWindowManager(&mWindowManager);
attribute->setAttributeId(ESM::Attribute::attributeIds[idx]); attribute->setAttributeId(ESM::Attribute::attributeIds[idx]);
attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0)); attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0));
} }
// Setup skills // Setup skills
getWidget(skillAreaWidget, "Skills"); getWidget(mSkillAreaWidget, "Skills");
getWidget(skillClientWidget, "SkillClient"); getWidget(mSkillClientWidget, "SkillClient");
getWidget(skillScrollerWidget, "SkillScroller"); getWidget(mSkillScrollerWidget, "SkillScroller");
skillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition);
updateScroller(); updateScroller();
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
{ {
skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>())); mSkillValues.insert(std::make_pair(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::TextBox*> (0))); mSkillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::TextBox*> (0)));
} }
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);
@ -112,14 +112,14 @@ void ReviewDialog::open()
void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
{ {
int diff = lastPos - pos; int diff = mLastPos - pos;
// Adjust position of all widget according to difference // Adjust position of all widget according to difference
if (diff == 0) if (diff == 0)
return; return;
lastPos = pos; mLastPos = pos;
std::vector<MyGUI::WidgetPtr>::const_iterator end = skillWidgets.end(); std::vector<MyGUI::WidgetPtr>::const_iterator end = mSkillWidgets.end();
for (std::vector<MyGUI::WidgetPtr>::const_iterator it = skillWidgets.begin(); it != end; ++it) for (std::vector<MyGUI::WidgetPtr>::const_iterator it = mSkillWidgets.begin(); it != end; ++it)
{ {
(*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff)); (*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff));
} }
@ -132,63 +132,63 @@ void ReviewDialog::onWindowResize(MyGUI::Window* window)
void ReviewDialog::setPlayerName(const std::string &name) void ReviewDialog::setPlayerName(const std::string &name)
{ {
nameWidget->setCaption(name); mNameWidget->setCaption(name);
} }
void ReviewDialog::setRace(const std::string &raceId_) void ReviewDialog::setRace(const std::string &raceId)
{ {
raceId = raceId_; mRaceId = raceId;
const ESM::Race *race = mWindowManager.getStore().races.search(raceId); const ESM::Race *race = mWindowManager.getStore().races.search(mRaceId);
if (race) if (race)
{ {
ToolTips::createRaceToolTip(raceWidget, race); ToolTips::createRaceToolTip(mRaceWidget, race);
raceWidget->setCaption(race->name); mRaceWidget->setCaption(race->name);
} }
} }
void ReviewDialog::setClass(const ESM::Class& class_) void ReviewDialog::setClass(const ESM::Class& class_)
{ {
klass = class_; mKlass = class_;
classWidget->setCaption(klass.name); mClassWidget->setCaption(mKlass.name);
ToolTips::createClassToolTip(classWidget, klass); ToolTips::createClassToolTip(mClassWidget, mKlass);
} }
void ReviewDialog::setBirthSign(const std::string& signId) void ReviewDialog::setBirthSign(const std::string& signId)
{ {
birthSignId = signId; mBirthSignId = signId;
const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(birthSignId); const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(mBirthSignId);
if (sign) if (sign)
{ {
birthSignWidget->setCaption(sign->name); mBirthSignWidget->setCaption(sign->name);
ToolTips::createBirthsignToolTip(birthSignWidget, birthSignId); ToolTips::createBirthsignToolTip(mBirthSignWidget, mBirthSignId);
} }
} }
void ReviewDialog::setHealth(const MWMechanics::DynamicStat<int>& value) void ReviewDialog::setHealth(const MWMechanics::DynamicStat<int>& value)
{ {
health->setValue(value.getCurrent(), value.getModified()); mHealth->setValue(value.getCurrent(), value.getModified());
std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified()); std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
health->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); mHealth->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
} }
void ReviewDialog::setMagicka(const MWMechanics::DynamicStat<int>& value) void ReviewDialog::setMagicka(const MWMechanics::DynamicStat<int>& value)
{ {
magicka->setValue(value.getCurrent(), value.getModified()); mMagicka->setValue(value.getCurrent(), value.getModified());
std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified()); std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
magicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); mMagicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
} }
void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<int>& value) void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<int>& value)
{ {
fatigue->setValue(value.getCurrent(), value.getModified()); mFatigue->setValue(value.getCurrent(), value.getModified());
std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified()); std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
fatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); mFatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
} }
void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const MWMechanics::Stat<int>& value) void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const MWMechanics::Stat<int>& value)
{ {
std::map<int, MWAttributePtr>::iterator attr = attributeWidgets.find(static_cast<int>(attributeId)); std::map<int, MWAttributePtr>::iterator attr = mAttributeWidgets.find(static_cast<int>(attributeId));
if (attr == attributeWidgets.end()) if (attr == mAttributeWidgets.end())
return; return;
attr->second->setAttributeValue(value); attr->second->setAttributeValue(value);
@ -196,8 +196,8 @@ void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const M
void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value) void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value)
{ {
skillValues[skillId] = value; mSkillValues[skillId] = value;
MyGUI::TextBox* widget = skillWidgetMap[skillId]; MyGUI::TextBox* widget = mSkillWidgetMap[skillId];
if (widget) if (widget)
{ {
float modified = value.getModified(), base = value.getBase(); float modified = value.getModified(), base = value.getBase();
@ -216,20 +216,20 @@ void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanic
void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vector<int>& minor) void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vector<int>& minor)
{ {
majorSkills = major; mMajorSkills = major;
minorSkills = minor; mMinorSkills = minor;
// Update misc skills with the remaining skills not in major or minor // Update misc skills with the remaining skills not in major or minor
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::skillIds.end(); boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::skillIds.end();
miscSkills.clear(); mMiscSkills.clear();
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it)
{ {
int skill = *it; int skill = *it;
if (skillSet.find(skill) == skillSet.end()) if (skillSet.find(skill) == skillSet.end())
miscSkills.push_back(skill); mMiscSkills.push_back(skill);
} }
updateSkillArea(); updateSkillArea();
@ -237,10 +237,10 @@ void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vec
void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::ImageBox* separator = skillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); MyGUI::ImageBox* separator = mSkillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default);
separator->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); separator->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillWidgets.push_back(separator); mSkillWidgets.push_back(separator);
coord1.top += separator->getHeight(); coord1.top += separator->getHeight();
coord2.top += separator->getHeight(); coord2.top += separator->getHeight();
@ -248,13 +248,13 @@ void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2
void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::TextBox* groupWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
groupWidget->setCaption(label); groupWidget->setCaption(label);
skillWidgets.push_back(groupWidget); mSkillWidgets.push_back(groupWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
} }
MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
@ -262,20 +262,20 @@ MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::s
MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillNameWidget;
MyGUI::TextBox* skillValueWidget; MyGUI::TextBox* skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default); skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right); skillValueWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right);
skillValueWidget->setCaption(value); skillValueWidget->setCaption(value);
skillValueWidget->_setWidgetState(state); skillValueWidget->_setWidgetState(state);
skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
skillWidgets.push_back(skillValueWidget); mSkillWidgets.push_back(skillValueWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
return skillValueWidget; return skillValueWidget;
} }
@ -284,20 +284,20 @@ void ReviewDialog::addItem(const std::string& text, MyGUI::IntCoord &coord1, MyG
{ {
MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillNameWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
} }
void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!mSkillWidgets.empty())
{ {
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
} }
@ -312,7 +312,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
continue; continue;
assert(skillId >= 0 && skillId < ESM::Skill::Length); assert(skillId >= 0 && skillId < ESM::Skill::Length);
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId];
const MWMechanics::Stat<float> &stat = skillValues.find(skillId)->second; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second;
float base = stat.getBase(); float base = stat.getBase();
float modified = stat.getModified(); float modified = stat.getModified();
@ -325,44 +325,44 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
ToolTips::createSkillToolTip(skillWidgets[skillWidgets.size()-1-i], skillId); ToolTips::createSkillToolTip(mSkillWidgets[mSkillWidgets.size()-1-i], skillId);
} }
skillWidgetMap[skillId] = widget; mSkillWidgetMap[skillId] = widget;
} }
} }
void ReviewDialog::updateSkillArea() void ReviewDialog::updateSkillArea()
{ {
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it) for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
skillWidgets.clear(); mSkillWidgets.clear();
const int valueSize = 40; const int valueSize = 40;
MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18); MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18);
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height); MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
if (!majorSkills.empty()) if (!mMajorSkills.empty())
addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
if (!minorSkills.empty()) if (!mMinorSkills.empty())
addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
if (!miscSkills.empty()) if (!mMiscSkills.empty())
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
clientHeight = coord1.top; mClientHeight = coord1.top;
updateScroller(); updateScroller();
} }
void ReviewDialog::updateScroller() void ReviewDialog::updateScroller()
{ {
skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0));
skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0));
if (clientHeight != 0) if (mClientHeight != 0)
skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillScrollerWidget->getLineSize() ); mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() );
} }
// widget controls // widget controls
@ -399,12 +399,12 @@ void ReviewDialog::onBirthSignClicked(MyGUI::Widget* _sender)
void ReviewDialog::onMouseWheel(MyGUI::Widget* _sender, int _rel) void ReviewDialog::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (skillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0)
skillScrollerWidget->setScrollPosition(0); mSkillScrollerWidget->setScrollPosition(0);
else if (skillScrollerWidget->getScrollPosition() - _rel*0.3 > skillScrollerWidget->getScrollRange()-1) else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1)
skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollRange()-1); mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1);
else else
skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollPosition() - _rel*0.3); mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3);
onScrollChangePosition(skillScrollerWidget, skillScrollerWidget->getScrollPosition()); onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition());
} }

@ -82,23 +82,23 @@ namespace MWGui
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
static const int lineHeight; static const int sLineHeight;
MyGUI::TextBox *nameWidget, *raceWidget, *classWidget, *birthSignWidget; MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget;
MyGUI::ScrollBar* skillScrollerWidget; MyGUI::ScrollBar* mSkillScrollerWidget;
int lastPos, clientHeight; int mLastPos, mClientHeight;
Widgets::MWDynamicStatPtr health, magicka, fatigue; Widgets::MWDynamicStatPtr mHealth, mMagicka, mFatigue;
std::map<int, Widgets::MWAttributePtr> attributeWidgets; std::map<int, Widgets::MWAttributePtr> mAttributeWidgets;
SkillList majorSkills, minorSkills, miscSkills; SkillList mMajorSkills, mMinorSkills, mMiscSkills;
std::map<int, MWMechanics::Stat<float> > skillValues; std::map<int, MWMechanics::Stat<float> > mSkillValues;
std::map<int, MyGUI::TextBox*> skillWidgetMap; std::map<int, MyGUI::TextBox*> mSkillWidgetMap;
std::string name, raceId, birthSignId; std::string mName, mRaceId, mBirthSignId;
ESM::Class klass; ESM::Class mKlass;
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information std::vector<MyGUI::WidgetPtr> mSkillWidgets; //< Skills and other information
}; };
} }
#endif #endif

@ -1,8 +1,10 @@
#include "scrollwindow.hpp" #include "scrollwindow.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "formatting.hpp" #include "formatting.hpp"
@ -63,7 +65,7 @@ void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack); MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack);
MWWorld::ActionTake take(mScroll); MWWorld::ActionTake take(mScroll);
take.execute(); take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
mWindowManager.removeGuiMode(GM_Scroll); mWindowManager.removeGuiMode(GM_Scroll);
} }

@ -74,6 +74,11 @@ namespace
return "16 : 10"; return "16 : 10";
return boost::lexical_cast<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(yaspect); return boost::lexical_cast<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(yaspect);
} }
std::string hlslGlsl ()
{
return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl";
}
} }
namespace MWGui namespace MWGui
@ -103,8 +108,19 @@ namespace MWGui
getWidget(mReflectObjectsButton, "ReflectObjectsButton"); getWidget(mReflectObjectsButton, "ReflectObjectsButton");
getWidget(mReflectActorsButton, "ReflectActorsButton"); getWidget(mReflectActorsButton, "ReflectActorsButton");
getWidget(mReflectTerrainButton, "ReflectTerrainButton"); getWidget(mReflectTerrainButton, "ReflectTerrainButton");
getWidget(mShadersButton, "ShadersButton");
getWidget(mShadowsEnabledButton, "ShadowsEnabledButton");
getWidget(mShadowsLargeDistance, "ShadowsLargeDistance");
getWidget(mShadowsTextureSize, "ShadowsTextureSize");
getWidget(mActorShadows, "ActorShadows");
getWidget(mStaticsShadows, "StaticsShadows");
getWidget(mMiscShadows, "MiscShadows");
getWidget(mShadowsDebug, "ShadowsDebug");
getWidget(mUnderwaterButton, "UnderwaterButton");
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mWaterShaderButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mWaterShaderButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mReflectObjectsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mReflectObjectsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
@ -120,6 +136,14 @@ namespace MWGui
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected); mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
mAnisotropySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mAnisotropySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mShadowsEnabledButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadowsLargeDistance->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadowsTextureSize->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadowTextureSize);
mActorShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mStaticsShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mMiscShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadowsDebug->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mMasterVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mMasterVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mVoiceVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mVoiceVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mEffectsVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mEffectsVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
@ -172,7 +196,6 @@ namespace MWGui
std::string tf = Settings::Manager::getString("texture filtering", "General"); std::string tf = Settings::Manager::getString("texture filtering", "General");
mTextureFilteringButton->setCaption(textureFilteringToStr(tf)); mTextureFilteringButton->setCaption(textureFilteringToStr(tf));
mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(Settings::Manager::getInt("anisotropy", "General")) + ")"); mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(Settings::Manager::getInt("anisotropy", "General")) + ")");
mAnisotropyBox->setVisible(tf == "anisotropic");
float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-sViewDistMin)/(sViewDistMax-sViewDistMin); float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-sViewDistMin)/(sViewDistMax-sViewDistMin);
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val; int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
@ -185,9 +208,27 @@ namespace MWGui
mVoiceVolumeSlider->setScrollPosition(Settings::Manager::getFloat("voice volume", "Sound") * (mVoiceVolumeSlider->getScrollRange()-1)); mVoiceVolumeSlider->setScrollPosition(Settings::Manager::getFloat("voice volume", "Sound") * (mVoiceVolumeSlider->getScrollRange()-1));
mWaterShaderButton->setCaptionWithReplacing(Settings::Manager::getBool("shader", "Water") ? "#{sOn}" : "#{sOff}"); mWaterShaderButton->setCaptionWithReplacing(Settings::Manager::getBool("shader", "Water") ? "#{sOn}" : "#{sOff}");
mReflectObjectsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect objects", "Water") ? "#{sOn}" : "#{sOff}"); mReflectObjectsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect statics", "Water") ? "#{sOn}" : "#{sOff}");
mReflectActorsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect actors", "Water") ? "#{sOn}" : "#{sOff}"); mReflectActorsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect actors", "Water") ? "#{sOn}" : "#{sOff}");
mReflectTerrainButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect terrain", "Water") ? "#{sOn}" : "#{sOff}"); mReflectTerrainButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect terrain", "Water") ? "#{sOn}" : "#{sOff}");
mUnderwaterButton->setCaptionWithReplacing(Settings::Manager::getBool("underwater effect", "Water") ? "#{sOn}" : "#{sOff}");
mShadowsTextureSize->setCaption (Settings::Manager::getString ("texture size", "Shadows"));
mShadowsLargeDistance->setCaptionWithReplacing(Settings::Manager::getBool("split", "Shadows") ? "#{sOn}" : "#{sOff}");
mShadowsEnabledButton->setCaptionWithReplacing(Settings::Manager::getBool("enabled", "Shadows") ? "#{sOn}" : "#{sOff}");
mActorShadows->setCaptionWithReplacing(Settings::Manager::getBool("actor shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
mStaticsShadows->setCaptionWithReplacing(Settings::Manager::getBool("statics shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "Shadows") ? "#{sOn}" : "#{sOff}");
std::string shaders;
if (!Settings::Manager::getBool("shaders", "Objects"))
shaders = "off";
else
{
shaders = Settings::Manager::getString("shader mode", "General");
}
mShadersButton->setCaption (shaders);
if (!MWRender::RenderingManager::waterShaderSupported()) if (!MWRender::RenderingManager::waterShaderSupported())
{ {
@ -197,6 +238,12 @@ namespace MWGui
mReflectTerrainButton->setEnabled(false); mReflectTerrainButton->setEnabled(false);
} }
if (shaders == "off")
{
mUnderwaterButton->setEnabled (false);
mShadowsEnabledButton->setEnabled(false);
}
mFullscreenButton->setCaptionWithReplacing(Settings::Manager::getBool("fullscreen", "Video") ? "#{sOn}" : "#{sOff}"); mFullscreenButton->setCaptionWithReplacing(Settings::Manager::getBool("fullscreen", "Video") ? "#{sOn}" : "#{sOff}");
mVSyncButton->setCaptionWithReplacing(Settings::Manager::getBool("vsync", "Video") ? "#{sOn}": "#{sOff}"); mVSyncButton->setCaptionWithReplacing(Settings::Manager::getBool("vsync", "Video") ? "#{sOn}": "#{sOff}");
mFPSButton->setCaptionWithReplacing(fpsLevelToStr(Settings::Manager::getInt("fps", "HUD"))); mFPSButton->setCaptionWithReplacing(fpsLevelToStr(Settings::Manager::getInt("fps", "HUD")));
@ -237,6 +284,25 @@ namespace MWGui
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE); mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
} }
void SettingsWindow::onShadowTextureSize(MyGUI::Widget* _sender)
{
std::string size = mShadowsTextureSize->getCaption();
if (size == "512")
size = "1024";
else if (size == "1024")
size = "2048";
else if (size == "2048")
size = "4096";
else
size = "512";
mShadowsTextureSize->setCaption(size);
Settings::Manager::setString("texture size", "Shadows", size);
apply();
}
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender) void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
{ {
std::string on = mWindowManager.getGameSettingString("sOn", "On"); std::string on = mWindowManager.getGameSettingString("sOn", "On");
@ -291,6 +357,10 @@ namespace MWGui
{ {
if (_sender == mWaterShaderButton) if (_sender == mWaterShaderButton)
Settings::Manager::setBool("shader", "Water", newState); Settings::Manager::setBool("shader", "Water", newState);
else if (_sender == mUnderwaterButton)
{
Settings::Manager::setBool("underwater effect", "Water", newState);
}
else if (_sender == mReflectObjectsButton) else if (_sender == mReflectObjectsButton)
{ {
Settings::Manager::setBool("reflect misc", "Water", newState); Settings::Manager::setBool("reflect misc", "Water", newState);
@ -301,11 +371,77 @@ namespace MWGui
Settings::Manager::setBool("reflect actors", "Water", newState); Settings::Manager::setBool("reflect actors", "Water", newState);
else if (_sender == mReflectTerrainButton) else if (_sender == mReflectTerrainButton)
Settings::Manager::setBool("reflect terrain", "Water", newState); Settings::Manager::setBool("reflect terrain", "Water", newState);
else if (_sender == mShadowsEnabledButton)
Settings::Manager::setBool("enabled", "Shadows", newState);
else if (_sender == mShadowsLargeDistance)
Settings::Manager::setBool("split", "Shadows", newState);
else if (_sender == mActorShadows)
Settings::Manager::setBool("actor shadows", "Shadows", newState);
else if (_sender == mStaticsShadows)
Settings::Manager::setBool("statics shadows", "Shadows", newState);
else if (_sender == mMiscShadows)
Settings::Manager::setBool("misc shadows", "Shadows", newState);
else if (_sender == mShadowsDebug)
Settings::Manager::setBool("debug", "Shadows", newState);
apply(); apply();
} }
} }
void SettingsWindow::onShadersToggled(MyGUI::Widget* _sender)
{
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
if (val == "off")
{
val = hlslGlsl();
}
else if (val == hlslGlsl())
val = "cg";
else
val = "off";
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
if (val == "off")
{
Settings::Manager::setBool("shaders", "Objects", false);
// water shader not supported with object shaders off
mWaterShaderButton->setCaptionWithReplacing("#{sOff}");
mUnderwaterButton->setCaptionWithReplacing("#{sOff}");
mWaterShaderButton->setEnabled(false);
mReflectObjectsButton->setEnabled(false);
mReflectActorsButton->setEnabled(false);
mReflectTerrainButton->setEnabled(false);
mUnderwaterButton->setEnabled(false);
Settings::Manager::setBool("shader", "Water", false);
Settings::Manager::setBool("underwater effect", "Water", false);
// shadows not supported
mShadowsEnabledButton->setEnabled(false);
mShadowsEnabledButton->setCaptionWithReplacing("#{sOff}");
Settings::Manager::setBool("enabled", "Shadows", false);
}
else
{
Settings::Manager::setBool("shaders", "Objects", true);
Settings::Manager::setString("shader mode", "General", val);
// re-enable
if (MWRender::RenderingManager::waterShaderSupported())
{
mWaterShaderButton->setEnabled(true);
mReflectObjectsButton->setEnabled(true);
mReflectActorsButton->setEnabled(true);
mReflectTerrainButton->setEnabled(true);
}
mUnderwaterButton->setEnabled(true);
mShadowsEnabledButton->setEnabled(true);
}
apply();
}
void SettingsWindow::onFpsToggled(MyGUI::Widget* _sender) void SettingsWindow::onFpsToggled(MyGUI::Widget* _sender)
{ {
int newLevel = (Settings::Manager::getInt("fps", "HUD") + 1) % 3; int newLevel = (Settings::Manager::getInt("fps", "HUD") + 1) % 3;
@ -328,7 +464,6 @@ namespace MWGui
next = "none"; next = "none";
mTextureFilteringButton->setCaption(textureFilteringToStr(next)); mTextureFilteringButton->setCaption(textureFilteringToStr(next));
mAnisotropyBox->setVisible(next == "anisotropic");
Settings::Manager::setString("texture filtering", "General", next); Settings::Manager::setString("texture filtering", "General", next);
apply(); apply();

@ -42,6 +42,16 @@ namespace MWGui
MyGUI::Button* mReflectObjectsButton; MyGUI::Button* mReflectObjectsButton;
MyGUI::Button* mReflectActorsButton; MyGUI::Button* mReflectActorsButton;
MyGUI::Button* mReflectTerrainButton; MyGUI::Button* mReflectTerrainButton;
MyGUI::Button* mShadersButton;
MyGUI::Button* mUnderwaterButton;
MyGUI::Button* mShadowsEnabledButton;
MyGUI::Button* mShadowsLargeDistance;
MyGUI::Button* mShadowsTextureSize;
MyGUI::Button* mActorShadows;
MyGUI::Button* mStaticsShadows;
MyGUI::Button* mMiscShadows;
MyGUI::Button* mShadowsDebug;
// audio // audio
MyGUI::ScrollBar* mMasterVolumeSlider; MyGUI::ScrollBar* mMasterVolumeSlider;
@ -59,6 +69,9 @@ namespace MWGui
void onResolutionAccept(); void onResolutionAccept();
void onResolutionCancel(); void onResolutionCancel();
void onShadersToggled(MyGUI::Widget* _sender);
void onShadowTextureSize(MyGUI::Widget* _sender);
void apply(); void apply();
}; };
} }

@ -81,7 +81,7 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player); MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::Spells& spells = stats.mSpells; MWMechanics::Spells& spells = stats.getSpells();
// the following code switches between selected enchanted item and selected spell (only one of these // the following code switches between selected enchanted item and selected spell (only one of these
// can be active at a time) // can be active at a time)
@ -333,7 +333,7 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player); MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWMechanics::Spells& spells = stats.mSpells; MWMechanics::Spells& spells = stats.getSpells();
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>(); MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
// retrieve ContainerStoreIterator to the item // retrieve ContainerStoreIterator to the item
@ -397,7 +397,7 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player); MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWMechanics::Spells& spells = stats.mSpells; MWMechanics::Spells& spells = stats.getSpells();
if (MyGUI::InputManager::getInstance().isShiftPressed()) if (MyGUI::InputManager::getInstance().isShiftPressed())
{ {
@ -451,7 +451,7 @@ namespace MWGui
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::Spells& spells = stats.mSpells; MWMechanics::Spells& spells = stats.getSpells();
if (spells.getSelectedSpell() == mSpellToDelete) if (spells.getSelectedSpell() == mSpellToDelete)
{ {

@ -19,26 +19,26 @@
using namespace MWGui; using namespace MWGui;
const int StatsWindow::lineHeight = 18; const int StatsWindow::sLineHeight = 18;
StatsWindow::StatsWindow (WindowManager& parWindowManager) StatsWindow::StatsWindow (WindowManager& parWindowManager)
: WindowPinnableBase("openmw_stats_window.layout", parWindowManager) : WindowPinnableBase("openmw_stats_window.layout", parWindowManager)
, skillAreaWidget(NULL) , mSkillAreaWidget(NULL)
, skillClientWidget(NULL) , mSkillClientWidget(NULL)
, skillScrollerWidget(NULL) , mSkillScrollerWidget(NULL)
, lastPos(0) , mLastPos(0)
, clientHeight(0) , mClientHeight(0)
, majorSkills() , mMajorSkills()
, minorSkills() , mMinorSkills()
, miscSkills() , mMiscSkills()
, skillValues() , mSkillValues()
, skillWidgetMap() , mSkillWidgetMap()
, factionWidgetMap() , mFactionWidgetMap()
, mFactions() , mFactions()
, birthSignId() , mBirthSignId()
, reputation(0) , mReputation(0)
, bounty(0) , mBounty(0)
, skillWidgets() , mSkillWidgets()
, mChanged(true) , mChanged(true)
{ {
setCoord(0,0,498, 342); setCoord(0,0,498, 342);
@ -62,21 +62,21 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
setText (names[i][0], store.gameSettings.find (names[i][1])->str); setText (names[i][0], store.gameSettings.find (names[i][1])->str);
} }
getWidget(skillAreaWidget, "Skills"); getWidget(mSkillAreaWidget, "Skills");
getWidget(skillClientWidget, "SkillClient"); getWidget(mSkillClientWidget, "SkillClient");
getWidget(skillScrollerWidget, "SkillScroller"); getWidget(mSkillScrollerWidget, "SkillScroller");
getWidget(mLeftPane, "LeftPane"); getWidget(mLeftPane, "LeftPane");
getWidget(mRightPane, "RightPane"); getWidget(mRightPane, "RightPane");
skillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
updateScroller(); updateScroller();
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
{ {
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>())); mSkillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, nullptr)); mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, nullptr));
} }
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget); MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
@ -85,14 +85,14 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
{ {
int diff = lastPos - pos; int diff = mLastPos - pos;
// Adjust position of all widget according to difference // Adjust position of all widget according to difference
if (diff == 0) if (diff == 0)
return; return;
lastPos = pos; mLastPos = pos;
std::vector<MyGUI::WidgetPtr>::const_iterator end = skillWidgets.end(); std::vector<MyGUI::WidgetPtr>::const_iterator end = mSkillWidgets.end();
for (std::vector<MyGUI::WidgetPtr>::const_iterator it = skillWidgets.begin(); it != end; ++it) for (std::vector<MyGUI::WidgetPtr>::const_iterator it = mSkillWidgets.begin(); it != end; ++it)
{ {
(*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff)); (*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff));
} }
@ -100,14 +100,14 @@ void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (skillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0)
skillScrollerWidget->setScrollPosition(0); mSkillScrollerWidget->setScrollPosition(0);
else if (skillScrollerWidget->getScrollPosition() - _rel*0.3 > skillScrollerWidget->getScrollRange()-1) else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1)
skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollRange()-1); mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1);
else else
skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollPosition() - _rel*0.3); mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3);
onScrollChangePosition(skillScrollerWidget, skillScrollerWidget->getScrollPosition()); onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition());
} }
void StatsWindow::onWindowResize(MyGUI::Window* window) void StatsWindow::onWindowResize(MyGUI::Window* window)
@ -224,8 +224,8 @@ void StatsWindow::setValue (const std::string& id, int value)
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value) void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
{ {
skillValues[parSkill] = value; mSkillValues[parSkill] = value;
MyGUI::TextBox* widget = skillWidgetMap[(int)parSkill]; MyGUI::TextBox* widget = mSkillWidgetMap[(int)parSkill];
if (widget) if (widget)
{ {
float modified = value.getModified(), base = value.getBase(); float modified = value.getModified(), base = value.getBase();
@ -243,20 +243,20 @@ void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechani
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor) void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
{ {
majorSkills = major; mMajorSkills = major;
minorSkills = minor; mMinorSkills = minor;
// Update misc skills with the remaining skills not in major or minor // Update misc skills with the remaining skills not in major or minor
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::skillIds.end(); boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::skillIds.end();
miscSkills.clear(); mMiscSkills.clear();
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it)
{ {
int skill = *it; int skill = *it;
if (skillSet.find(skill) == skillSet.end()) if (skillSet.find(skill) == skillSet.end())
miscSkills.push_back(skill); mMiscSkills.push_back(skill);
} }
updateSkillArea(); updateSkillArea();
@ -270,7 +270,7 @@ void StatsWindow::onFrame ()
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player); MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player);
setFactions(PCstats.mFactionRank); setFactions(PCstats.getFactionRanks());
setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());
@ -289,20 +289,20 @@ void StatsWindow::setFactions (const FactionList& factions)
void StatsWindow::setBirthSign (const std::string& signId) void StatsWindow::setBirthSign (const std::string& signId)
{ {
if (signId != birthSignId) if (signId != mBirthSignId)
{ {
birthSignId = signId; mBirthSignId = signId;
mChanged = true; mChanged = true;
} }
} }
void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::ImageBox* separator = skillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::ImageBox* separator = mSkillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine",
MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18),
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillWidgets.push_back(separator); mSkillWidgets.push_back(separator);
coord1.top += separator->getHeight(); coord1.top += separator->getHeight();
coord2.top += separator->getHeight(); coord2.top += separator->getHeight();
@ -310,35 +310,35 @@ void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::TextBox* groupWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText",
MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height),
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
groupWidget->setCaption(label); groupWidget->setCaption(label);
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillWidgets.push_back(groupWidget); mSkillWidgets.push_back(groupWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
} }
MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::TextBox *skillNameWidget, *skillValueWidget; MyGUI::TextBox *skillNameWidget, *skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top); skillValueWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top);
skillValueWidget->setCaption(value); skillValueWidget->setCaption(value);
skillValueWidget->_setWidgetState(state); skillValueWidget->_setWidgetState(state);
skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
skillWidgets.push_back(skillValueWidget); mSkillWidgets.push_back(skillValueWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
return skillValueWidget; return skillValueWidget;
} }
@ -347,14 +347,14 @@ MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord &co
{ {
MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillNameWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
coord1.top += lineHeight; coord1.top += sLineHeight;
coord2.top += lineHeight; coord2.top += sLineHeight;
return skillNameWidget; return skillNameWidget;
} }
@ -362,7 +362,7 @@ MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord &co
void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!mSkillWidgets.empty())
{ {
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
} }
@ -377,7 +377,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
continue; continue;
assert(skillId >= 0 && skillId < ESM::Skill::Length); assert(skillId >= 0 && skillId < ESM::Skill::Length);
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId];
const MWMechanics::Stat<float> &stat = skillValues.find(skillId)->second; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second;
float base = stat.getBase(); float base = stat.getBase();
float modified = stat.getModified(); float modified = stat.getModified();
int progressPercent = (modified - float(static_cast<int>(modified))) * 100; int progressPercent = (modified - float(static_cast<int>(modified))) * 100;
@ -400,18 +400,18 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip");
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}");
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description);
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}");
skillWidgets[skillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon);
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast<std::string>(progressPercent)+"/100"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast<std::string>(progressPercent)+"/100");
skillWidgets[skillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100");
skillWidgets[skillWidgets.size()-1-i]->setUserString("RangePosition_SkillProgress", boost::lexical_cast<std::string>(progressPercent)); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("RangePosition_SkillProgress", boost::lexical_cast<std::string>(progressPercent));
} }
skillWidgetMap[skillId] = widget; mSkillWidgetMap[skillId] = widget;
} }
} }
@ -419,28 +419,28 @@ void StatsWindow::updateSkillArea()
{ {
mChanged = false; mChanged = false;
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it) for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(*it);
} }
skillWidgets.clear(); mSkillWidgets.clear();
skillScrollerWidget->setScrollPosition(0); mSkillScrollerWidget->setScrollPosition(0);
onScrollChangePosition(skillScrollerWidget, 0); onScrollChangePosition(mSkillScrollerWidget, 0);
clientHeight = 0; mClientHeight = 0;
const int valueSize = 40; const int valueSize = 40;
MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18); MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18);
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height); MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
if (!majorSkills.empty()) if (!mMajorSkills.empty())
addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
if (!minorSkills.empty()) if (!mMinorSkills.empty())
addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
if (!miscSkills.empty()) if (!mMiscSkills.empty())
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
@ -463,7 +463,7 @@ void StatsWindow::updateSkillArea()
if (!mFactions.empty()) if (!mFactions.empty())
{ {
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!mSkillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
@ -516,53 +516,53 @@ void StatsWindow::updateSkillArea()
} }
} }
if (!birthSignId.empty()) if (!mBirthSignId.empty())
{ {
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!mSkillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2);
const ESM::BirthSign *sign = store.birthSigns.find(birthSignId); const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId);
MyGUI::Widget* w = addItem(sign->name, coord1, coord2); MyGUI::Widget* w = addItem(sign->name, coord1, coord2);
ToolTips::createBirthsignToolTip(w, birthSignId); ToolTips::createBirthsignToolTip(w, mBirthSignId);
} }
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!mSkillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"),
boost::lexical_cast<std::string>(static_cast<int>(reputation)), "normal", coord1, coord2); boost::lexical_cast<std::string>(static_cast<int>(mReputation)), "normal", coord1, coord2);
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}");
} }
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"),
boost::lexical_cast<std::string>(static_cast<int>(bounty)), "normal", coord1, coord2); boost::lexical_cast<std::string>(static_cast<int>(mBounty)), "normal", coord1, coord2);
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ {
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}");
} }
clientHeight = coord1.top; mClientHeight = coord1.top;
updateScroller(); updateScroller();
} }
void StatsWindow::updateScroller() void StatsWindow::updateScroller()
{ {
skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0));
skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0));
if (clientHeight != 0) if (mClientHeight != 0)
skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillScrollerWidget->getLineSize() ); mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() );
} }
void StatsWindow::onPinToggled() void StatsWindow::onPinToggled()

@ -38,8 +38,8 @@ namespace MWGui
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value); void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
void configureSkills (const SkillList& major, const SkillList& minor); void configureSkills (const SkillList& major, const SkillList& minor);
void setReputation (int reputation) { this->reputation = reputation; } void setReputation (int reputation) { this->mReputation = reputation; }
void setBounty (int bounty) { this->bounty = bounty; } void setBounty (int bounty) { this->mBounty = bounty; }
void updateSkillArea(); void updateSkillArea();
private: private:
@ -57,23 +57,23 @@ namespace MWGui
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
void onMouseWheel(MyGUI::Widget* _sender, int _rel); void onMouseWheel(MyGUI::Widget* _sender, int _rel);
static const int lineHeight; static const int sLineHeight;
MyGUI::Widget* mLeftPane; MyGUI::Widget* mLeftPane;
MyGUI::Widget* mRightPane; MyGUI::Widget* mRightPane;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget;
MyGUI::ScrollBar* skillScrollerWidget; MyGUI::ScrollBar* mSkillScrollerWidget;
int lastPos, clientHeight; int mLastPos, mClientHeight;
SkillList majorSkills, minorSkills, miscSkills; SkillList mMajorSkills, mMinorSkills, mMiscSkills;
std::map<int, MWMechanics::Stat<float> > skillValues; std::map<int, MWMechanics::Stat<float> > mSkillValues;
std::map<int, MyGUI::TextBox*> skillWidgetMap; std::map<int, MyGUI::TextBox*> mSkillWidgetMap;
std::map<std::string, MyGUI::WidgetPtr> factionWidgetMap; std::map<std::string, MyGUI::WidgetPtr> mFactionWidgetMap;
FactionList mFactions; ///< Stores a list of factions and the current rank FactionList mFactions; ///< Stores a list of factions and the current rank
std::string birthSignId; std::string mBirthSignId;
int reputation, bounty; int mReputation, mBounty;
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information std::vector<MyGUI::WidgetPtr> mSkillWidgets; //< Skills and other information
bool mChanged; bool mChanged;

@ -9,15 +9,15 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
// Centre dialog // Centre dialog
center(); center();
getWidget(textEdit, "TextEdit"); getWidget(mTextEdit, "TextEdit");
textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted); mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
} }
void TextInputDialog::setNextButtonShow(bool shown) void TextInputDialog::setNextButtonShow(bool shown)
@ -43,7 +43,7 @@ void TextInputDialog::setTextLabel(const std::string &label)
void TextInputDialog::open() void TextInputDialog::open()
{ {
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
setVisible(true); setVisible(true);
} }

@ -20,8 +20,8 @@ namespace MWGui
public: public:
TextInputDialog(WindowManager& parWindowManager); TextInputDialog(WindowManager& parWindowManager);
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; }
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); }
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void setTextLabel(const std::string &label); void setTextLabel(const std::string &label);
@ -32,7 +32,7 @@ namespace MWGui
void onTextAccepted(MyGUI::Edit* _sender); void onTextAccepted(MyGUI::Edit* _sender);
private: private:
MyGUI::EditPtr textEdit; MyGUI::EditPtr mTextEdit;
}; };
} }
#endif #endif

@ -27,16 +27,16 @@ void MWGui::Widgets::fixTexturePath(std::string &path)
/* MWSkill */ /* MWSkill */
MWSkill::MWSkill() MWSkill::MWSkill()
: manager(nullptr) : mManager(nullptr)
, skillId(ESM::Skill::Length) , mSkillId(ESM::Skill::Length)
, skillNameWidget(nullptr) , mSkillNameWidget(nullptr)
, skillValueWidget(nullptr) , mSkillValueWidget(nullptr)
{ {
} }
void MWSkill::setSkillId(ESM::Skill::SkillEnum skill) void MWSkill::setSkillId(ESM::Skill::SkillEnum skill)
{ {
skillId = skill; mSkillId = skill;
updateWidgets(); updateWidgets();
} }
@ -50,36 +50,36 @@ void MWSkill::setSkillNumber(int skill)
throw new std::runtime_error("Skill number out of range"); throw new std::runtime_error("Skill number out of range");
} }
void MWSkill::setSkillValue(const SkillValue& value_) void MWSkill::setSkillValue(const SkillValue& value)
{ {
value = value_; mValue = value;
updateWidgets(); updateWidgets();
} }
void MWSkill::updateWidgets() void MWSkill::updateWidgets()
{ {
if (skillNameWidget && manager) if (mSkillNameWidget && mManager)
{ {
if (skillId == ESM::Skill::Length) if (mSkillId == ESM::Skill::Length)
{ {
static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption(""); static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption("");
} }
else else
{ {
const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], ""); const std::string &name = mManager->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], "");
static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption(name); static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption(name);
} }
} }
if (skillValueWidget) if (mSkillValueWidget)
{ {
SkillValue::Type modified = value.getModified(), base = value.getBase(); SkillValue::Type modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(skillValueWidget)->setCaption(boost::lexical_cast<std::string>(modified)); static_cast<MyGUI::TextBox*>(mSkillValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base) if (modified > base)
skillValueWidget->_setWidgetState("increased"); mSkillValueWidget->_setWidgetState("increased");
else if (modified < base) else if (modified < base)
skillValueWidget->_setWidgetState("decreased"); mSkillValueWidget->_setWidgetState("decreased");
else else
skillValueWidget->_setWidgetState("normal"); mSkillValueWidget->_setWidgetState("normal");
} }
} }
@ -96,14 +96,14 @@ void MWSkill::initialiseOverride()
{ {
Base::initialiseOverride(); Base::initialiseOverride();
assignWidget(skillNameWidget, "StatName"); assignWidget(mSkillNameWidget, "StatName");
assignWidget(skillValueWidget, "StatValue"); assignWidget(mSkillValueWidget, "StatValue");
MyGUI::ButtonPtr button; MyGUI::ButtonPtr button;
assignWidget(button, "StatNameButton"); assignWidget(button, "StatNameButton");
if (button) if (button)
{ {
skillNameWidget = button; mSkillNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
} }
@ -111,7 +111,7 @@ void MWSkill::initialiseOverride()
assignWidget(button, "StatValueButton"); assignWidget(button, "StatValueButton");
if (button) if (button)
{ {
skillNameWidget = button; mSkillNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
} }
} }
@ -119,22 +119,22 @@ void MWSkill::initialiseOverride()
/* MWAttribute */ /* MWAttribute */
MWAttribute::MWAttribute() MWAttribute::MWAttribute()
: manager(nullptr) : mManager(nullptr)
, id(-1) , mId(-1)
, attributeNameWidget(nullptr) , mAttributeNameWidget(nullptr)
, attributeValueWidget(nullptr) , mAttributeValueWidget(nullptr)
{ {
} }
void MWAttribute::setAttributeId(int attributeId) void MWAttribute::setAttributeId(int attributeId)
{ {
id = attributeId; mId = attributeId;
updateWidgets(); updateWidgets();
} }
void MWAttribute::setAttributeValue(const AttributeValue& value_) void MWAttribute::setAttributeValue(const AttributeValue& value)
{ {
value = value_; mValue = value;
updateWidgets(); updateWidgets();
} }
@ -145,11 +145,11 @@ void MWAttribute::onClicked(MyGUI::Widget* _sender)
void MWAttribute::updateWidgets() void MWAttribute::updateWidgets()
{ {
if (attributeNameWidget && manager) if (mAttributeNameWidget && mManager)
{ {
if (id < 0 || id >= 8) if (mId < 0 || mId >= 8)
{ {
static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption(""); static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption("");
} }
else else
{ {
@ -163,20 +163,20 @@ void MWAttribute::updateWidgets()
"sAttributePersonality", "sAttributePersonality",
"sAttributeLuck" "sAttributeLuck"
}; };
const std::string &name = manager->getGameSettingString(attributes[id], ""); const std::string &name = mManager->getGameSettingString(attributes[mId], "");
static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption(name); static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption(name);
} }
} }
if (attributeValueWidget) if (mAttributeValueWidget)
{ {
AttributeValue::Type modified = value.getModified(), base = value.getBase(); AttributeValue::Type modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(attributeValueWidget)->setCaption(boost::lexical_cast<std::string>(modified)); static_cast<MyGUI::TextBox*>(mAttributeValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base) if (modified > base)
attributeValueWidget->_setWidgetState("increased"); mAttributeValueWidget->_setWidgetState("increased");
else if (modified < base) else if (modified < base)
attributeValueWidget->_setWidgetState("decreased"); mAttributeValueWidget->_setWidgetState("decreased");
else else
attributeValueWidget->_setWidgetState("normal"); mAttributeValueWidget->_setWidgetState("normal");
} }
} }
@ -188,14 +188,14 @@ void MWAttribute::initialiseOverride()
{ {
Base::initialiseOverride(); Base::initialiseOverride();
assignWidget(attributeNameWidget, "StatName"); assignWidget(mAttributeNameWidget, "StatName");
assignWidget(attributeValueWidget, "StatValue"); assignWidget(mAttributeValueWidget, "StatValue");
MyGUI::ButtonPtr button; MyGUI::ButtonPtr button;
assignWidget(button, "StatNameButton"); assignWidget(button, "StatNameButton");
if (button) if (button)
{ {
attributeNameWidget = button; mAttributeNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
} }
@ -203,7 +203,7 @@ void MWAttribute::initialiseOverride()
assignWidget(button, "StatValueButton"); assignWidget(button, "StatValueButton");
if (button) if (button)
{ {
attributeValueWidget = button; mAttributeValueWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
} }
} }
@ -212,21 +212,21 @@ void MWAttribute::initialiseOverride()
MWSpell::MWSpell() MWSpell::MWSpell()
: mWindowManager(nullptr) : mWindowManager(nullptr)
, spellNameWidget(nullptr) , mSpellNameWidget(nullptr)
{ {
} }
void MWSpell::setSpellId(const std::string &spellId) void MWSpell::setSpellId(const std::string &spellId)
{ {
id = spellId; mId = spellId;
updateWidgets(); updateWidgets();
} }
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id); const ESM::Spell *spell = store.spells.search(mId);
MYGUI_ASSERT(spell, "spell with id '" << id << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
MWSpellEffectPtr effect = nullptr; MWSpellEffectPtr effect = nullptr;
std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end(); std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end();
@ -253,14 +253,14 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
void MWSpell::updateWidgets() void MWSpell::updateWidgets()
{ {
if (spellNameWidget && mWindowManager) if (mSpellNameWidget && mWindowManager)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id); const ESM::Spell *spell = store.spells.search(mId);
if (spell) if (spell)
static_cast<MyGUI::TextBox*>(spellNameWidget)->setCaption(spell->name); static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->name);
else else
static_cast<MyGUI::TextBox*>(spellNameWidget)->setCaption(""); static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption("");
} }
} }
@ -268,7 +268,7 @@ void MWSpell::initialiseOverride()
{ {
Base::initialiseOverride(); Base::initialiseOverride();
assignWidget(spellNameWidget, "StatName"); assignWidget(mSpellNameWidget, "StatName");
} }
MWSpell::~MWSpell() MWSpell::~MWSpell()
@ -367,8 +367,8 @@ SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
MWSpellEffect::MWSpellEffect() MWSpellEffect::MWSpellEffect()
: mWindowManager(nullptr) : mWindowManager(nullptr)
, imageWidget(nullptr) , mImageWidget(nullptr)
, textWidget(nullptr) , mTextWidget(nullptr)
, mRequestedWidth(0) , mRequestedWidth(0)
{ {
} }
@ -388,7 +388,7 @@ void MWSpellEffect::updateWidgets()
const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID);
if (!magicEffect) if (!magicEffect)
return; return;
if (textWidget) if (mTextWidget)
{ {
std::string pt = mWindowManager->getGameSettingString("spoint", ""); std::string pt = mWindowManager->getGameSettingString("spoint", "");
std::string pts = mWindowManager->getGameSettingString("spoints", ""); std::string pts = mWindowManager->getGameSettingString("spoints", "");
@ -448,14 +448,14 @@ void MWSpellEffect::updateWidgets()
} }
} }
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(spellLine); static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(spellLine);
mRequestedWidth = textWidget->getTextSize().width + 24; mRequestedWidth = mTextWidget->getTextSize().width + 24;
} }
if (imageWidget) if (mImageWidget)
{ {
std::string path = std::string("icons\\") + magicEffect->icon; std::string path = std::string("icons\\") + magicEffect->icon;
fixTexturePath(path); fixTexturePath(path);
imageWidget->setImageTexture(path); mImageWidget->setImageTexture(path);
} }
} }
@ -728,49 +728,49 @@ void MWSpellEffect::initialiseOverride()
{ {
Base::initialiseOverride(); Base::initialiseOverride();
assignWidget(textWidget, "Text"); assignWidget(mTextWidget, "Text");
assignWidget(imageWidget, "Image"); assignWidget(mImageWidget, "Image");
} }
/* MWDynamicStat */ /* MWDynamicStat */
MWDynamicStat::MWDynamicStat() MWDynamicStat::MWDynamicStat()
: value(0) : mValue(0)
, max(1) , mMax(1)
, textWidget(nullptr) , mTextWidget(nullptr)
, barWidget(nullptr) , mBarWidget(nullptr)
, barTextWidget(nullptr) , mBarTextWidget(nullptr)
{ {
} }
void MWDynamicStat::setValue(int cur, int max_) void MWDynamicStat::setValue(int cur, int max)
{ {
value = cur; mValue = cur;
max = max_; mMax = max;
if (barWidget) if (mBarWidget)
{ {
barWidget->setProgressRange(max); mBarWidget->setProgressRange(mMax);
barWidget->setProgressPosition(value); mBarWidget->setProgressPosition(mValue);
} }
if (barTextWidget) if (mBarTextWidget)
{ {
if (value >= 0 && max > 0) if (mValue >= 0 && mMax > 0)
{ {
std::stringstream out; std::stringstream out;
out << value << "/" << max; out << mValue << "/" << mMax;
static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption(out.str().c_str()); static_cast<MyGUI::TextBox*>(mBarTextWidget)->setCaption(out.str().c_str());
} }
else else
static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption(""); static_cast<MyGUI::TextBox*>(mBarTextWidget)->setCaption("");
} }
} }
void MWDynamicStat::setTitle(const std::string& text) void MWDynamicStat::setTitle(const std::string& text)
{ {
if (textWidget) if (mTextWidget)
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(text); static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(text);
} }
MWDynamicStat::~MWDynamicStat() MWDynamicStat::~MWDynamicStat()
@ -781,7 +781,7 @@ void MWDynamicStat::initialiseOverride()
{ {
Base::initialiseOverride(); Base::initialiseOverride();
assignWidget(textWidget, "Text"); assignWidget(mTextWidget, "Text");
assignWidget(barWidget, "Bar"); assignWidget(mBarWidget, "Bar");
assignWidget(barTextWidget, "BarText"); assignWidget(mBarTextWidget, "BarText");
} }

@ -73,7 +73,7 @@ namespace MWGui
typedef std::vector<SpellEffectParams> SpellEffectList; typedef std::vector<SpellEffectParams> SpellEffectList;
class MYGUI_EXPORT MWSkill : public Widget class MYGUI_EXPORT MWSkill : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWSkill ); MYGUI_RTTI_DERIVED( MWSkill );
public: public:
@ -81,14 +81,14 @@ namespace MWGui
typedef MWMechanics::Stat<float> SkillValue; typedef MWMechanics::Stat<float> SkillValue;
void setWindowManager(WindowManager *m) { manager = m; } void setWindowManager(WindowManager *m) { mManager = m; }
void setSkillId(ESM::Skill::SkillEnum skillId); void setSkillId(ESM::Skill::SkillEnum skillId);
void setSkillNumber(int skillId); void setSkillNumber(int skillId);
void setSkillValue(const SkillValue& value); void setSkillValue(const SkillValue& value);
WindowManager *getWindowManager() const { return manager; } WindowManager *getWindowManager() const { return mManager; }
ESM::Skill::SkillEnum getSkillId() const { return skillId; } ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
const SkillValue& getSkillValue() const { return value; } const SkillValue& getSkillValue() const { return mValue; }
// Events // Events
typedef delegates::CMultiDelegate1<MWSkill*> EventHandle_SkillVoid; typedef delegates::CMultiDelegate1<MWSkill*> EventHandle_SkillVoid;
@ -109,14 +109,14 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager *manager; WindowManager *mManager;
ESM::Skill::SkillEnum skillId; ESM::Skill::SkillEnum mSkillId;
SkillValue value; SkillValue mValue;
MyGUI::WidgetPtr skillNameWidget, skillValueWidget; MyGUI::WidgetPtr mSkillNameWidget, mSkillValueWidget;
}; };
typedef MWSkill* MWSkillPtr; typedef MWSkill* MWSkillPtr;
class MYGUI_EXPORT MWAttribute : public Widget class MYGUI_EXPORT MWAttribute : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWAttribute ); MYGUI_RTTI_DERIVED( MWAttribute );
public: public:
@ -124,13 +124,13 @@ namespace MWGui
typedef MWMechanics::Stat<int> AttributeValue; typedef MWMechanics::Stat<int> AttributeValue;
void setWindowManager(WindowManager *m) { manager = m; } void setWindowManager(WindowManager *m) { mManager = m; }
void setAttributeId(int attributeId); void setAttributeId(int attributeId);
void setAttributeValue(const AttributeValue& value); void setAttributeValue(const AttributeValue& value);
WindowManager *getWindowManager() const { return manager; } WindowManager *getWindowManager() const { return mManager; }
int getAttributeId() const { return id; } int getAttributeId() const { return mId; }
const AttributeValue& getAttributeValue() const { return value; } const AttributeValue& getAttributeValue() const { return mValue; }
// Events // Events
typedef delegates::CMultiDelegate1<MWAttribute*> EventHandle_AttributeVoid; typedef delegates::CMultiDelegate1<MWAttribute*> EventHandle_AttributeVoid;
@ -151,10 +151,10 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager *manager; WindowManager *mManager;
int id; int mId;
AttributeValue value; AttributeValue mValue;
MyGUI::WidgetPtr attributeNameWidget, attributeValueWidget; MyGUI::WidgetPtr mAttributeNameWidget, mAttributeValueWidget;
}; };
typedef MWAttribute* MWAttributePtr; typedef MWAttribute* MWAttributePtr;
@ -162,7 +162,7 @@ namespace MWGui
* @todo remove this class and use MWEffectList instead * @todo remove this class and use MWEffectList instead
*/ */
class MWSpellEffect; class MWSpellEffect;
class MYGUI_EXPORT MWSpell : public Widget class MYGUI_EXPORT MWSpell : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWSpell ); MYGUI_RTTI_DERIVED( MWSpell );
public: public:
@ -182,7 +182,7 @@ namespace MWGui
*/ */
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags); void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags);
const std::string &getSpellId() const { return id; } const std::string &getSpellId() const { return mId; }
protected: protected:
virtual ~MWSpell(); virtual ~MWSpell();
@ -193,12 +193,12 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; WindowManager* mWindowManager;
std::string id; std::string mId;
MyGUI::TextBox* spellNameWidget; MyGUI::TextBox* mSpellNameWidget;
}; };
typedef MWSpell* MWSpellPtr; typedef MWSpell* MWSpellPtr;
class MYGUI_EXPORT MWEffectList : public Widget class MYGUI_EXPORT MWEffectList : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWEffectList ); MYGUI_RTTI_DERIVED( MWEffectList );
public: public:
@ -239,7 +239,7 @@ namespace MWGui
}; };
typedef MWEffectList* MWEffectListPtr; typedef MWEffectList* MWEffectListPtr;
class MYGUI_EXPORT MWSpellEffect : public Widget class MYGUI_EXPORT MWSpellEffect : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWSpellEffect ); MYGUI_RTTI_DERIVED( MWSpellEffect );
public: public:
@ -269,13 +269,13 @@ namespace MWGui
WindowManager* mWindowManager; WindowManager* mWindowManager;
SpellEffectParams mEffectParams; SpellEffectParams mEffectParams;
MyGUI::ImageBox* imageWidget; MyGUI::ImageBox* mImageWidget;
MyGUI::TextBox* textWidget; MyGUI::TextBox* mTextWidget;
int mRequestedWidth; int mRequestedWidth;
}; };
typedef MWSpellEffect* MWSpellEffectPtr; typedef MWSpellEffect* MWSpellEffectPtr;
class MYGUI_EXPORT MWDynamicStat : public Widget class MYGUI_EXPORT MWDynamicStat : public MyGUI::Widget
{ {
MYGUI_RTTI_DERIVED( MWDynamicStat ); MYGUI_RTTI_DERIVED( MWDynamicStat );
public: public:
@ -284,8 +284,8 @@ namespace MWGui
void setValue(int value, int max); void setValue(int value, int max);
void setTitle(const std::string& text); void setTitle(const std::string& text);
int getValue() const { return value; } int getValue() const { return mValue; }
int getMax() const { return max; } int getMax() const { return mMax; }
protected: protected:
virtual ~MWDynamicStat(); virtual ~MWDynamicStat();
@ -294,10 +294,10 @@ namespace MWGui
private: private:
int value, max; int mValue, mMax;
MyGUI::TextBox* textWidget; MyGUI::TextBox* mTextWidget;
MyGUI::ProgressPtr barWidget; MyGUI::ProgressPtr mBarWidget;
MyGUI::TextBox* barTextWidget; MyGUI::TextBox* mBarTextWidget;
}; };
typedef MWDynamicStat* MWDynamicStatPtr; typedef MWDynamicStat* MWDynamicStatPtr;
} }

@ -41,15 +41,15 @@
using namespace MWGui; using namespace MWGui;
WindowManager::WindowManager( WindowManager::WindowManager(
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath) const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts)
: mGuiManager(NULL) : mGuiManager(NULL)
, hud(NULL) , mHud(NULL)
, map(NULL) , mMap(NULL)
, menu(NULL) , mMenu(NULL)
, mStatsWindow(NULL) , mStatsWindow(NULL)
, mToolTips(NULL) , mToolTips(NULL)
, mMessageBoxManager(NULL) , mMessageBoxManager(NULL)
, console(NULL) , mConsole(NULL)
, mJournal(NULL) , mJournal(NULL)
, mDialogueWindow(NULL) , mDialogueWindow(NULL)
, mBookWindow(NULL) , mBookWindow(NULL)
@ -61,21 +61,21 @@ WindowManager::WindowManager(
, mAlchemyWindow(NULL) , mAlchemyWindow(NULL)
, mSpellWindow(NULL) , mSpellWindow(NULL)
, mCharGen(NULL) , mCharGen(NULL)
, playerClass() , mPlayerClass()
, playerName() , mPlayerName()
, playerRaceId() , mPlayerRaceId()
, playerAttributes() , mPlayerAttributes()
, playerMajorSkills() , mPlayerMajorSkills()
, playerMinorSkills() , mPlayerMinorSkills()
, playerSkillValues() , mPlayerSkillValues()
, playerHealth() , mPlayerHealth()
, playerMagicka() , mPlayerMagicka()
, playerFatigue() , mPlayerFatigue()
, gui(NULL) , mGui(NULL)
, garbageDialogs() , mGarbageDialogs()
, shown(GW_ALL) , mShown(GW_ALL)
, allowed(newGame ? GW_None : GW_ALL) , mAllowed(newGame ? GW_None : GW_ALL)
, showFPSLevel(fpsLevel) , mShowFPSLevel(fpsLevel)
, mFPS(0.0f) , mFPS(0.0f)
, mTriangleCount(0) , mTriangleCount(0)
, mBatchCount(0) , mBatchCount(0)
@ -83,7 +83,7 @@ WindowManager::WindowManager(
// Set up the GUI system // Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath); mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);
gui = mGuiManager->getGui(); mGui = mGuiManager->getGui();
//Register own widgets with MyGUI //Register own widgets with MyGUI
MyGUI::FactoryManager::getInstance().registerFactory<DialogueHistory>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<DialogueHistory>("Widget");
@ -98,11 +98,11 @@ WindowManager::WindowManager(
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
// Get size info from the Gui object // Get size info from the Gui object
assert(gui); assert(mGui);
int w = MyGUI::RenderManager::getInstance().getViewSize().width; int w = MyGUI::RenderManager::getInstance().getViewSize().width;
int h = MyGUI::RenderManager::getInstance().getViewSize().height; int h = MyGUI::RenderManager::getInstance().getViewSize().height;
MyGUI::Widget* dragAndDropWidget = gui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget"); MyGUI::Widget* dragAndDropWidget = mGui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget");
dragAndDropWidget->setVisible(false); dragAndDropWidget->setVisible(false);
mDragAndDrop = new DragAndDrop(); mDragAndDrop = new DragAndDrop();
@ -110,17 +110,17 @@ WindowManager::WindowManager(
mDragAndDrop->mDraggedWidget = 0; mDragAndDrop->mDraggedWidget = 0;
mDragAndDrop->mDragAndDropWidget = dragAndDropWidget; mDragAndDrop->mDragAndDropWidget = dragAndDropWidget;
menu = new MainMenu(w,h); mMenu = new MainMenu(w,h);
map = new MapWindow(*this); mMap = new MapWindow(*this);
mStatsWindow = new StatsWindow(*this); mStatsWindow = new StatsWindow(*this);
console = new Console(w,h, extensions); mConsole = new Console(w,h, consoleOnlyScripts);
mJournal = new JournalWindow(*this); mJournal = new JournalWindow(*this);
mMessageBoxManager = new MessageBoxManager(this); mMessageBoxManager = new MessageBoxManager(this);
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
mTradeWindow = new TradeWindow(*this); mTradeWindow = new TradeWindow(*this);
mDialogueWindow = new DialogueWindow(*this); mDialogueWindow = new DialogueWindow(*this);
mContainerWindow = new ContainerWindow(*this,mDragAndDrop); mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
hud = new HUD(w,h, showFPSLevel, mDragAndDrop); mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop);
mToolTips = new ToolTips(this); mToolTips = new ToolTips(this);
mScrollWindow = new ScrollWindow(*this); mScrollWindow = new ScrollWindow(*this);
mBookWindow = new BookWindow(*this); mBookWindow = new BookWindow(*this);
@ -131,19 +131,19 @@ WindowManager::WindowManager(
mSpellWindow = new SpellWindow(*this); mSpellWindow = new SpellWindow(*this);
// The HUD is always on // The HUD is always on
hud->setVisible(true); mHud->setVisible(true);
mCharGen = new CharacterCreation(this); mCharGen = new CharacterCreation(this);
// Setup player stats // Setup player stats
for (int i = 0; i < ESM::Attribute::Length; ++i) for (int i = 0; i < ESM::Attribute::Length; ++i)
{ {
playerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat<int>())); mPlayerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat<int>()));
} }
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
{ {
playerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat<float>())); mPlayerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat<float>()));
} }
unsetSelectedSpell(); unsetSelectedSpell();
@ -156,11 +156,11 @@ WindowManager::WindowManager(
WindowManager::~WindowManager() WindowManager::~WindowManager()
{ {
delete mGuiManager; delete mGuiManager;
delete console; delete mConsole;
delete mMessageBoxManager; delete mMessageBoxManager;
delete hud; delete mHud;
delete map; delete mMap;
delete menu; delete mMenu;
delete mStatsWindow; delete mStatsWindow;
delete mJournal; delete mJournal;
delete mDialogueWindow; delete mDialogueWindow;
@ -183,13 +183,13 @@ WindowManager::~WindowManager()
void WindowManager::cleanupGarbage() void WindowManager::cleanupGarbage()
{ {
// Delete any dialogs which are no longer in use // Delete any dialogs which are no longer in use
if (!garbageDialogs.empty()) if (!mGarbageDialogs.empty())
{ {
for (std::vector<OEngine::GUI::Layout*>::iterator it = garbageDialogs.begin(); it != garbageDialogs.end(); ++it) for (std::vector<OEngine::GUI::Layout*>::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it)
{ {
delete *it; delete *it;
} }
garbageDialogs.clear(); mGarbageDialogs.clear();
} }
} }
@ -197,18 +197,18 @@ void WindowManager::update()
{ {
cleanupGarbage(); cleanupGarbage();
hud->setFPS(mFPS); mHud->setFPS(mFPS);
hud->setTriangleCount(mTriangleCount); mHud->setTriangleCount(mTriangleCount);
hud->setBatchCount(mBatchCount); mHud->setBatchCount(mBatchCount);
} }
void WindowManager::updateVisible() void WindowManager::updateVisible()
{ {
// Start out by hiding everything except the HUD // Start out by hiding everything except the HUD
map->setVisible(false); mMap->setVisible(false);
menu->setVisible(false); mMenu->setVisible(false);
mStatsWindow->setVisible(false); mStatsWindow->setVisible(false);
console->disable(); mConsole->disable();
mJournal->setVisible(false); mJournal->setVisible(false);
mDialogueWindow->setVisible(false); mDialogueWindow->setVisible(false);
mContainerWindow->setVisible(false); mContainerWindow->setVisible(false);
@ -230,10 +230,10 @@ void WindowManager::updateVisible()
else else
mToolTips->enterGuiMode(); mToolTips->enterGuiMode();
setMinimapVisibility((allowed & GW_Map) && !map->pinned()); setMinimapVisibility((mAllowed & GW_Map) && !mMap->pinned());
setWeaponVisibility((allowed & GW_Inventory) && !mInventoryWindow->pinned()); setWeaponVisibility((mAllowed & GW_Inventory) && !mInventoryWindow->pinned());
setSpellVisibility((allowed & GW_Magic) && !mSpellWindow->pinned()); setSpellVisibility((mAllowed & GW_Magic) && !mSpellWindow->pinned());
setHMSVisibility((allowed & GW_Stats) && !mStatsWindow->pinned()); setHMSVisibility((mAllowed & GW_Stats) && !mStatsWindow->pinned());
// If in game mode, don't show anything. // If in game mode, don't show anything.
if (gameMode) if (gameMode)
@ -243,13 +243,13 @@ void WindowManager::updateVisible()
switch(mode) { switch(mode) {
case GM_MainMenu: case GM_MainMenu:
menu->setVisible(true); mMenu->setVisible(true);
break; break;
case GM_Settings: case GM_Settings:
mSettingsWindow->setVisible(true); mSettingsWindow->setVisible(true);
break; break;
case GM_Console: case GM_Console:
console->enable(); mConsole->enable();
break; break;
case GM_Scroll: case GM_Scroll:
mScrollWindow->setVisible(true); mScrollWindow->setVisible(true);
@ -276,13 +276,13 @@ void WindowManager::updateVisible()
// This is controlled both by what windows the // This is controlled both by what windows the
// user has opened/closed (the 'shown' variable) and by what // user has opened/closed (the 'shown' variable) and by what
// windows we are allowed to show (the 'allowed' var.) // windows we are allowed to show (the 'allowed' var.)
int eff = shown & allowed; int eff = mShown & mAllowed;
// Show the windows we want // Show the windows we want
map -> setVisible(eff & GW_Map); mMap ->setVisible(eff & GW_Map);
mStatsWindow -> setVisible(eff & GW_Stats); mStatsWindow ->setVisible(eff & GW_Stats);
mInventoryWindow->setVisible(eff & GW_Inventory); mInventoryWindow->setVisible(eff & GW_Inventory);
mSpellWindow->setVisible(eff & GW_Magic); mSpellWindow ->setVisible(eff & GW_Magic);
break; break;
} }
case GM_Container: case GM_Container:
@ -333,7 +333,7 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int
{ {
if (id != ids[i]) if (id != ids[i])
continue; continue;
playerAttributes[attributes[i]] = value; mPlayerAttributes[attributes[i]] = value;
break; break;
} }
} }
@ -343,27 +343,27 @@ void WindowManager::setValue(const ESM::Skill::SkillEnum parSkill, const MWMecha
{ {
mStatsWindow->setValue(parSkill, value); mStatsWindow->setValue(parSkill, value);
mCharGen->setValue(parSkill, value); mCharGen->setValue(parSkill, value);
playerSkillValues[parSkill] = value; mPlayerSkillValues[parSkill] = value;
} }
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value) void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
{ {
mStatsWindow->setValue (id, value); mStatsWindow->setValue (id, value);
hud->setValue (id, value); mHud->setValue (id, value);
mCharGen->setValue(id, value); mCharGen->setValue(id, value);
if (id == "HBar") if (id == "HBar")
{ {
playerHealth = value; mPlayerHealth = value;
mCharGen->setPlayerHealth (value); mCharGen->setPlayerHealth (value);
} }
else if (id == "MBar") else if (id == "MBar")
{ {
playerMagicka = value; mPlayerMagicka = value;
mCharGen->setPlayerMagicka (value); mCharGen->setPlayerMagicka (value);
} }
else if (id == "FBar") else if (id == "FBar")
{ {
playerFatigue = value; mPlayerFatigue = value;
mCharGen->setPlayerFatigue (value); mCharGen->setPlayerFatigue (value);
} }
} }
@ -372,11 +372,11 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicS
MWMechanics::DynamicStat<int> WindowManager::getValue(const std::string& id) MWMechanics::DynamicStat<int> WindowManager::getValue(const std::string& id)
{ {
if(id == "HBar") if(id == "HBar")
return playerHealth; return layerHealth;
else if (id == "MBar") else if (id == "MBar")
return playerMagicka; return mPlayerMagicka;
else if (id == "FBar") else if (id == "FBar")
return playerFatigue; return mPlayerFatigue;
} }
#endif #endif
@ -384,9 +384,9 @@ void WindowManager::setValue (const std::string& id, const std::string& value)
{ {
mStatsWindow->setValue (id, value); mStatsWindow->setValue (id, value);
if (id=="name") if (id=="name")
playerName = value; mPlayerName = value;
else if (id=="race") else if (id=="race")
playerRaceId = value; mPlayerRaceId = value;
} }
void WindowManager::setValue (const std::string& id, int value) void WindowManager::setValue (const std::string& id, int value)
@ -396,16 +396,16 @@ void WindowManager::setValue (const std::string& id, int value)
void WindowManager::setPlayerClass (const ESM::Class &class_) void WindowManager::setPlayerClass (const ESM::Class &class_)
{ {
playerClass = class_; mPlayerClass = class_;
mStatsWindow->setValue("class", playerClass.name); mStatsWindow->setValue("class", mPlayerClass.name);
} }
void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) void WindowManager::configureSkills (const SkillList& major, const SkillList& minor)
{ {
mStatsWindow->configureSkills (major, minor); mStatsWindow->configureSkills (major, minor);
mCharGen->configureSkills(major, minor); mCharGen->configureSkills(major, minor);
playerMajorSkills = major; mPlayerMajorSkills = major;
playerMinorSkills = minor; mPlayerMinorSkills = minor;
} }
void WindowManager::setReputation (int reputation) void WindowManager::setReputation (int reputation)
@ -429,7 +429,7 @@ void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
if (!dialog) if (!dialog)
return; return;
dialog->setVisible(false); dialog->setVisible(false);
garbageDialogs.push_back(dialog); mGarbageDialogs.push_back(dialog);
} }
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons) void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
@ -484,12 +484,12 @@ void WindowManager::onFrame (float frameDuration)
mStatsWindow->onFrame(); mStatsWindow->onFrame();
hud->onFrame(frameDuration); mHud->onFrame(frameDuration);
mDialogueWindow->checkReferenceAvailable(); mDialogueWindow->checkReferenceAvailable();
mTradeWindow->checkReferenceAvailable(); mTradeWindow->checkReferenceAvailable();
mContainerWindow->checkReferenceAvailable(); mContainerWindow->checkReferenceAvailable();
console->checkReferenceAvailable(); mConsole->checkReferenceAvailable();
} }
const ESMS::ESMStore& WindowManager::getStore() const const ESMS::ESMStore& WindowManager::getStore() const
@ -513,56 +513,56 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
name = getGameSettingString("sDefaultCellname", "Wilderness"); name = getGameSettingString("sDefaultCellname", "Wilderness");
} }
map->setCellName( name ); mMap->setCellName( name );
hud->setCellName( name ); mHud->setCellName( name );
map->setCellPrefix("Cell"); mMap->setCellPrefix("Cell");
hud->setCellPrefix("Cell"); mHud->setCellPrefix("Cell");
map->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); mMap->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
hud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); mHud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
} }
else else
{ {
map->setCellName( cell->cell->name ); mMap->setCellName( cell->cell->name );
hud->setCellName( cell->cell->name ); mHud->setCellName( cell->cell->name );
map->setCellPrefix( cell->cell->name ); mMap->setCellPrefix( cell->cell->name );
hud->setCellPrefix( cell->cell->name ); mHud->setCellPrefix( cell->cell->name );
} }
} }
void WindowManager::setInteriorMapTexture(const int x, const int y) void WindowManager::setInteriorMapTexture(const int x, const int y)
{ {
map->setActiveCell(x,y, true); mMap->setActiveCell(x,y, true);
hud->setActiveCell(x,y, true); mHud->setActiveCell(x,y, true);
} }
void WindowManager::setPlayerPos(const float x, const float y) void WindowManager::setPlayerPos(const float x, const float y)
{ {
map->setPlayerPos(x,y); mMap->setPlayerPos(x,y);
hud->setPlayerPos(x,y); mHud->setPlayerPos(x,y);
} }
void WindowManager::setPlayerDir(const float x, const float y) void WindowManager::setPlayerDir(const float x, const float y)
{ {
map->setPlayerDir(x,y); mMap->setPlayerDir(x,y);
hud->setPlayerDir(x,y); mHud->setPlayerDir(x,y);
} }
void WindowManager::setHMSVisibility(bool visible) void WindowManager::setHMSVisibility(bool visible)
{ {
hud->setBottomLeftVisibility(visible, hud->weapBox->getVisible(), hud->spellBox->getVisible()); mHud->setBottomLeftVisibility(visible, mHud->mWeapBox->getVisible(), mHud->mSpellBox->getVisible());
} }
void WindowManager::setMinimapVisibility(bool visible) void WindowManager::setMinimapVisibility(bool visible)
{ {
hud->setBottomRightVisibility(hud->effectBox->getVisible(), visible); mHud->setBottomRightVisibility(mHud->mEffectBox->getVisible(), visible);
} }
void WindowManager::toggleFogOfWar() void WindowManager::toggleFogOfWar()
{ {
map->toggleFogOfWar(); mMap->toggleFogOfWar();
hud->toggleFogOfWar(); mHud->toggleFogOfWar();
} }
void WindowManager::setFocusObject(const MWWorld::Ptr& focus) void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
@ -587,13 +587,13 @@ bool WindowManager::getFullHelp() const
void WindowManager::setWeaponVisibility(bool visible) void WindowManager::setWeaponVisibility(bool visible)
{ {
hud->setBottomLeftVisibility(hud->health->getVisible(), visible, hud->spellBox->getVisible()); mHud->setBottomLeftVisibility(mHud->health->getVisible(), visible, mHud->mSpellBox->getVisible());
} }
void WindowManager::setSpellVisibility(bool visible) void WindowManager::setSpellVisibility(bool visible)
{ {
hud->setBottomLeftVisibility(hud->health->getVisible(), hud->weapBox->getVisible(), visible); mHud->setBottomLeftVisibility(mHud->health->getVisible(), mHud->mWeapBox->getVisible(), visible);
hud->setBottomRightVisibility(visible, hud->minimapBox->getVisible()); mHud->setBottomRightVisibility(visible, mHud->mMinimapBox->getVisible());
} }
void WindowManager::setMouseVisible(bool visible) void WindowManager::setMouseVisible(bool visible)
@ -618,7 +618,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed) void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
{ {
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD")); mHud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI")); mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));
bool changeRes = false; bool changeRes = false;
@ -637,8 +637,8 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
{ {
int x = Settings::Manager::getInt("resolution x", "Video"); int x = Settings::Manager::getInt("resolution x", "Video");
int y = Settings::Manager::getInt("resolution y", "Video"); int y = Settings::Manager::getInt("resolution y", "Video");
hud->onResChange(x, y); mHud->onResChange(x, y);
console->onResChange(x, y); mConsole->onResChange(x, y);
mSettingsWindow->center(); mSettingsWindow->center();
mAlchemyWindow->center(); mAlchemyWindow->center();
mScrollWindow->center(); mScrollWindow->center();
@ -649,7 +649,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
void WindowManager::pushGuiMode(GuiMode mode) void WindowManager::pushGuiMode(GuiMode mode)
{ {
if (mode==GM_Inventory && allowed==GW_None) if (mode==GM_Inventory && mAllowed==GW_None)
return; return;
mGuiModes.push_back(mode); mGuiModes.push_back(mode);
@ -690,32 +690,32 @@ void WindowManager::removeGuiMode(GuiMode mode)
void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent) void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent)
{ {
hud->setSelectedSpell(spellId, successChancePercent); mHud->setSelectedSpell(spellId, successChancePercent);
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
mSpellWindow->setTitle(spell->name); mSpellWindow->setTitle(spell->name);
} }
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
{ {
hud->setSelectedEnchantItem(item, chargePercent); mHud->setSelectedEnchantItem(item, chargePercent);
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item)); mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
} }
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
{ {
hud->setSelectedWeapon(item, durabilityPercent); mHud->setSelectedWeapon(item, durabilityPercent);
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item)); mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
} }
void WindowManager::unsetSelectedSpell() void WindowManager::unsetSelectedSpell()
{ {
hud->unsetSelectedSpell(); mHud->unsetSelectedSpell();
mSpellWindow->setTitle("#{sNone}"); mSpellWindow->setTitle("#{sNone}");
} }
void WindowManager::unsetSelectedWeapon() void WindowManager::unsetSelectedWeapon()
{ {
hud->unsetSelectedWeapon(); mHud->unsetSelectedWeapon();
mInventoryWindow->setTitle("#{sSkillHandtohand}"); mInventoryWindow->setTitle("#{sSkillHandtohand}");
} }
@ -738,5 +738,10 @@ void WindowManager::getMousePosition(float &x, float &y)
bool WindowManager::getWorldMouseOver() bool WindowManager::getWorldMouseOver()
{ {
return hud->getWorldMouseOver(); return mHud->getWorldMouseOver();
}
void WindowManager::executeInConsole (const std::string& path)
{
mConsole->executeFile (path);
} }

@ -10,10 +10,6 @@
this class. this class.
**/ **/
#include <string>
#include <vector>
#include <set>
#include "MyGUI_UString.h" #include "MyGUI_UString.h"
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
@ -98,7 +94,7 @@ namespace MWGui
typedef std::vector<Faction> FactionList; typedef std::vector<Faction> FactionList;
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath); WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts);
virtual ~WindowManager(); virtual ~WindowManager();
/** /**
@ -123,27 +119,27 @@ namespace MWGui
void toggleVisible(GuiWindow wnd) void toggleVisible(GuiWindow wnd)
{ {
shown = (shown & wnd) ? (GuiWindow) (shown & ~wnd) : (GuiWindow) (shown | wnd); mShown = (mShown & wnd) ? (GuiWindow) (mShown & ~wnd) : (GuiWindow) (mShown | wnd);
updateVisible(); updateVisible();
} }
// Disallow all inventory mode windows // Disallow all inventory mode windows
void disallowAll() void disallowAll()
{ {
allowed = GW_None; mAllowed = GW_None;
updateVisible(); updateVisible();
} }
// Allow one or more windows // Allow one or more windows
void allow(GuiWindow wnd) void allow(GuiWindow wnd)
{ {
allowed = (GuiWindow)(allowed | wnd); mAllowed = (GuiWindow)(mAllowed | wnd);
updateVisible(); updateVisible();
} }
bool isAllowed(GuiWindow wnd) const bool isAllowed(GuiWindow wnd) const
{ {
return allowed & wnd; return mAllowed & wnd;
} }
MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;} MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;}
@ -155,9 +151,9 @@ namespace MWGui
MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;} MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;} MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;} MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
MWGui::Console* getConsole() {return console;} MWGui::Console* getConsole() {return mConsole;}
MyGUI::Gui* getGui() const { return gui; } MyGUI::Gui* getGui() const { return mGui; }
void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount)
{ {
@ -223,10 +219,10 @@ namespace MWGui
void onFrame (float frameDuration); void onFrame (float frameDuration);
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > getPlayerSkillValues() { return playerSkillValues; } std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > getPlayerSkillValues() { return mPlayerSkillValues; }
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > getPlayerAttributeValues() { return playerAttributes; } std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > getPlayerAttributeValues() { return mPlayerAttributes; }
SkillList getPlayerMinorSkills() { return playerMinorSkills; } SkillList getPlayerMinorSkills() { return mPlayerMinorSkills; }
SkillList getPlayerMajorSkills() { return playerMajorSkills; } SkillList getPlayerMajorSkills() { return mPlayerMajorSkills; }
/** /**
* Fetches a GMST string from the store, if there is no setting with the given * Fetches a GMST string from the store, if there is no setting with the given
@ -241,15 +237,17 @@ namespace MWGui
void processChangedSettings(const Settings::CategorySettingVector& changed); void processChangedSettings(const Settings::CategorySettingVector& changed);
void executeInConsole (const std::string& path);
private: private:
OEngine::GUI::MyGUIManager *mGuiManager; OEngine::GUI::MyGUIManager *mGuiManager;
HUD *hud; HUD *mHud;
MapWindow *map; MapWindow *mMap;
MainMenu *menu; MainMenu *mMenu;
ToolTips *mToolTips; ToolTips *mToolTips;
StatsWindow *mStatsWindow; StatsWindow *mStatsWindow;
MessageBoxManager *mMessageBoxManager; MessageBoxManager *mMessageBoxManager;
Console *console; Console *mConsole;
JournalWindow* mJournal; JournalWindow* mJournal;
DialogueWindow *mDialogueWindow; DialogueWindow *mDialogueWindow;
ContainerWindow *mContainerWindow; ContainerWindow *mContainerWindow;
@ -267,33 +265,33 @@ namespace MWGui
CharacterCreation* mCharGen; CharacterCreation* mCharGen;
// Various stats about player as needed by window manager // Various stats about player as needed by window manager
ESM::Class playerClass; ESM::Class mPlayerClass;
std::string playerName; std::string mPlayerName;
std::string playerRaceId; std::string mPlayerRaceId;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes; std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > mPlayerAttributes;
SkillList playerMajorSkills, playerMinorSkills; SkillList mPlayerMajorSkills, mPlayerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues; std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > mPlayerSkillValues;
MWMechanics::DynamicStat<int> playerHealth, playerMagicka, playerFatigue; MWMechanics::DynamicStat<int> mPlayerHealth, mPlayerMagicka, mPlayerFatigue;
MyGUI::Gui *gui; // Gui MyGUI::Gui *mGui; // Gui
std::vector<GuiMode> mGuiModes; std::vector<GuiMode> mGuiModes;
std::vector<OEngine::GUI::Layout*> garbageDialogs; std::vector<OEngine::GUI::Layout*> mGarbageDialogs;
void cleanupGarbage(); void cleanupGarbage();
GuiWindow shown; // Currently shown windows in inventory mode GuiWindow mShown; // Currently shown windows in inventory mode
/* Currently ALLOWED windows in inventory mode. This is used at /* Currently ALLOWED windows in inventory mode. This is used at
the start of the game, when windows are enabled one by one the start of the game, when windows are enabled one by one
through script commands. You can manipulate this through using through script commands. You can manipulate this through using
allow() and disableAll(). allow() and disableAll().
*/ */
GuiWindow allowed; GuiWindow mAllowed;
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
int showFPSLevel; int mShowFPSLevel;
float mFPS; float mFPS;
unsigned int mTriangleCount; unsigned int mTriangleCount;
unsigned int mBatchCount; unsigned int mBatchCount;

@ -90,6 +90,7 @@ namespace MWInput
bool mDragDrop; bool mDragDrop;
std::map<std::string, bool> mControlSwitch;
/* InputImpl Methods */ /* InputImpl Methods */
public: public:
@ -102,15 +103,15 @@ private:
{ {
if (windows.isGuiMode()) return; if (windows.isGuiMode()) return;
DrawState state = player.getDrawState(); MWMechanics::DrawState_ state = player.getDrawState();
if (state == DrawState_Weapon || state == DrawState_Nothing) if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing)
{ {
player.setDrawState(DrawState_Spell); player.setDrawState(MWMechanics::DrawState_Spell);
std::cout << "Player has now readied his hands for spellcasting!\n"; std::cout << "Player has now readied his hands for spellcasting!\n";
} }
else else
{ {
player.setDrawState(DrawState_Nothing); player.setDrawState(MWMechanics::DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n"; std::cout << "Player does not have any kind of attack ready now.\n";
} }
} }
@ -119,15 +120,15 @@ private:
{ {
if (windows.isGuiMode()) return; if (windows.isGuiMode()) return;
DrawState state = player.getDrawState(); MWMechanics::DrawState_ state = player.getDrawState();
if (state == DrawState_Spell || state == DrawState_Nothing) if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
{ {
player.setDrawState(DrawState_Weapon); player.setDrawState(MWMechanics::DrawState_Weapon);
std::cout << "Player is now drawing his weapon.\n"; std::cout << "Player is now drawing his weapon.\n";
} }
else else
{ {
player.setDrawState(DrawState_Nothing); player.setDrawState(MWMechanics::DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n"; std::cout << "Player does not have any kind of attack ready now.\n";
} }
} }
@ -336,9 +337,17 @@ private:
poller.bind(A_MoveRight, KC_D); poller.bind(A_MoveRight, KC_D);
poller.bind(A_MoveForward, KC_W); poller.bind(A_MoveForward, KC_W);
poller.bind(A_MoveBackward, KC_S); poller.bind(A_MoveBackward, KC_S);
poller.bind(A_Jump, KC_E); poller.bind(A_Jump, KC_E);
poller.bind(A_Crouch, KC_LCONTROL); poller.bind(A_Crouch, KC_LCONTROL);
mControlSwitch["playercontrols"] = true;
mControlSwitch["playerfighting"] = true;
mControlSwitch["playerjumping"] = true;
mControlSwitch["playerlooking"] = true;
mControlSwitch["playermagic"] = true;
mControlSwitch["playerviewswitch"] = true;
mControlSwitch["vanitymode"] = true;
} }
void setDragDrop(bool dragDrop) void setDragDrop(bool dragDrop)
@ -366,33 +375,35 @@ private:
// Configure player movement according to keyboard input. Actual movement will // Configure player movement according to keyboard input. Actual movement will
// be done in the physics system. // be done in the physics system.
if (poller.isDown(A_MoveLeft)) if (mControlSwitch["playercontrols"]) {
{ if (poller.isDown(A_MoveLeft))
player.setAutoMove (false); {
player.setLeftRight (1); player.setAutoMove (false);
} player.setLeftRight (1);
else if (poller.isDown(A_MoveRight)) }
{ else if (poller.isDown(A_MoveRight))
player.setAutoMove (false); {
player.setLeftRight (-1); player.setAutoMove (false);
} player.setLeftRight (-1);
else }
player.setLeftRight (0); else
player.setLeftRight (0);
if (poller.isDown(A_MoveForward))
{ if (poller.isDown(A_MoveForward))
player.setAutoMove (false); {
player.setForwardBackward (1); player.setAutoMove (false);
} player.setForwardBackward (1);
else if (poller.isDown(A_MoveBackward)) }
{ else if (poller.isDown(A_MoveBackward))
player.setAutoMove (false); {
player.setForwardBackward (-1); player.setAutoMove (false);
player.setForwardBackward (-1);
}
else
player.setForwardBackward (0);
} }
else
player.setForwardBackward (0);
if (poller.isDown(A_Jump)) if (poller.isDown(A_Jump) && mControlSwitch["playerjumping"])
player.setUpDown (1); player.setUpDown (1);
else if (poller.isDown(A_Crouch)) else if (poller.isDown(A_Crouch))
player.setUpDown (-1); player.setUpDown (-1);
@ -423,6 +434,24 @@ private:
guiEvents->enabled = false; guiEvents->enabled = false;
} }
} }
void toggleControlSwitch(std::string sw, bool value)
{
if (mControlSwitch[sw] == value) {
return;
}
/// \note 7 switches at all, if-else is relevant
if (sw == "playercontrols") {
player.setLeftRight(0);
player.setForwardBackward(0);
player.setAutoMove(false);
} else if (sw == "playerjumping") {
/// \fixme maybe crouching at this time
player.setUpDown(0);
}
mControlSwitch[sw] = value;
}
}; };
/***CONSTRUCTOR***/ /***CONSTRUCTOR***/
@ -471,4 +500,9 @@ private:
if (changeRes) if (changeRes)
impl->adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video")); impl->adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video"));
} }
void MWInputManager::toggleControlSwitch(std::string sw, bool value)
{
impl->toggleControlSwitch(sw, value);
}
} }

@ -57,6 +57,8 @@ namespace MWInput
void processChangedSettings(const Settings::CategorySettingVector& changed); void processChangedSettings(const Settings::CategorySettingVector& changed);
void setDragDrop(bool dragDrop); void setDragDrop(bool dragDrop);
void toggleControlSwitch(std::string sw, bool value);
}; };
} }
#endif #endif

@ -3,6 +3,9 @@
#include <cstdlib> #include <cstdlib>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadspel.hpp>
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -43,14 +46,13 @@ namespace MWMechanics
for (TIterator iter (begin()); iter!=end(); ++iter) for (TIterator iter (begin()); iter!=end(); ++iter)
{ {
const ESM::Spell& spell = const ESM::EffectList& effects = getEffectList (iter->first);
*MWBase::Environment::get().getWorld()->getStore().spells.find (iter->first);
const MWWorld::TimeStamp& start = iter->second.first; const MWWorld::TimeStamp& start = iter->second.first;
float magnitude = iter->second.second; float magnitude = iter->second.second;
for (std::vector<ESM::ENAMstruct>::const_iterator iter (spell.effects.list.begin()); for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.list.begin());
iter!=spell.effects.list.end(); ++iter) iter!=effects.list.end(); ++iter)
{ {
if (iter->duration) if (iter->duration)
{ {
@ -71,18 +73,31 @@ namespace MWMechanics
} }
} }
const ESM::EffectList& ActiveSpells::getEffectList (const std::string& id) const
{
if (const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().spells.search (id))
return spell->effects;
if (const ESM::Potion *potion =
MWBase::Environment::get().getWorld()->getStore().potions.search (id))
return potion->effects;
throw std::runtime_error ("ID " + id + " can not produce lasting effects");
}
ActiveSpells::ActiveSpells() ActiveSpells::ActiveSpells()
: mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp()) : mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp())
{} {}
void ActiveSpells::addSpell (const std::string& id) bool ActiveSpells::addSpell (const std::string& id)
{ {
const ESM::Spell& spell = *MWBase::Environment::get().getWorld()->getStore().spells.find (id); const ESM::EffectList& effects = getEffectList (id);
bool found = false; bool found = false;
for (std::vector<ESM::ENAMstruct>::const_iterator iter (spell.effects.list.begin()); for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.list.begin());
iter!=spell.effects.list.end(); ++iter) iter!=effects.list.end(); ++iter)
{ {
if (iter->duration) if (iter->duration)
{ {
@ -92,7 +107,7 @@ namespace MWMechanics
} }
if (!found) if (!found)
return; return false;
TContainer::iterator iter = mSpells.find (id); TContainer::iterator iter = mSpells.find (id);
@ -105,6 +120,8 @@ namespace MWMechanics
iter->second = std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random); iter->second = std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random);
mSpellsChanged = true; mSpellsChanged = true;
return true;
} }
void ActiveSpells::removeSpell (const std::string& id) void ActiveSpells::removeSpell (const std::string& id)
@ -138,13 +155,12 @@ namespace MWMechanics
double ActiveSpells::timeToExpire (const TIterator& iterator) const double ActiveSpells::timeToExpire (const TIterator& iterator) const
{ {
const ESM::Spell& spell = const ESM::EffectList& effects = getEffectList (iterator->first);
*MWBase::Environment::get().getWorld()->getStore().spells.find (iterator->first);
int duration = 0; int duration = 0;
for (std::vector<ESM::ENAMstruct>::const_iterator iter (spell.effects.list.begin()); for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.list.begin());
iter!=spell.effects.list.end(); ++iter) iter!=effects.list.end(); ++iter)
{ {
if (iter->duration>duration) if (iter->duration>duration)
duration = iter->duration; duration = iter->duration;

@ -12,11 +12,15 @@
namespace ESM namespace ESM
{ {
struct Spell; struct Spell;
struct EffectList;
} }
namespace MWMechanics namespace MWMechanics
{ {
/// \brief Lasting spell effects /// \brief Lasting spell effects
///
/// \note The name of this class is slightly misleading, since it also handels lasting potion
/// effects.
class ActiveSpells class ActiveSpells
{ {
public: public:
@ -33,13 +37,17 @@ namespace MWMechanics
void update() const; void update() const;
const ESM::EffectList& getEffectList (const std::string& id) const;
public: public:
ActiveSpells(); ActiveSpells();
void addSpell (const std::string& id); bool addSpell (const std::string& id);
///< Overwrites an existing spell with the same ID. If the spell does not have any ///< Overwrites an existing spell with the same ID. If the spell does not have any
/// non-instant effects, it is ignored. /// non-instant effects, it is ignored.
///
/// \return Has the spell been added?
void removeSpell (const std::string& id); void removeSpell (const std::string& id);

@ -18,22 +18,8 @@ namespace MWMechanics
{ {
// magic effects // magic effects
adjustMagicEffects (ptr); adjustMagicEffects (ptr);
calculateCreatureStatModifiers (ptr);
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); calculateDynamicStats (ptr);
// calculate dynamic stats
int strength = creatureStats.mAttributes[0].getBase();
int intelligence = creatureStats.mAttributes[1].getBase();
int willpower = creatureStats.mAttributes[2].getBase();
int agility = creatureStats.mAttributes[3].getBase();
int endurance = creatureStats.mAttributes[5].getBase();
double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5;
creatureStats.mDynamic[0].setBase (static_cast<int> (0.5 * (strength + endurance)));
creatureStats.mDynamic[1].setBase (static_cast<int> (intelligence +
magickaFactor * intelligence));
creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance);
} }
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused) void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
@ -47,7 +33,7 @@ namespace MWMechanics
{ {
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature); CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
MagicEffects now = creatureStats.mSpells.getMagicEffects(); MagicEffects now = creatureStats.getSpells().getMagicEffects();
if (creature.getTypeName()==typeid (ESM::NPC).name()) if (creature.getTypeName()==typeid (ESM::NPC).name())
{ {
@ -55,15 +41,64 @@ namespace MWMechanics
now += store.getMagicEffects(); now += store.getMagicEffects();
} }
now += creatureStats.mActiveSpells.getMagicEffects(); now += creatureStats.getActiveSpells().getMagicEffects();
MagicEffects diff = MagicEffects::diff (creatureStats.mMagicEffects, now); MagicEffects diff = MagicEffects::diff (creatureStats.getMagicEffects(), now);
creatureStats.mMagicEffects = now; creatureStats.setMagicEffects(now);
// TODO apply diff to other stats // TODO apply diff to other stats
} }
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
{
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
int strength = creatureStats.getAttribute(0).getBase();
int intelligence = creatureStats.getAttribute(1).getBase();
int willpower = creatureStats.getAttribute(2).getBase();
int agility = creatureStats.getAttribute(3).getBase();
int endurance = creatureStats.getAttribute(5).getBase();
double magickaFactor =
creatureStats.getMagicEffects().get (EffectKey (84)).mMagnitude * 0.1 + 0.5;
creatureStats.getHealth().setBase(
static_cast<int> (0.5 * (strength + endurance)));
creatureStats.getMagicka().setBase(
static_cast<int> (intelligence + magickaFactor * intelligence));
creatureStats.getFatigue().setBase(strength+willpower+agility+endurance);
}
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
{
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
// attributes
for (int i=0; i<5; ++i)
{
int modifier =
creatureStats.getMagicEffects().get (EffectKey (79, i)).mMagnitude;
modifier -= creatureStats.getMagicEffects().get (EffectKey (17, i)).mMagnitude;
creatureStats.getAttribute(i).setModifier (modifier);
}
// dynamic stats
MagicEffects effects = creatureStats.getMagicEffects();
creatureStats.getHealth().setModifier(
effects.get(EffectKey(80)).mMagnitude - effects.get(EffectKey(18)).mMagnitude);
creatureStats.getMagicka().setModifier(
effects.get(EffectKey(81)).mMagnitude - effects.get(EffectKey(19)).mMagnitude);
creatureStats.getFatigue().setModifier(
effects.get(EffectKey(82)).mMagnitude - effects.get(EffectKey(20)).mMagnitude);
}
Actors::Actors() : mDuration (0) {} Actors::Actors() : mDuration (0) {}
void Actors::addActor (const MWWorld::Ptr& ptr) void Actors::addActor (const MWWorld::Ptr& ptr)
@ -99,15 +134,16 @@ namespace MWMechanics
if (mDuration>=0.25) if (mDuration>=0.25)
{ {
float totalDuration = mDuration;
mDuration = 0;
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter) for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter)
{ {
updateActor (*iter, mDuration); updateActor (*iter, totalDuration);
if (iter->getTypeName()==typeid (ESM::NPC).name()) if (iter->getTypeName()==typeid (ESM::NPC).name())
updateNpc (*iter, mDuration, paused); updateNpc (*iter, totalDuration, paused);
} }
mDuration = 0;
} }
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end();

@ -27,6 +27,10 @@ namespace MWMechanics
void adjustMagicEffects (const MWWorld::Ptr& creature); void adjustMagicEffects (const MWWorld::Ptr& creature);
void calculateDynamicStats (const MWWorld::Ptr& ptr);
void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr);
public: public:
Actors(); Actors();

@ -0,0 +1,48 @@
#include "creaturestats.hpp"
namespace MWMechanics
{
CreatureStats::CreatureStats()
{}
// Can't use all benefits of members initialization because of
// lack of copy constructors
CreatureStats::CreatureStats(const CreatureStats &orig)
: mLevel(orig.mLevel), mHello(orig.mHello), mFight(orig.mFight),
mFlee(orig.mFlee), mAlarm(orig.mAlarm)
{
for (int i = 0; i < 8; ++i) {
mAttributes[i] = orig.mAttributes[i];
}
for (int i = 0; i < 3; ++i) {
mDynamic[i] = orig.mDynamic[i];
}
mSpells = orig.mSpells;
mActiveSpells = orig.mActiveSpells;
mMagicEffects = orig.mMagicEffects;
}
CreatureStats::~CreatureStats()
{}
const CreatureStats &
CreatureStats::operator=(const CreatureStats &orig)
{
for (int i = 0; i < 8; ++i) {
mAttributes[i] = orig.mAttributes[i];
}
for (int i = 0; i < 3; ++i) {
mDynamic[i] = orig.mDynamic[i];
}
mLevel = orig.mLevel;
mSpells = orig.mSpells;
mActiveSpells = orig.mActiveSpells;
mMagicEffects = orig.mMagicEffects;
mHello = orig.mHello;
mFight = orig.mFight;
mFlee = orig.mFlee;
mAlarm = orig.mAlarm;
return *this;
}
}

@ -3,6 +3,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include <stdexcept>
#include "stat.hpp" #include "stat.hpp"
#include "magiceffects.hpp" #include "magiceffects.hpp"
@ -11,7 +12,10 @@
namespace MWMechanics namespace MWMechanics
{ {
struct CreatureStats /// \brief Common creature stats
///
///
class CreatureStats
{ {
Stat<int> mAttributes[8]; Stat<int> mAttributes[8];
DynamicStat<int> mDynamic[3]; // health, magicka, fatigue DynamicStat<int> mDynamic[3]; // health, magicka, fatigue
@ -23,7 +27,258 @@ namespace MWMechanics
int mFight; int mFight;
int mFlee; int mFlee;
int mAlarm; int mAlarm;
public:
CreatureStats();
CreatureStats(const CreatureStats &);
virtual ~CreatureStats();
const CreatureStats & operator=(const CreatureStats &);
const Stat<int> & getAttribute(int index) const;
const DynamicStat<int> & getHealth() const;
const DynamicStat<int> & getMagicka() const;
const DynamicStat<int> & getFatigue() const;
const Spells & getSpells() const;
const ActiveSpells & getActiveSpells() const;
const MagicEffects & getMagicEffects() const;
int getLevel() const;
int getHello() const;
int getFight() const;
int getFlee() const;
int getAlarm() const;
Stat<int> & getAttribute(int index);
DynamicStat<int> & getHealth();
DynamicStat<int> & getMagicka();
DynamicStat<int> & getFatigue();
DynamicStat<int> & getDynamic(int index);
Spells & getSpells();
ActiveSpells & getActiveSpells();
MagicEffects & getMagicEffects();
void setAttribute(int index, const Stat<int> &value);
void setHealth(const DynamicStat<int> &value);
void setMagicka(const DynamicStat<int> &value);
void setFatigue(const DynamicStat<int> &value);
void setSpells(const Spells &spells);
void setActiveSpells(const ActiveSpells &active);
void setMagicEffects(const MagicEffects &effects);
void setLevel(int level);
void setHello(int value);
void setFight(int value);
void setFlee(int value);
void setAlarm(int value);
}; };
// Inline const getters
inline const Stat<int> &
CreatureStats::getAttribute(int index) const {
if (index < 0 || index > 7) {
throw std::runtime_error("attribute index is out of range");
}
return mAttributes[index];
}
inline const DynamicStat<int> &
CreatureStats::getHealth() const {
return mDynamic[0];
}
inline const DynamicStat<int> &
CreatureStats::getMagicka() const {
return mDynamic[1];
}
inline const DynamicStat<int> &
CreatureStats::getFatigue() const {
return mDynamic[2];
}
inline const Spells &
CreatureStats::getSpells() const {
return mSpells;
}
inline const ActiveSpells &
CreatureStats::getActiveSpells() const {
return mActiveSpells;
}
inline const MagicEffects &
CreatureStats::getMagicEffects() const {
return mMagicEffects;
}
inline int
CreatureStats::getLevel() const {
return mLevel;
}
inline int
CreatureStats::getHello() const {
return mHello;
}
inline int
CreatureStats::getFight() const {
return mFight;
}
inline int
CreatureStats::getFlee() const {
return mFlee;
}
inline int
CreatureStats::getAlarm() const {
return mAlarm;
}
// Inline non-const getters
inline Stat<int> &
CreatureStats::getAttribute(int index) {
if (index < 0 || index > 7) {
throw std::runtime_error("attribute index is out of range");
}
return mAttributes[index];
}
inline DynamicStat<int> &
CreatureStats::getHealth() {
return mDynamic[0];
}
inline DynamicStat<int> &
CreatureStats::getMagicka() {
return mDynamic[1];
}
inline DynamicStat<int> &
CreatureStats::getFatigue() {
return mDynamic[2];
}
inline DynamicStat<int> &
CreatureStats::getDynamic(int index) {
if (index < 0 || index > 2) {
throw std::runtime_error("dynamic stat index is out of range");
}
return mDynamic[index];
}
inline Spells &
CreatureStats::getSpells() {
return mSpells;
}
inline void
CreatureStats::setSpells(const Spells &spells) {
mSpells = spells;
}
inline ActiveSpells &
CreatureStats::getActiveSpells() {
return mActiveSpells;
}
inline MagicEffects &
CreatureStats::getMagicEffects() {
return mMagicEffects;
}
// Inline setters
inline void
CreatureStats::setAttribute(int index, const Stat<int> &value) {
if (index < 0 || index > 7) {
throw std::runtime_error("attribute index is out of range");
}
mAttributes[index] = value;
}
inline void
CreatureStats::setHealth(const DynamicStat<int> &value) {
mDynamic[0] = value;
}
inline void
CreatureStats::setMagicka(const DynamicStat<int> &value) {
mDynamic[1] = value;
}
inline void
CreatureStats::setFatigue(const DynamicStat<int> &value) {
mDynamic[2] = value;
}
inline void
CreatureStats::setLevel(int level) {
mLevel = level;
}
inline void
CreatureStats::setActiveSpells(const ActiveSpells &active) {
mActiveSpells = active;
}
inline void
CreatureStats::setMagicEffects(const MagicEffects &effects) {
mMagicEffects = effects;
}
inline void
CreatureStats::setHello(int value) {
mHello = value;
}
inline void
CreatureStats::setFight(int value) {
mFight = value;
}
inline void
CreatureStats::setFlee(int value) {
mFlee = value;
}
inline void
CreatureStats::setAlarm(int value) {
mAlarm = value;
}
} }
#endif #endif

@ -1,13 +1,15 @@
#ifndef GAME_MWMECHANICS_DRAWSTATE_H #ifndef GAME_MWMECHANICS_DRAWSTATE_H
#define GAME_MWMECHANICS_DRAWSTATE_H #define GAME_MWMECHANICS_DRAWSTATE_H
#undef DrawState namespace MWMechanics
enum DrawState
{ {
DrawState_Weapon = 0, /// \note The _ suffix is required to avoid a collision with a Windoze macro. Die, Microsoft! Die!
DrawState_Spell = 1, enum DrawState_
DrawState_Nothing = 2, {
}; DrawState_Weapon = 0,
DrawState_Spell = 1,
DrawState_Nothing = 2,
};
}
#endif #endif

@ -23,21 +23,21 @@ namespace MWMechanics
const ESM::NPC *player = ptr.get<ESM::NPC>()->base; const ESM::NPC *player = ptr.get<ESM::NPC>()->base;
// reset // reset
creatureStats.mLevel = player->npdt52.level; creatureStats.setLevel(player->npdt52.level);
creatureStats.mSpells.clear(); creatureStats.getSpells().clear();
creatureStats.mMagicEffects = MagicEffects(); creatureStats.setMagicEffects(MagicEffects());
for (int i=0; i<27; ++i) for (int i=0; i<27; ++i)
npcStats.mSkill[i].setBase (player->npdt52.skills[i]); npcStats.getSkill (i).setBase (player->npdt52.skills[i]);
creatureStats.mAttributes[0].setBase (player->npdt52.strength); creatureStats.getAttribute(0).setBase (player->npdt52.strength);
creatureStats.mAttributes[1].setBase (player->npdt52.intelligence); creatureStats.getAttribute(1).setBase (player->npdt52.intelligence);
creatureStats.mAttributes[2].setBase (player->npdt52.willpower); creatureStats.getAttribute(2).setBase (player->npdt52.willpower);
creatureStats.mAttributes[3].setBase (player->npdt52.agility); creatureStats.getAttribute(3).setBase (player->npdt52.agility);
creatureStats.mAttributes[4].setBase (player->npdt52.speed); creatureStats.getAttribute(4).setBase (player->npdt52.speed);
creatureStats.mAttributes[5].setBase (player->npdt52.endurance); creatureStats.getAttribute(5).setBase (player->npdt52.endurance);
creatureStats.mAttributes[6].setBase (player->npdt52.personality); creatureStats.getAttribute(6).setBase (player->npdt52.personality);
creatureStats.mAttributes[7].setBase (player->npdt52.luck); creatureStats.getAttribute(7).setBase (player->npdt52.luck);
// race // race
if (mRaceSelected) if (mRaceSelected)
@ -63,7 +63,7 @@ namespace MWMechanics
case 7: attribute = &race->data.luck; break; case 7: attribute = &race->data.luck; break;
} }
creatureStats.mAttributes[i].setBase ( creatureStats.getAttribute(i).setBase (
static_cast<int> (male ? attribute->male : attribute->female)); static_cast<int> (male ? attribute->male : attribute->female));
} }
@ -73,15 +73,15 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + race->data.bonus[i].bonus); npcStats.getSkill (index).getBase() + race->data.bonus[i].bonus);
} }
} }
for (std::vector<std::string>::const_iterator iter (race->powers.list.begin()); for (std::vector<std::string>::const_iterator iter (race->powers.list.begin());
iter!=race->powers.list.end(); ++iter) iter!=race->powers.list.end(); ++iter)
{ {
creatureStats.mSpells.add (*iter); creatureStats.getSpells().add (*iter);
} }
} }
@ -95,7 +95,7 @@ namespace MWMechanics
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin()); for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
iter!=sign->powers.list.end(); ++iter) iter!=sign->powers.list.end(); ++iter)
{ {
creatureStats.mSpells.add (*iter); creatureStats.getSpells().add (*iter);
} }
} }
@ -109,8 +109,8 @@ namespace MWMechanics
int attribute = class_.data.attribute[i]; int attribute = class_.data.attribute[i];
if (attribute>=0 && attribute<8) if (attribute>=0 && attribute<8)
{ {
creatureStats.mAttributes[attribute].setBase ( creatureStats.getAttribute(attribute).setBase (
creatureStats.mAttributes[attribute].getBase() + 10); creatureStats.getAttribute(attribute).getBase() + 10);
} }
} }
@ -124,8 +124,8 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + bonus); npcStats.getSkill (index).getBase() + bonus);
} }
} }
} }
@ -141,8 +141,8 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + 5); npcStats.getSkill (index).getBase() + 5);
} }
} }
} }
@ -151,8 +151,9 @@ namespace MWMechanics
// forced update and current value adjustments // forced update and current value adjustments
mActors.updateActor (ptr, 0); mActors.updateActor (ptr, 0);
for (int i=0; i<3; ++i) creatureStats.getHealth().setCurrent(creatureStats.getHealth().getModified());
creatureStats.mDynamic[i].setCurrent (creatureStats.mDynamic[i].getModified()); creatureStats.getMagicka().setCurrent(creatureStats.getMagicka().getModified());
creatureStats.getFatigue().setCurrent(creatureStats.getFatigue().getModified());
} }
@ -213,22 +214,25 @@ namespace MWMechanics
for (int i=0; i<8; ++i) for (int i=0; i<8; ++i)
{ {
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i]) if (stats.getAttribute(i)!=mWatchedCreature.getAttribute(i))
{ {
mWatchedCreature.mAttributes[i] = stats.mAttributes[i]; mWatchedCreature.setAttribute(i, stats.getAttribute(i));
MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.mAttributes[i]); MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.getAttribute(i));
} }
} }
for (int i=0; i<3; ++i) if (stats.getHealth() != mWatchedCreature.getHealth()) {
{ mWatchedCreature.setHealth(stats.getHealth());
if (stats.mDynamic[i]!=mWatchedCreature.mDynamic[i]) MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[0], stats.getHealth());
{ }
mWatchedCreature.mDynamic[i] = stats.mDynamic[i]; if (stats.getMagicka() != mWatchedCreature.getMagicka()) {
mWatchedCreature.setMagicka(stats.getMagicka());
MWBase::Environment::get().getWindowManager()->setValue (dynamicNames[i], stats.mDynamic[i]); MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[1], stats.getMagicka());
} }
if (stats.getFatigue() != mWatchedCreature.getFatigue()) {
mWatchedCreature.setFatigue(stats.getFatigue());
MWBase::Environment::get().getWindowManager()->setValue(dynamicNames[2], stats.getFatigue());
} }
bool update = false; bool update = false;
@ -236,18 +240,18 @@ namespace MWMechanics
//Loop over ESM::Skill::SkillEnum //Loop over ESM::Skill::SkillEnum
for(int i = 0; i < 27; ++i) for(int i = 0; i < 27; ++i)
{ {
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i]) if(npcStats.getSkill (i) != mWatchedNpc.getSkill (i))
{ {
update = true; update = true;
mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; mWatchedNpc.getSkill (i) = npcStats.getSkill (i);
MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.getSkill (i));
} }
} }
if (update) if (update)
MWBase::Environment::get().getWindowManager()->updateSkillArea(); MWBase::Environment::get().getWindowManager()->updateSkillArea();
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.mLevel); MWBase::Environment::get().getWindowManager()->setValue ("level", stats.getLevel());
} }
if (mUpdatePlayer) if (mUpdatePlayer)

@ -0,0 +1,140 @@
#include "npcstats.hpp"
#include <cmath>
#include <stdexcept>
#include <components/esm/loadskil.hpp>
#include <components/esm/loadclas.hpp>
#include <components/esm/loadgmst.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
MWMechanics::NpcStats::NpcStats()
: mMovementFlags (0), mDrawState (DrawState_Nothing)
{}
MWMechanics::DrawState_ MWMechanics::NpcStats::getDrawState() const
{
return mDrawState;
}
void MWMechanics::NpcStats::setDrawState (DrawState_ state)
{
mDrawState = state;
}
bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const
{
return mMovementFlags & flag;
}
void MWMechanics::NpcStats::setMovementFlag (Flag flag, bool state)
{
if (state)
mMovementFlags |= flag;
else
mMovementFlags &= ~flag;
}
const MWMechanics::Stat<float>& MWMechanics::NpcStats::getSkill (int index) const
{
if (index<0 || index>=27)
throw std::runtime_error ("skill index out of range");
return mSkill[index];
}
MWMechanics::Stat<float>& MWMechanics::NpcStats::getSkill (int index)
{
if (index<0 || index>=27)
throw std::runtime_error ("skill index out of range");
return mSkill[index];
}
std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks()
{
return mFactionRank;
}
const std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks() const
{
return mFactionRank;
}
float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& class_, int usageType,
int level) const
{
if (level<0)
level = static_cast<int> (getSkill (skillIndex).getBase());
const ESM::Skill *skill = MWBase::Environment::get().getWorld()->getStore().skills.find (skillIndex);
float skillFactor = 1;
if (usageType>=4)
throw std::runtime_error ("skill usage type out of range");
if (usageType>0)
{
skillFactor = skill->data.useValue[usageType];
if (skillFactor<=0)
throw std::runtime_error ("invalid skill gain factor");
}
float typeFactor =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->f;
for (int i=0; i<5; ++i)
if (class_.data.skills[i][0]==skillIndex)
{
typeFactor =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->f;
break;
}
for (int i=0; i<5; ++i)
if (class_.data.skills[i][1]==skillIndex)
{
typeFactor =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->f;
break;
}
if (typeFactor<=0)
throw std::runtime_error ("invalid skill type factor");
float specialisationFactor = 1;
if (skill->data.specialization==class_.data.specialization)
{
specialisationFactor =
MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->f;
if (specialisationFactor<=0)
throw std::runtime_error ("invalid skill specialisation factor");
}
return 1.0 / (level +1) * (1.0 / skillFactor) * typeFactor * specialisationFactor;
}
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
{
float base = getSkill (skillIndex).getBase();
int level = static_cast<int> (base);
base += getSkillGain (skillIndex, class_, usageType);
if (static_cast<int> (base)!=level)
base = level+1;
getSkill (skillIndex).setBase (base);
}

@ -3,10 +3,16 @@
#include <map> #include <map>
#include <set> #include <set>
#include <string>
#include "stat.hpp" #include "stat.hpp"
#include "drawstate.hpp" #include "drawstate.hpp"
namespace ESM
{
struct Class;
}
namespace MWMechanics namespace MWMechanics
{ {
/// \brief Additional stats for NPCs /// \brief Additional stats for NPCs
@ -16,24 +22,57 @@ namespace MWMechanics
/// \note For technical reasons the spell list and the currently selected spell is also handled by /// \note For technical reasons the spell list and the currently selected spell is also handled by
/// CreatureStats, even though they are actually NPC stats. /// CreatureStats, even though they are actually NPC stats.
struct NpcStats class NpcStats
{ {
// NPCs other than the player can only have one faction. But for the sake of consistency public:
// we use the same data structure for the PC and the NPCs.
/// \note the faction key must be in lowercase enum Flag
std::map<std::string, int> mFactionRank; {
Flag_ForceRun = 1,
Stat<float> mSkill[27]; Flag_ForceSneak = 2,
Flag_Run = 4,
bool mForceRun; Flag_Sneak = 8
bool mForceSneak; };
bool mRun;
bool mSneak; private:
bool mCombat;
DrawState mDrawState; /// NPCs other than the player can only have one faction. But for the sake of consistency
/// we use the same data structure for the PC and the NPCs.
NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), /// \note the faction key must be in lowercase
mCombat (false) , mDrawState(DrawState_Nothing) {} std::map<std::string, int> mFactionRank;
DrawState_ mDrawState;
unsigned int mMovementFlags;
Stat<float> mSkill[27];
public:
NpcStats();
DrawState_ getDrawState() const;
void setDrawState (DrawState_ state);
bool getMovementFlag (Flag flag) const;
void setMovementFlag (Flag flag, bool state);
const Stat<float>& getSkill (int index) const;
Stat<float>& getSkill (int index);
std::map<std::string, int>& getFactionRanks();
const std::map<std::string, int>& getFactionRanks() const;
float getSkillGain (int skillIndex, const ESM::Class& class_, int usageType = -1,
int level = -1) const;
///< \param usageType: Usage specific factor, specified in the respective skill record;
/// -1: use a factor of 1.0 instead.
/// \param level Level to base calculation on; -1: use current level.
void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1);
///< Increase skill by usage.
}; };
} }

@ -41,7 +41,7 @@ namespace MWMechanics
{ {
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID); const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID);
int _school = effect->data.school; int _school = effect->data.school;
int _skillLevel = stats.mSkill[spellSchoolToSkill(_school)].getModified(); int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified();
if (school == -1) if (school == -1)
{ {
@ -78,15 +78,15 @@ namespace MWMechanics
NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor);
CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor); CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor);
int skillLevel = stats.mSkill[getSpellSchool(spellId, actor)].getModified(); int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified();
// Sound magic effect (reduces spell casting chance) // Sound magic effect (reduces spell casting chance)
int soundMagnitude = creatureStats.mMagicEffects.get (MWMechanics::EffectKey (48)).mMagnitude; int soundMagnitude = creatureStats.getMagicEffects().get (MWMechanics::EffectKey (48)).mMagnitude;
int willpower = creatureStats.mAttributes[ESM::Attribute::Willpower].getModified(); int willpower = creatureStats.getAttribute(ESM::Attribute::Willpower).getModified();
int luck = creatureStats.mAttributes[ESM::Attribute::Luck].getModified(); int luck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified();
int currentFatigue = creatureStats.mDynamic[2].getCurrent(); int currentFatigue = creatureStats.getFatigue().getCurrent();
int maxFatigue = creatureStats.mDynamic[2].getModified(); int maxFatigue = creatureStats.getFatigue().getModified();
int spellCost = spell->data.cost; int spellCost = spell->data.cost;
// There we go, all needed variables are there, lets go // There we go, all needed variables are there, lets go

@ -31,6 +31,11 @@ namespace MWMechanics
return mModified; return mModified;
} }
T getModifier() const
{
return mModified-mBase;
}
/// Set base and modified to \a value. /// Set base and modified to \a value.
void set (const T& value) void set (const T& value)
{ {
@ -65,10 +70,9 @@ namespace MWMechanics
mBase += diff; mBase += diff;
} }
/// Change modified relatively. void setModifier (const T& modifier)
void modify (const T& diff)
{ {
mModified += diff; mModified = mBase + modifier;
} }
}; };
@ -143,7 +147,7 @@ namespace MWMechanics
void modify (const T& diff) void modify (const T& diff)
{ {
mStatic.modify (diff); mStatic.modify (diff);
modifyCurrent (diff); setCurrent (getCurrent()+diff);
} }
void setCurrent (const T& value) void setCurrent (const T& value)
@ -155,6 +159,13 @@ namespace MWMechanics
else if (mCurrent>getModified()) else if (mCurrent>getModified())
mCurrent = getModified(); mCurrent = getModified();
} }
void setModifier (const T& modifier)
{
T diff = modifier - mStatic.getModifier();
mStatic.setModifier (modifier);
setCurrent (getCurrent()+diff);
}
}; };
template<typename T> template<typename T>

@ -122,15 +122,13 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store){
void Actors::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number){ void Actors::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number){
if(mAllActors.find(ptr) != mAllActors.end()) if(mAllActors.find(ptr) != mAllActors.end())
mAllActors[ptr]->startScript(groupName, mode, number); mAllActors[ptr]->playGroup(groupName, mode, number);
} }
void Actors::skipAnimation (const MWWorld::Ptr& ptr){ void Actors::skipAnimation (const MWWorld::Ptr& ptr){
if(mAllActors.find(ptr) != mAllActors.end()) if(mAllActors.find(ptr) != mAllActors.end())
mAllActors[ptr]->stopScript(); mAllActors[ptr]->skipAnim();
} }
void Actors::update (float duration){ void Actors::update (float duration){
for(std::map<MWWorld::Ptr, Animation*>::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++) for(std::map<MWWorld::Ptr, Animation*>::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++)
{ iter->second->runAnimation(duration);
(iter->second)->runAnimation(duration);
}
} }

@ -1,18 +1,8 @@
#ifndef _GAME_RENDER_ACTORS_H #ifndef _GAME_RENDER_ACTORS_H
#define _GAME_RENDER_ACTORS_H #define _GAME_RENDER_ACTORS_H
#include <map>
#include <list>
#include <openengine/ogre/renderer.hpp>
#include "components/nifogre/ogre_nif_loader.hpp"
#include "../mwworld/refdata.hpp"
#include "../mwworld/actiontalk.hpp"
#include "npcanimation.hpp" #include "npcanimation.hpp"
#include "creatureanimation.hpp" #include "creatureanimation.hpp"
#include <openengine/bullet/physic.hpp>
namespace MWWorld namespace MWWorld
{ {

@ -5,499 +5,171 @@
#include <OgreEntity.h> #include <OgreEntity.h>
#include <OgreBone.h> #include <OgreBone.h>
#include <OgreSubMesh.h> #include <OgreSubMesh.h>
#include <OgreSceneManager.h>
namespace MWRender{
std::map<std::string, int> Animation::mUniqueIDs;
Animation::Animation(OEngine::Render::OgreRenderer& _rend) namespace MWRender
: insert(NULL) {
, mRend(_rend)
, vecRotPos()
, time(0.0f)
, startTime(0.0f)
, stopTime(0.0f)
, animate(0)
, rindexI()
, tindexI()
, shapeNumber(0)
, shapeIndexI()
, shapes(NULL)
, transformations(NULL)
, textmappings(NULL)
, base(NULL)
{
}
Animation::~Animation()
{
}
std::string Animation::getUniqueID(std::string mesh){ Animation::Animation(OEngine::Render::OgreRenderer& _rend)
int counter; : mInsert(NULL)
std::string copy = mesh; , mRend(_rend)
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); , mTime(0.0f)
if(mUniqueIDs.find(copy) == mUniqueIDs.end()){ , mSkipFrame(false)
counter = mUniqueIDs[copy] = 0; {
} }
else{
mUniqueIDs[copy] = mUniqueIDs[copy] + 1;
counter = mUniqueIDs[copy];
}
std::stringstream out; Animation::~Animation()
if(counter > 99 && counter < 1000) {
out << "0"; Ogre::SceneManager *sceneMgr = mInsert->getCreator();
else if(counter > 9) for(size_t i = 0;i < mEntityList.mEntities.size();i++)
out << "00"; sceneMgr->destroyEntity(mEntityList.mEntities[i]);
else mEntityList.mEntities.clear();
out << "000";
out << counter;
return out.str();
} }
void Animation::startScript(std::string groupname, int mode, int loops){
//If groupname is recognized set animate to true
//Set the start time and stop time
//How many times to loop
if(groupname == "all"){
animate = loops;
time = startTime;
}
else if(textmappings){
std::string startName = groupname + ": loop start";
std::string stopName = groupname + ": loop stop";
bool first = false; struct checklow {
bool operator()(const char &a, const char &b) const
{
return ::tolower(a) == ::tolower(b);
}
};
if(loops > 1){ bool Animation::findGroupTimes(const std::string &groupname, Animation::GroupTimes *times)
startName = groupname + ": loop start"; {
stopName = groupname + ": loop stop"; const std::string &start = groupname+": start";
const std::string &startloop = groupname+": loop start";
const std::string &stop = groupname+": stop";
const std::string &stoploop = groupname+": loop stop";
for(std::map<std::string, float>::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ NifOgre::TextKeyMap::const_iterator iter;
for(iter = mTextKeys.begin();iter != mTextKeys.end();iter++)
{
if(times->mStart >= 0.0f && times->mLoopStart >= 0.0f && times->mLoopStop >= 0.0f && times->mStop >= 0.0f)
return true;
std::string current = iter->first.substr(0, startName.size()); std::string::const_iterator strpos = iter->second.begin();
std::transform(current.begin(), current.end(), current.begin(), ::tolower); std::string::const_iterator strend = iter->second.end();
std::string current2 = iter->first.substr(0, stopName.size());
std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower);
if(current == startName){ while(strpos != strend)
startTime = iter->second; {
animate = loops; size_t strlen = strend-strpos;
time = startTime; std::string::const_iterator striter;
first = true;
} if(start.size() <= strlen &&
if(current2 == stopName){ ((striter=std::mismatch(strpos, strend, start.begin(), checklow()).first) == strend ||
stopTime = iter->second; *striter == '\r' || *striter == '\n'))
if(first) {
break; times->mStart = iter->first;
} times->mLoopStart = iter->first;
}
} }
if(!first){ else if(startloop.size() <= strlen &&
startName = groupname + ": start"; ((striter=std::mismatch(strpos, strend, startloop.begin(), checklow()).first) == strend ||
stopName = groupname + ": stop"; *striter == '\r' || *striter == '\n'))
{
for(std::map<std::string, float>::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ times->mLoopStart = iter->first;
std::string current = iter->first.substr(0, startName.size());
std::transform(current.begin(), current.end(), current.begin(), ::tolower);
std::string current2 = iter->first.substr(0, stopName.size());
std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower);
if(current == startName){
startTime = iter->second;
animate = loops;
time = startTime;
first = true;
}
if(current2 == stopName){
stopTime = iter->second;
if(first)
break;
}
} }
else if(stoploop.size() <= strlen &&
((striter=std::mismatch(strpos, strend, stoploop.begin(), checklow()).first) == strend ||
*striter == '\r' || *striter == '\n'))
{
times->mLoopStop = iter->first;
}
else if(stop.size() <= strlen &&
((striter=std::mismatch(strpos, strend, stop.begin(), checklow()).first) == strend ||
*striter == '\r' || *striter == '\n'))
{
times->mStop = iter->first;
if(times->mLoopStop < 0.0f)
times->mLoopStop = iter->first;
break;
} }
strpos = std::find(strpos+1, strend, '\n');
while(strpos != strend && *strpos == '\n')
strpos++;
} }
}
void Animation::stopScript(){
animate = 0;
} }
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ return (times->mStart >= 0.0f && times->mLoopStart >= 0.0f && times->mLoopStop >= 0.0f && times->mStop >= 0.0f);
shapeNumber = 0; }
if (allshapes == NULL || creaturemodel == NULL || skel == NULL)
{
return;
}
std::vector<Nif::NiTriShapeCopy>::iterator allshapesiter;
for(allshapesiter = allshapes->begin(); allshapesiter != allshapes->end(); allshapesiter++)
{
//std::map<unsigned short, PosAndRot> vecPosRot;
Nif::NiTriShapeCopy& copy = *allshapesiter;
std::vector<Ogre::Vector3>* allvertices = &copy.vertices;
//std::set<unsigned int> vertices;
//std::set<unsigned int> normals;
//std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfovector = copy.boneinfo;
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >* verticesToChange = &copy.vertsToWeights;
//std::cout << "Name " << copy.sname << "\n";
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real* pReal = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
std::vector<Ogre::Vector3> initialVertices = copy.morph.getInitialVertices();
//Each shape has multiple indices
if(initialVertices.size() )
{
if(copy.vertices.size() == initialVertices.size())
{
//Create if it doesn't already exist
if(shapeIndexI.size() == static_cast<std::size_t> (shapeNumber))
{
std::vector<int> vec;
shapeIndexI.push_back(vec);
}
if(time >= copy.morph.getStartTime() && time <= copy.morph.getStopTime()){
float x;
for (unsigned int i = 0; i < copy.morph.getAdditionalVertices().size(); i++){
int j = 0;
if(shapeIndexI[shapeNumber].size() <= i)
shapeIndexI[shapeNumber].push_back(0);
if(timeIndex(time,copy.morph.getRelevantTimes()[i],(shapeIndexI[shapeNumber])[i], j, x)){
int indexI = (shapeIndexI[shapeNumber])[i];
std::vector<Ogre::Vector3> relevantData = (copy.morph.getRelevantData()[i]);
float v1 = relevantData[indexI].x;
float v2 = relevantData[j].x;
float t = v1 + (v2 - v1) * x;
if ( t < 0 ) t = 0;
if ( t > 1 ) t = 1;
if( t != 0 && initialVertices.size() == copy.morph.getAdditionalVertices()[i].size())
{
for (unsigned int v = 0; v < initialVertices.size(); v++){
initialVertices[v] += ((copy.morph.getAdditionalVertices()[i])[v]) * t;
}
}
}
}
allvertices = &initialVertices;
}
shapeNumber++;
}
}
if(verticesToChange->size() > 0){
for(std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >::iterator iter = verticesToChange->begin();
iter != verticesToChange->end(); iter++)
{
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
int verIndex = iter->first;
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
Ogre::Bone *bonePtr = 0;
Ogre::Vector3 vecPos;
Ogre::Quaternion vecRot;
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
if(result == vecRotPos.end()){
bonePtr = skel->getBone(boneinfocopy->bonename);
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
PosAndRot both;
both.vecPos = vecPos;
both.vecRot = vecRot;
vecRotPos[boneinfocopy] = both;
}
else{
PosAndRot both = result->second;
vecPos = both.vecPos;
vecRot = both.vecRot;
}
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
for(std::size_t i = 1; i < inds.size(); i++){
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
result = vecRotPos.find(boneinfocopy);
if(result == vecRotPos.end()){
bonePtr = skel->getBone(boneinfocopy->bonename);
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
PosAndRot both;
both.vecPos = vecPos;
both.vecRot = vecRot;
vecRotPos[boneinfocopy] = both;
}
else{
PosAndRot both = result->second;
vecPos = both.vecPos;
vecRot = both.vecRot;
}
absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight;
}
Ogre::Real* addr = (pReal + 3 * verIndex);
*addr = absVertPos.x;
*(addr+1) = absVertPos.y;
*(addr+2) = absVertPos.z;
}
}
else
{
//Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(copy.bonename);
Ogre::Quaternion shaperot = copy.trafo.rotation;
Ogre::Vector3 shapetrans = copy.trafo.trans;
float shapescale = copy.trafo.scale;
std::vector<std::string> boneSequence = copy.boneSequence;
Ogre::Vector3 transmult;
Ogre::Quaternion rotmult;
float scale;
if(boneSequence.size() > 0){
std::vector<std::string>::iterator boneSequenceIter = boneSequence.begin();
if(skel->hasBone(*boneSequenceIter)){
Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter);
transmult = bonePtr->getPosition();
rotmult = bonePtr->getOrientation();
scale = bonePtr->getScale().x;
boneSequenceIter++;
for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++)
{
if(skel->hasBone(*boneSequenceIter)){
Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter);
// Computes C = B + AxC*scale
transmult = transmult + rotmult * bonePtr->getPosition();
rotmult = rotmult * bonePtr->getOrientation();
scale = scale * bonePtr->getScale().x;
}
//std::cout << "Bone:" << *boneSequenceIter << " ";
}
transmult = transmult + rotmult * shapetrans;
rotmult = rotmult * shaperot;
scale = shapescale * scale;
//std::cout << "Position: " << transmult << "Rotation: " << rotmult << "\n";
}
}
else
{
transmult = shapetrans;
rotmult = shaperot;
scale = shapescale;
}
// Computes C = B + AxC*scale
// final_vector = old_vector + old_rotation*new_vector*old_scale/
for(unsigned int i = 0; i < allvertices->size(); i++){
Ogre::Vector3 current = transmult + rotmult * (*allvertices)[i];
Ogre::Real* addr = pReal + i * 3;
*addr = current.x;
*(addr+1) = current.y;
*(addr + 2) = current.z;
}/*
for(int i = 0; i < allnormals.size(); i++){
Ogre::Vector3 current =rotmult * allnormals[i];
Ogre::Real* addr = pRealNormal + i * 3;
*addr = current.x;
*(addr+1) = current.y;
*(addr + 2) = current.z;
}*/
} void Animation::playGroup(std::string groupname, int mode, int loops)
vbuf->unlock(); {
GroupTimes times;
times.mLoops = loops;
} if(groupname == "all")
{
times.mStart = times.mLoopStart = 0.0f;
times.mLoopStop = times.mStop = 0.0f;
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
times.mLoopStop = times.mStop = state->getLength();
break;
}
}
} }
bool Animation::timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x ){ else if(!findGroupTimes(groupname, &times))
int count; throw std::runtime_error("Failed to find animation group "+groupname);
if ( (count = times.size()) > 0 )
{
if ( time <= times[0] )
{
i = j = 0;
x = 0.0;
return true;
}
if ( time >= times[count - 1] )
{
i = j = count - 1;
x = 0.0;
return true;
}
if ( i < 0 || i >= count )
i = 0;
float tI = times[i];
if ( time > tI )
{
j = i + 1;
float tJ;
while ( time >= ( tJ = times[j]) )
{
i = j++;
tI = tJ;
}
x = ( time - tI ) / ( tJ - tI );
return true;
}
else if ( time < tI )
{
j = i - 1;
float tJ;
while ( time <= ( tJ = times[j] ) )
{
i = j--;
tI = tJ;
}
x = ( time - tI ) / ( tJ - tI );
return true;
}
else
{
j = i;
x = 0.0;
return true;
}
}
else
return false;
if(mode == 0 && mCurGroup.mLoops > 0)
mNextGroup = times;
else
{
mCurGroup = times;
mNextGroup = GroupTimes();
mTime = ((mode==2) ? mCurGroup.mLoopStart : mCurGroup.mStart);
}
} }
void Animation::handleAnimationTransforms(){ void Animation::skipAnim()
{
mSkipFrame = true;
Ogre::SkeletonInstance* skel = base->getSkeleton(); }
Ogre::Bone* b = skel->getRootBone();
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3)); //This is a trick
skel->_updateTransforms();
//skel->_notifyManualBonesDirty();
base->getAllAnimationStates()->_notifyDirty();
//base->_updateAnimation();
//base->_notifyMoved();
std::vector<Nif::NiKeyframeData>::iterator iter;
int slot = 0;
if(transformations){
for(iter = transformations->begin(); iter != transformations->end(); iter++){
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
{
slot++;
continue;
}
float x;
float x2;
const std::vector<Ogre::Quaternion> & quats = iter->getQuat();
const std::vector<float> & ttime = iter->gettTime();
const std::vector<float> & rtime = iter->getrTime();
int rindexJ = rindexI[slot];
timeIndex(time, rtime, rindexI[slot], rindexJ, x2);
int tindexJ = tindexI[slot];
const std::vector<Ogre::Vector3> & translist1 = iter->getTranslist1();
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
Ogre::Vector3 t;
Ogre::Quaternion r;
bool bTrans = translist1.size() > 0;
bool bQuats = quats.size() > 0;
if(skel->hasBone(iter->getBonename())){
Ogre::Bone* bone = skel->getBone(iter->getBonename());
if(bTrans){
Ogre::Vector3 v1 = translist1[tindexI[slot]];
Ogre::Vector3 v2 = translist1[tindexJ];
t = (v1 + (v2 - v1) * x);
bone->setPosition(t);
}
if(bQuats){
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
bone->setOrientation(r);
}
}
void Animation::runAnimation(float timepassed)
{
if(mCurGroup.mLoops > 0 && !mSkipFrame)
{
mTime += timepassed;
if(mTime >= mCurGroup.mLoopStop)
{
if(mCurGroup.mLoops > 1)
{
mCurGroup.mLoops--;
mTime = mTime - mCurGroup.mLoopStop + mCurGroup.mLoopStart;
}
else if(mTime >= mCurGroup.mStop)
{
if(mNextGroup.mLoops > 0)
mTime = mTime - mCurGroup.mStop + mNextGroup.mStart;
else
mTime = mCurGroup.mStop;
mCurGroup = mNextGroup;
mNextGroup = GroupTimes();
}
}
slot++; if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setTimePosition(mTime);
}
}
} }
skel->_updateTransforms(); mSkipFrame = false;
base->getAllAnimationStates()->_notifyDirty();
}
} }
} }

@ -1,71 +1,57 @@
#ifndef _GAME_RENDER_ANIMATION_H #ifndef _GAME_RENDER_ANIMATION_H
#define _GAME_RENDER_ANIMATION_H #define _GAME_RENDER_ANIMATION_H
#include <components/nif/data.hpp>
#include <vector>
#include <components/nifogre/ogre_nif_loader.hpp>
#include <openengine/ogre/renderer.hpp> #include <openengine/ogre/renderer.hpp>
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp" #include "../mwworld/actiontalk.hpp"
#include <components/nif/node.hpp> #include <components/nif/node.hpp>
#include <map>
#include <openengine/bullet/physic.hpp> #include <openengine/bullet/physic.hpp>
namespace MWRender{ namespace MWRender {
struct PosAndRot{
Ogre::Quaternion vecRot;
Ogre::Vector3 vecPos;
};
class Animation{
protected:
Ogre::SceneNode* insert;
OEngine::Render::OgreRenderer &mRend;
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot> vecRotPos;
static std::map<std::string, int> mUniqueIDs;
class Animation {
struct GroupTimes {
float mStart;
float mStop;
float mLoopStart;
float mLoopStop;
size_t mLoops;
GroupTimes()
: mStart(-1.0f), mStop(-1.0f), mLoopStart(-1.0f), mLoopStop(-1.0f),
mLoops(0)
{ }
};
protected:
Ogre::SceneNode* mInsert;
OEngine::Render::OgreRenderer &mRend;
float time; float mTime;
float startTime; GroupTimes mCurGroup;
float stopTime; GroupTimes mNextGroup;
int animate;
//Represents a rotation index for each bone
std::vector<int>rindexI;
//Represents a translation index for each bone
std::vector<int>tindexI;
//Only shapes with morphing data will use a shape number
int shapeNumber;
std::vector<std::vector<int> > shapeIndexI;
//Ogre::SkeletonInstance* skel;
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for a creature
std::vector<Nif::NiKeyframeData>* transformations; bool mSkipFrame;
std::map<std::string,float>* textmappings;
Ogre::Entity* base;
void handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel);
void handleAnimationTransforms();
bool timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x );
std::string getUniqueID(std::string mesh);
public: NifOgre::EntityList mEntityList;
Animation(OEngine::Render::OgreRenderer& _rend); NifOgre::TextKeyMap mTextKeys;
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();
bool findGroupTimes(const std::string &groupname, GroupTimes *times);
virtual ~Animation(); public:
Animation(OEngine::Render::OgreRenderer& _rend);
virtual ~Animation();
void playGroup(std::string groupname, int mode, int loops);
void skipAnim();
virtual void runAnimation(float timepassed);
}; };
} }
#endif #endif

@ -12,80 +12,66 @@ using namespace Ogre;
using namespace NifOgre; using namespace NifOgre;
namespace MWRender{ namespace MWRender{
CreatureAnimation::~CreatureAnimation(){ CreatureAnimation::~CreatureAnimation()
{
} }
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){
insert = ptr.getRefData().getBaseNode(); CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend)
MWWorld::LiveCellRef<ESM::Creature> *ref = {
ptr.get<ESM::Creature>(); mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->base != NULL); assert (ref->base != NULL);
if(!ref->base->model.empty()){ if(!ref->base->model.empty())
const std::string &mesh = "meshes\\" + ref->base->model; {
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|"; std::string mesh = "meshes\\" + ref->base->model;
NifOgre::NIFLoader::load(meshNumbered);
base = mRend.getScene()->createEntity(meshNumbered);
base->setVisibilityFlags(RV_Actors);
bool transparent = false; mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
for (unsigned int i=0; i<base->getNumSubEntities(); ++i) for(size_t i = 0;i < mEntityList.mEntities.size();i++)
{ {
Ogre::MaterialPtr mat = base->getSubEntity(i)->getMaterial(); Ogre::Entity *ent = mEntityList.mEntities[i];
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); ent->setVisibilityFlags(RV_Actors);
while (techIt.hasMoreElements())
bool transparent = false;
for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j)
{ {
Ogre::Technique* tech = techIt.getNext(); Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Technique::PassIterator passIt = tech->getPassIterator(); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (passIt.hasMoreElements()) while (techIt.hasMoreElements() && !transparent)
{ {
Ogre::Pass* pass = passIt.getNext(); Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
if (pass->getDepthWriteEnabled() == false) while (passIt.hasMoreElements() && !transparent)
transparent = true; {
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
} }
} }
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
} }
base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
std::string meshZero = mesh + "0000>|"; if(mEntityList.mSkelBase)
{
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))){ Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
for(std::size_t init = 0; init < transformations->size(); init++){ while(as.hasMoreElements())
rindexI.push_back(0); {
tindexI.push_back(0); Ogre::AnimationState *state = as.getNext();
} state->setEnabled(true);
stopTime = transformations->begin()->getStopTime(); state->setLoop(false);
startTime = transformations->begin()->getStartTime(); }
shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
} }
textmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero);
insert->attachObject(base);
} }
} }
void CreatureAnimation::runAnimation(float timepassed){ void CreatureAnimation::runAnimation(float timepassed)
vecRotPos.clear(); {
if(animate > 0){ // Placeholder
//Add the amount of time passed to time
//Handle the animation transforms dependent on time Animation::runAnimation(timepassed);
//Handle the shapes dependent on animation transforms
time += timepassed;
if(time >= stopTime){
animate--;
//std::cout << "Stopping the animation\n";
if(animate == 0)
time = stopTime;
else
time = startTime + (time - stopTime);
}
handleAnimationTransforms();
handleShapes(shapes, base, base->getSkeleton());
}
} }
} }

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

Loading…
Cancel
Save