Merge branch 'master' of https://github.com/zinnschlag/openmw.git into inventoryGUI

Conflicts:
	apps/openmw/CMakeLists.txt
	apps/openmw/mwclass/apparatus.cpp
	apps/openmw/mwclass/armor.cpp
	apps/openmw/mwclass/book.cpp
	apps/openmw/mwclass/clothing.cpp
	apps/openmw/mwclass/container.cpp
	apps/openmw/mwclass/ingredient.cpp
	apps/openmw/mwclass/light.cpp
	apps/openmw/mwclass/lockpick.cpp
	apps/openmw/mwclass/misc.cpp
	apps/openmw/mwclass/potion.cpp
	apps/openmw/mwclass/probe.cpp
	apps/openmw/mwclass/repair.cpp
	apps/openmw/mwclass/weapon.cpp
	apps/openmw/mwgui/window_manager.cpp
	apps/openmw/mwgui/window_manager.hpp
	apps/openmw/mwworld/class.cpp
actorid
gugus 13 years ago
commit 8e8f80807e

@ -15,7 +15,7 @@ include (OpenMWMacros)
# Version
set (OPENMW_VERSION_MAJOR 0)
set (OPENMW_VERSION_MINOR 13)
set (OPENMW_VERSION_MINOR 14)
set (OPENMW_VERSION_RELEASE 0)
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
@ -122,6 +122,11 @@ set(OENGINE_BULLET
${LIBDIR}/openengine/bullet/physic.hpp
${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp
${LIBDIR}/openengine/bullet/BulletShapeLoader.h
${LIBDIR}/openengine/bullet/pmove.cpp
${LIBDIR}/openengine/bullet/pmove.h
${LIBDIR}/openengine/bullet/trace.cpp
${LIBDIR}/openengine/bullet/trace.h
)
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
@ -209,16 +214,16 @@ include_directories("."
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
if(APPLE)
if (APPLE)
# List used Ogre plugins
SET(USED_OGRE_PLUGINS "RenderSystem_GL"
"Plugin_OctreeSceneManager"
"Plugin_CgProgramManager"
"Plugin_ParticleFX")
endif(APPLE)
SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL}
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
${OGRE_Plugin_ParticleFX_LIBRARY_REL})
endif (APPLE)
add_subdirectory( files/)
add_subdirectory( files/mygui )
add_subdirectory(files/)
add_subdirectory(files/mygui)
# Specify build paths
@ -255,34 +260,36 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
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)
# prepare plugins
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(OPENMW_RELEASE_BUILD 1)
endif()
if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo")
set(OPENMW_RELEASE_BUILD 1)
endif()
if (${OPENMW_RELEASE_BUILD})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif()
foreach(plugin ${USED_OGRE_PLUGINS})
configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib"
"${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib"
COPYONLY)
endforeach()
endif (APPLE)
@ -356,12 +363,17 @@ if(DPKG_PROGRAM)
endif(DPKG_PROGRAM)
if(WIN32)
FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*")
INSTALL(FILES ${files} DESTINATION ".")
FILE(GLOB dll_files "${OpenMW_BINARY_DIR}/Release/*.dll")
INSTALL(FILES ${dll_files} DESTINATION ".")
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
INSTALL(FILES
"${OpenMW_SOURCE_DIR}/readme.txt"
"${OpenMW_BINARY_DIR}/plugins.cfg"
"${OpenMW_SOURCE_DIR}/readme.txt"
"${OpenMW_BINARY_DIR}/launcher.qss"
"${OpenMW_BINARY_DIR}/settings-default.cfg"
"${OpenMW_BINARY_DIR}/transparency-overrides.cfg"
"${OpenMW_BINARY_DIR}/Release/omwlauncher.exe"
"${OpenMW_BINARY_DIR}/Release/openmw.exe"
DESTINATION ".")
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
@ -387,7 +399,7 @@ if(WIN32)
SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe")
SET(CPACK_NSIS_MUI_ICON "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.ico")
SET(CPACK_NSIS_MUI_UNIICON "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.ico")
# SET(CPACK_PACKAGE_ICON "${OpenMW_SOURCE_DIR}\\\\files\\\\openmw.bmp")
SET(CPACK_PACKAGE_ICON "${OpenMW_SOURCE_DIR}\\\\files\\\\openmw.bmp")
SET(VCREDIST32 "${OpenMW_BINARY_DIR}/vcredist_x86.exe")
if(EXISTS ${VCREDIST32})
@ -520,10 +532,12 @@ if (APPLE)
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(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/plugins.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}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
@ -532,22 +546,25 @@ if (APPLE)
set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}")
set(PLUGINS "")
set(ABSOLUTE_PLUGINS "")
# Scan Plugins dir for *.dylibs
set(PLUGIN_SEARCH_ROOT "${APP_BUNDLE_DIR}/Contents/Plugins")
file(GLOB_RECURSE ALL_PLUGINS "${PLUGIN_SEARCH_ROOT}/*.dylib")
foreach (PLUGIN ${USED_OGRE_PLUGINS})
get_filename_component(PLUGIN_ABS ${PLUGIN} REALPATH)
set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS})
endforeach ()
set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins")
foreach(PLUGIN ${ALL_PLUGINS})
string(REPLACE "${PLUGIN_SEARCH_ROOT}/" "" PLUGIN_RELATIVE "${PLUGIN}")
install(FILES ${ABSOLUTE_PLUGINS} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins" COMPONENT Runtime)
foreach (PLUGIN ${ABSOLUTE_PLUGINS})
get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME)
set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}")
endforeach()
endforeach ()
#For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail
set(DIRS "")
# Overriding item resolving during installation, it needed if
# some library already has be "fixed up", i.e. its id name contains @executable_path,
# some library already has been "fixed up", i.e. its id name contains @executable_path,
# but library is not embedded in bundle. For example, it's Ogre.framework from Ogre SDK.
# Current implementation of GetPrerequsities/BundleUtilities doesn't handle that case.
#
@ -565,17 +582,22 @@ if (APPLE)
if (item MATCHES \"Frameworks\") # if it is a framework
# get last segment of path
get_filename_component(fname \"\${item}\" NAME_WE)
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks)
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} \${CMAKE_SYSTEM_FRAMEWORK_PATH})
if (ri)
message(STATUS \"found \${ri} for \${item}\")
string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item})
set(ri \"\${ri}\${item_part}\")
set(\${resolved_item_var} \${ri} PARENT_SCOPE)
set(\${resolved_var} 1 PARENT_SCOPE)
set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri})
endif()
else()
# code path for standard (non-framework) libs (ogre & qt pugins)
get_filename_component(fname \"\${item}\" NAME_WE)
string(REGEX REPLACE \"^lib\" \"\" fname \${fname})
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /usr/lib /usr/local/lib)
if (ri)
set(\${resolved_item_var} \${ri} PARENT_SCOPE)
set(\${resolved_var} 1 PARENT_SCOPE)
endif ()
endif()
endif()
endfunction(gp_resolve_item_override)
@ -585,10 +607,5 @@ if (APPLE)
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\")
" COMPONENT Runtime)
include(CPack)
set(CMAKE_EXE_LINKER_FLAGS "-arch i386")
set(CMAKE_CXX_FLAGS "-arch i386")
include(CPack)
endif (APPLE)

@ -25,7 +25,7 @@ add_openmw_dir (mwinput
add_openmw_dir (mwgui
layouts text_input widgets race class birth review window_manager console dialogue
dialogue_history window_base stats_window messagebox journalwindow charactercreation container
map_window window_pinnable_base cursorreplace inventorywindow
map_window window_pinnable_base cursorreplace inventorywindow tooltips itemwidget
)
add_openmw_dir (mwdialogue
@ -44,7 +44,7 @@ add_openmw_dir (mwsound
)
add_openmw_dir (mwworld
refdata world physicssystem scene environment globals class action nullaction actionteleport
refdata world physicssystem scene globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore ptr actionopen
)
@ -58,6 +58,10 @@ add_openmw_dir (mwmechanics
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells
)
add_openmw_dir (mwbase
environment
)
# Main executable
IF(OGRE_STATIC)
IF(WIN32)

@ -50,10 +50,12 @@
#include "mwmechanics/mechanicsmanager.hpp"
#include "mwbase/environment.hpp"
void OMW::Engine::executeLocalScripts()
{
MWWorld::LocalScripts& localScripts = mEnvironment.mWorld->getLocalScripts();
MWWorld::LocalScripts& localScripts = MWBase::Environment::get().getWorld()->getLocalScripts();
localScripts.startIteration();
@ -61,58 +63,17 @@ void OMW::Engine::executeLocalScripts()
{
std::pair<std::string, MWWorld::Ptr> script = localScripts.getNext();
MWScript::InterpreterContext interpreterContext (mEnvironment,
MWScript::InterpreterContext interpreterContext (
&script.second.getRefData().getLocals(), script.second);
mEnvironment.mScriptManager->run (script.first, interpreterContext);
MWBase::Environment::get().getScriptManager()->run (script.first, interpreterContext);
if (mEnvironment.mWorld->hasCellChanged())
if (MWBase::Environment::get().getWorld()->hasCellChanged())
break;
}
localScripts.setIgnore (MWWorld::Ptr());
}
void OMW::Engine::updateFocusReport (float duration)
{
if ((mFocusTDiff += duration)>0.25)
{
mFocusTDiff = 0;
std::string name;
std::string handle = mEnvironment.mWorld->getFacedHandle();
if (!handle.empty())
{
// the faced handle is not updated immediately, so on a cell change it might
// point to an object that doesn't exist anymore
// therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case
try
{
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (!ptr.isEmpty()){
name = MWWorld::Class::get (ptr).getName (ptr);
}
}
catch (std::runtime_error& e)
{}
}
if (name!=mFocusName)
{
mFocusName = name;
if (mFocusName.empty())
std::cout << "Unfocus" << std::endl;
else
std::cout << "Focus: " << name << std::endl;
}
}
}
void OMW::Engine::setAnimationVerbose(bool animverbose){
if(animverbose){
NifOgre::NIFLoader::getSingletonPtr()->setOutputAnimFiles(true);
@ -124,27 +85,19 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
{
try
{
mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
// update input
mEnvironment.mInputManager->update();
MWBase::Environment::get().getInputManager()->update();
// sound
if (mUseSound)
mEnvironment.mSoundManager->update (evt.timeSinceLastFrame);
// update GUI
Ogre::RenderWindow* window = mOgre->getWindow();
mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(),
window->getTriangleCount(),
window->getBatchCount());
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame);
// global scripts
mEnvironment.mGlobalScripts->run (mEnvironment);
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
bool changed = mEnvironment.mWorld->hasCellChanged();
bool changed = MWBase::Environment::get().getWorld()->hasCellChanged();
// local scripts
executeLocalScripts(); // This does not handle the case where a global script causes a cell
@ -152,28 +105,32 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// frame.
// passing of time
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
mEnvironment.mWorld->advanceTime (
mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600);
if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game)
MWBase::Environment::get().getWorld()->advanceTime (
mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
if (changed) // keep change flag for another frame, if cell changed happend in local script
mEnvironment.mWorld->markCellAsUnchanged();
MWBase::Environment::get().getWorld()->markCellAsUnchanged();
// update actors
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
mEnvironment.mMechanicsManager->update (movement, mEnvironment.mFrameDuration,
mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game);
MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(),
MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game);
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game)
MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration());
// update world
mEnvironment.mWorld->update (evt.timeSinceLastFrame);
MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame);
// report focus object (for debugging)
if (mReportFocus)
updateFocusReport (mEnvironment.mFrameDuration);
// update GUI
Ogre::RenderWindow* window = mOgre->getWindow();
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(),
window->getTriangleCount(),
window->getBatchCount());
MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame);
}
catch (const std::exception& e)
{
@ -191,8 +148,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mNewGame (false)
, mUseSound (true)
, mCompileAll (false)
, mReportFocus (false)
, mFocusTDiff (0)
, mScriptContext (0)
, mFSStrict (false)
, mCfgMgr(configurationManager)
@ -203,13 +158,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
OMW::Engine::~Engine()
{
delete mEnvironment.mWorld;
delete mEnvironment.mSoundManager;
delete mEnvironment.mGlobalScripts;
delete mEnvironment.mMechanicsManager;
delete mEnvironment.mDialogueManager;
delete mEnvironment.mJournal;
delete mEnvironment.mScriptManager;
mEnvironment.cleanup();
delete mScriptContext;
delete mOgre;
}
@ -219,7 +168,7 @@ OMW::Engine::~Engine()
void OMW::Engine::loadBSA()
{
const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa");
for (Files::MultiDirCollection::TIter iter(bsa.begin()); iter!=bsa.end(); ++iter)
{
std::cout << "Adding " << iter->second.string() << std::endl;
@ -303,17 +252,10 @@ void OMW::Engine::setNewGame(bool newGame)
mNewGame = newGame;
}
void OMW::Engine::setReportFocus (bool report)
{
mReportFocus = report;
}
// Initialise and enter main loop.
void OMW::Engine::go()
{
mFocusTDiff = 0;
assert (!mEnvironment.mWorld);
assert (!mCellName.empty());
assert (!mMaster.empty());
assert (!mOgre);
@ -339,6 +281,8 @@ void OMW::Engine::go()
settings.loadDefault(localdefault);
else if (boost::filesystem::exists(globaldefault))
settings.loadDefault(globaldefault);
else
throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed.");
// load user settings if they exist, otherwise just load the default settings as user settings
const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg";
@ -382,69 +326,66 @@ void OMW::Engine::go()
MWGui::CursorReplace replacer;
// Create the world
mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster,
mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap);
mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
mResDir, mNewGame, mEncoding, mFallbackMap));
// Create window manager - this manages all the MW-specific GUI windows
MWScript::registerExtensions (mExtensions);
mEnvironment.mWindowManager = new MWGui::WindowManager(mEnvironment,
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"));
mEnvironment.setWindowManager (new MWGui::WindowManager(
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/")));
// Create sound system
mEnvironment.mSoundManager = new MWSound::SoundManager(mUseSound, mEnvironment);
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
// Create script system
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
mEnvironment);
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
mScriptContext->setExtensions (&mExtensions);
mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(),
mVerboseScripts, *mScriptContext);
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
*mEnvironment.mScriptManager);
mEnvironment.setScriptManager (new MWScript::ScriptManager (MWBase::Environment::get().getWorld()->getStore(),
mVerboseScripts, *mScriptContext));
// Create game mechanics system
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
mEnvironment.setMechanicsManager (new MWMechanics::MechanicsManager);
// Create dialog system
mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment);
mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions);
mEnvironment.setJournal (new MWDialogue::Journal);
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
// load cell
ESM::Position pos;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
pos.pos[2] = 0;
if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName))
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
{
mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY,
MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY,
pos.pos[0], pos.pos[1], true);
mEnvironment.mWorld->changeToExteriorCell (pos);
MWBase::Environment::get().getWorld()->changeToExteriorCell (pos);
}
else
{
pos.pos[0] = pos.pos[1] = 0;
mEnvironment.mWorld->changeToInteriorCell (mCellName, pos);
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
}
// Sets up the input system
MWInput::MWInputManager input(*mOgre, mEnvironment.mWorld->getPlayer(),
*mEnvironment.mWindowManager, mDebug, *this);
mEnvironment.mInputManager = &input;
mEnvironment.setInputManager (new MWInput::MWInputManager (*mOgre,
MWBase::Environment::get().getWorld()->getPlayer(),
*MWBase::Environment::get().getWindowManager(), mDebug, *this));
std::cout << "\nPress Q/ESC or close window to exit.\n";
mOgre->getRoot()->addFrameListener (this);
// Play some good 'ol tunes
mEnvironment.mSoundManager->playPlaylist(std::string("Explore"));
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
// scripts
if (mCompileAll)
{
std::pair<int, int> result = mEnvironment.mScriptManager->compileAll();
std::pair<int, int> result = MWBase::Environment::get().getScriptManager()->compileAll();
if (result.first)
std::cout
@ -465,10 +406,10 @@ void OMW::Engine::go()
void OMW::Engine::activate()
{
if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game)
if (MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game)
return;
std::string handle = mEnvironment.mWorld->getFacedHandle();
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
if (handle.empty())
return;
@ -479,7 +420,7 @@ void OMW::Engine::activate()
MWWorld::Ptr ptr;
try
{
ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
@ -489,12 +430,10 @@ void OMW::Engine::activate()
return;
}
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
mEnvironment);
MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
interpreterContext.activate (ptr, action);
@ -502,8 +441,8 @@ void OMW::Engine::activate()
if (!script.empty())
{
mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
mEnvironment.mScriptManager->run (script, interpreterContext);
MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr);
MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
}
if (!interpreterContext.hasActivationBeenHandled())

@ -10,7 +10,8 @@
#include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp>
#include "mwworld/environment.hpp"
#include "mwbase/environment.hpp"
#include "mwworld/ptr.hpp"
namespace Compiler
@ -61,6 +62,7 @@ namespace OMW
/// \brief Main engine class, that brings together all the components of OpenMW
class Engine : private Ogre::FrameListener
{
MWBase::Environment mEnvironment;
std::string mEncoding;
Files::PathContainer mDataDirs;
boost::filesystem::path mResDir;
@ -73,12 +75,9 @@ namespace OMW
bool mNewGame;
bool mUseSound;
bool mCompileAll;
bool mReportFocus;
float mFocusTDiff;
std::string mFocusName;
std::map<std::string,std::string> mFallbackMap;
MWWorld::Environment mEnvironment;
Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext;
@ -100,8 +99,6 @@ namespace OMW
void executeLocalScripts();
void updateFocusReport (float duration);
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);
public:
@ -144,9 +141,6 @@ namespace OMW
/// Start as a new game.
void setNewGame(bool newGame);
/// Write name of focussed object to cout
void setReportFocus (bool report);
/// Initialise and enter main loop.
void go();

@ -155,9 +155,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default")
("report-focus", bpo::value<bool>()->implicit_value(true)
->default_value(false), "write name of focussed object to cout")
("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
->multitoken()->composing(), "fallback values")
@ -265,7 +262,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setSoundUsage(!variables["nosound"].as<bool>());
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
engine.setCompileAll(variables["script-all"].as<bool>());
engine.setReportFocus(variables["report-focus"].as<bool>());
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);

@ -0,0 +1,161 @@
#include "environment.hpp"
#include <cassert>
#include "../mwinput/inputmanager.hpp"
#include "../mwscript/scriptmanager.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwworld/world.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0;
MWBase::Environment::Environment()
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mFrameDuration (0)
{
assert (!sThis);
sThis = this;
}
MWBase::Environment::~Environment()
{
cleanup();
sThis = 0;
}
void MWBase::Environment::setWorld (MWWorld::World *world)
{
mWorld = world;
}
void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager)
{
mSoundManager = soundManager;
}
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager)
{
mScriptManager = scriptManager;
}
void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager)
{
mWindowManager = windowManager;
}
void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager)
{
mMechanicsManager = mechanicsManager;
}
void MWBase::Environment::setDialogueManager (MWDialogue::DialogueManager *dialogueManager)
{
mDialogueManager = dialogueManager;
}
void MWBase::Environment::setJournal (MWDialogue::Journal *journal)
{
mJournal = journal;
}
void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager)
{
mInputManager = inputManager;
}
void MWBase::Environment::setFrameDuration (float duration)
{
mFrameDuration = duration;
}
MWWorld::World *MWBase::Environment::getWorld() const
{
assert (mWorld);
return mWorld;
}
MWSound::SoundManager *MWBase::Environment::getSoundManager() const
{
assert (mSoundManager);
return mSoundManager;
}
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const
{
assert (mScriptManager);
return mScriptManager;
}
MWGui::WindowManager *MWBase::Environment::getWindowManager() const
{
assert (mWindowManager);
return mWindowManager;
}
MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const
{
assert (mMechanicsManager);
return mMechanicsManager;
}
MWDialogue::DialogueManager *MWBase::Environment::getDialogueManager() const
{
assert (mDialogueManager);
return mDialogueManager;
}
MWDialogue::Journal *MWBase::Environment::getJournal() const
{
assert (mJournal);
return mJournal;
}
MWInput::MWInputManager *MWBase::Environment::getInputManager() const
{
assert (mInputManager);
return mInputManager;
}
float MWBase::Environment::getFrameDuration() const
{
return mFrameDuration;
}
void MWBase::Environment::cleanup()
{
delete mInputManager;
mInputManager = 0;
delete mSoundManager;
mSoundManager = 0;
delete mMechanicsManager;
mMechanicsManager = 0;
delete mDialogueManager;
mDialogueManager = 0;
delete mJournal;
mJournal = 0;
delete mScriptManager;
mScriptManager = 0;
delete mWorld;
mWorld = 0;
}
const MWBase::Environment& MWBase::Environment::get()
{
assert (sThis);
return *sThis;
}

@ -0,0 +1,119 @@
#ifndef GAME_BASE_INVIRONMENT_H
#define GAME_BASE_INVIRONMENT_H
namespace MWSound
{
class SoundManager;
}
namespace MWScript
{
class ScriptManager;
}
namespace MWGui
{
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace MWDialogue
{
class DialogueManager;
class Journal;
}
namespace MWInput
{
struct MWInputManager;
}
namespace MWWorld
{
class World;
}
namespace MWBase
{
/// \brief Central hub for mw-subsystems
///
/// This class allows each mw-subsystem to access any others subsystem's top-level manager class.
///
/// \attention Environment takes ownership of the manager class instances it is handed over in
/// the set* functions.
class Environment
{
static Environment *sThis;
MWWorld::World *mWorld;
MWSound::SoundManager *mSoundManager;
MWScript::ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager;
MWDialogue::DialogueManager *mDialogueManager;
MWDialogue::Journal *mJournal;
MWInput::MWInputManager *mInputManager;
float mFrameDuration;
Environment (const Environment&);
///< not implemented
Environment& operator= (const Environment&);
///< not implemented
public:
Environment();
~Environment();
void setWorld (MWWorld::World *world);
void setSoundManager (MWSound::SoundManager *soundManager);
void setScriptManager (MWScript::ScriptManager *scriptManager);
void setWindowManager (MWGui::WindowManager *windowManager);
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager);
void setDialogueManager (MWDialogue::DialogueManager *dialogueManager);
void setJournal (MWDialogue::Journal *journal);
void setInputManager (MWInput::MWInputManager *inputManager);
void setFrameDuration (float duration);
///< Set length of current frame in seconds.
MWWorld::World *getWorld() const;
MWSound::SoundManager *getSoundManager() const;
MWScript::ScriptManager *getScriptManager() const;
MWGui::WindowManager *getWindowManager() const;
MWMechanics::MechanicsManager *getMechanicsManager() const;
MWDialogue::DialogueManager *getDialogueManager() const;
MWDialogue::Journal *getJournal() const;
MWInput::MWInputManager *getInputManager() const;
float getFrameDuration() const;
void cleanup();
///< Delete all mw*-subsystems.
static const Environment& get();
///< Return instance of this class.
};
}
#endif

@ -1,13 +1,14 @@
#include "activator.hpp"
#include "../mwrender/objects.hpp"
#include <components/esm/loadacti.hpp>
#include <components/esm_store/cell_store.hpp>
#include "../mwworld/ptr.hpp"
#include "../mwrender/objects.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
namespace MWClass
{
@ -18,7 +19,7 @@ namespace MWClass
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects();
@ -27,7 +28,7 @@ namespace MWClass
}
}
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
@ -63,4 +64,28 @@ namespace MWClass
registerClass (typeid (ESM::Activator).name(), instance);
}
bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

@ -12,12 +12,18 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

@ -5,12 +5,17 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -31,7 +36,7 @@ namespace MWClass
}
}
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
@ -54,9 +59,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -95,8 +100,7 @@ namespace MWClass
return std::string("Item Apparatus Down");
}
std::string Apparatus::getInventoryIcon (const MWWorld::Ptr& ptr) const
std::string Apparatus::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
@ -104,4 +108,36 @@ namespace MWClass
return ref->base->icon;
}
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,14 +12,14 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
@ -28,6 +28,12 @@ namespace MWClass
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;

@ -9,13 +9,15 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -36,7 +38,7 @@ namespace MWClass
}
}
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
@ -58,9 +60,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -121,7 +123,7 @@ namespace MWClass
return std::make_pair (slots, false);
}
int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
@ -138,8 +140,7 @@ namespace MWClass
case ESM::Armor::Boots: typeGmst = "iBootsWeight"; break;
case ESM::Armor::LGauntlet:
case ESM::Armor::RGauntlet: typeGmst = "iGauntletWeight"; break;
/// \todo how to determine if shield light, medium or heavy?
// case ESM::Armor::Shield:
case ESM::Armor::Shield: typeGmst = "iShieldWeight"; break;
case ESM::Armor::LBracer:
case ESM::Armor::RBracer: typeGmst = "iGauntletWeight"; break;
}
@ -147,13 +148,13 @@ namespace MWClass
if (typeGmst.empty())
return -1;
float iWeight = environment.mWorld->getStore().gameSettings.find (typeGmst)->i;
float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->i;
if (iWeight * environment.mWorld->getStore().gameSettings.find ("fLightMaxMod")->f>=
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->f>=
ref->base->data.weight)
return ESM::Skill::LightArmor;
if (iWeight * environment.mWorld->getStore().gameSettings.find ("fMedMaxMod")->f>=
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->f>=
ref->base->data.weight)
return ESM::Skill::MediumArmor;
@ -175,9 +176,9 @@ namespace MWClass
registerClass (typeid (ESM::Armor).name(), instance);
}
std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr) const
{
int es = getEquipmentSkill(ptr, environment);
int es = getEquipmentSkill(ptr);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Up");
else if (es == ESM::Skill::MediumArmor)
@ -186,9 +187,9 @@ namespace MWClass
return std::string("Item Armor Heavy Up");
}
std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr) const
{
int es = getEquipmentSkill(ptr, environment);
int es = getEquipmentSkill(ptr);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Down");
else if (es == ESM::Skill::MediumArmor)
@ -197,11 +198,62 @@ namespace MWClass
return std::string("Item Armor Heavy Down");
}
std::string Armor::getInventoryIcon (const MWWorld::Ptr& ptr) const
std::string Armor::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return ref->base->icon;
}
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
// get armor type string (light/medium/heavy)
int armorType = getEquipmentSkill(ptr);
std::string typeText;
if (armorType == ESM::Skill::LightArmor)
typeText = store.gameSettings.search("sLight")->str;
else if (armorType == ESM::Skill::MediumArmor)
typeText = store.gameSettings.search("sMedium")->str;
else
typeText = store.gameSettings.search("sHeavy")->str;
text += "\n" + store.gameSettings.search("sArmorRating")->str + ": " + MWGui::ToolTips::toString(ref->base->data.armor);
/// \todo store the current armor health somewhere
text += "\n" + store.gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")";
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.enchant = ref->base->enchant;
info.text = text;
return info;
}
}

@ -12,14 +12,14 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
@ -35,20 +35,25 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const;
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,12 +5,16 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -31,7 +35,7 @@ namespace MWClass
}
}
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
@ -54,11 +58,11 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
// TODO implement reading
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -87,15 +91,16 @@ namespace MWClass
registerClass (typeid (ESM::Book).name(), instance);
}
std::string Book::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Book::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Book Up");
}
std::string Book::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Book::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Book Down");
}
std::string Book::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
@ -104,4 +109,39 @@ namespace MWClass
return ref->base->icon;
}
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.enchant = ref->base->enchant;
info.text = text;
return info;
}
}

@ -12,28 +12,34 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,10 +5,15 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwrender/objects.hpp"
@ -32,7 +37,7 @@ namespace MWClass
}
}
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
@ -55,9 +60,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -89,7 +94,7 @@ namespace MWClass
static const int sMapping[size][2] =
{
{ ESM::Clothing::Shirt, MWWorld::InventoryStore::Slot_Cuirass },
{ ESM::Clothing::Shirt, MWWorld::InventoryStore::Slot_Shirt },
{ ESM::Clothing::Belt, MWWorld::InventoryStore::Slot_Belt },
{ ESM::Clothing::Robe, MWWorld::InventoryStore::Slot_Robe },
{ ESM::Clothing::Pants, MWWorld::InventoryStore::Slot_Pants },
@ -111,8 +116,7 @@ namespace MWClass
return std::make_pair (slots, false);
}
int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const
int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
@ -138,7 +142,7 @@ namespace MWClass
registerClass (typeid (ESM::Clothing).name(), instance);
}
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
@ -150,7 +154,7 @@ namespace MWClass
return std::string("Item Clothes Up");
}
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
@ -169,4 +173,40 @@ namespace MWClass
return ref->base->icon;
}
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.enchant = ref->base->enchant;
info.text = text;
return info;
}
}

@ -12,14 +12,14 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
@ -29,20 +29,25 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const;
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,11 +5,16 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
#include "../mwworld/actionopen.hpp"
@ -62,7 +67,7 @@ namespace MWClass
}
}
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
@ -77,7 +82,7 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
const std::string lockedSound = "LockedChest";
const std::string trapActivationSound = "Disarm Trap Fail";
@ -87,7 +92,7 @@ namespace MWClass
{
// TODO check for key
std::cout << "Locked container" << std::endl;
environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
}
else
@ -103,7 +108,7 @@ namespace MWClass
{
// Trap activation goes here
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound3D (ptr, trapActivationSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0);
ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
}
@ -141,5 +146,37 @@ namespace MWClass
registerClass (typeid (ESM::Container).name(), instance);
}
bool Container::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
if (ref->ref.lockLevel > 0)
text += "\n" + store.gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + store.gameSettings.search("sTrapped")->str;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -14,16 +14,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store

@ -6,12 +6,15 @@
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwgui/window_manager.hpp"
namespace
{
struct CustomData : public MWWorld::CustomData
@ -74,7 +77,7 @@ namespace MWClass
actors.insertCreature(ptr);
}
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
@ -87,14 +90,14 @@ namespace MWClass
}
}
void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
void Creature::enable (const MWWorld::Ptr& ptr) const
{
environment.mMechanicsManager->addActor (ptr);
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
}
void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
void Creature::disable (const MWWorld::Ptr& ptr) const
{
environment.mMechanicsManager->removeActor (ptr);
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
}
std::string Creature::getName (const MWWorld::Ptr& ptr) const
@ -113,7 +116,7 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}
@ -140,4 +143,27 @@ namespace MWClass
registerClass (typeid (ESM::Creature).name(), instance);
}
bool Creature::hasToolTip (const MWWorld::Ptr& ptr) const
{
/// \todo We don't want tooltips for Creatures in combat mode.
return true;
}
MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

@ -20,23 +20,29 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
virtual void enable (const MWWorld::Ptr& ptr) const;
///< Enable reference; only does the non-rendering part
virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
virtual void disable (const MWWorld::Ptr& ptr) const;
///< Enable reference; only does the non-rendering part
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
///< Return creature stats
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual MWWorld::ContainerStore& getContainerStore (

@ -5,13 +5,17 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
@ -34,7 +38,7 @@ namespace MWClass
}
}
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
@ -58,7 +62,7 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
@ -73,7 +77,7 @@ namespace MWClass
// TODO check for key
// TODO report failure to player (message, sound?). Look up behaviour of original MW.
std::cout << "Locked!" << std::endl;
environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
}
@ -81,7 +85,7 @@ namespace MWClass
{
// Trap activation
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound3D(ptr, trapActivationSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0);
ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
}
@ -89,11 +93,11 @@ namespace MWClass
if (ref->ref.teleport)
{
// teleport door
if (environment.mWorld->getPlayer().getPlayer()==actor)
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
{
// the player is using the door
// The reason this is not 3D is that it would get interrupted when you teleport
environment.mSoundManager->playSound(openSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
}
@ -110,7 +114,7 @@ namespace MWClass
// TODO return action for rotating the door
// This is a little pointless, but helps with testing
environment.mSoundManager->playSound3D (ptr, openSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
}
}
@ -142,4 +146,63 @@ namespace MWClass
registerClass (typeid (ESM::Door).name(), instance);
}
bool Door::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
if (ref->ref.teleport)
{
std::string dest;
if (ref->ref.destCell != "")
{
// door leads to an interior, use interior name as tooltip
dest = ref->ref.destCell;
}
else
{
// door leads to exterior, use cell name (if any), otherwise translated region name
int x,y;
MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.doorDest.pos[0], ref->ref.doorDest.pos[1], x, y);
const ESM::Cell* cell = store.cells.findExt(x,y);
if (cell->name != "")
dest = cell->name;
else
{
const ESM::Region* region = store.regions.search(cell->region);
dest = region->name;
}
}
text += "\n" + store.gameSettings.search("sTo")->str;
text += "\n"+dest;
}
if (ref->ref.lockLevel > 0)
text += "\n" + store.gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + store.gameSettings.search("sTrapped")->str;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const;
///< Lock object

@ -5,9 +5,14 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -31,7 +36,7 @@ namespace MWClass
}
}
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
@ -52,9 +57,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -83,12 +88,12 @@ namespace MWClass
registerClass (typeid (ESM::Ingredient).name(), instance);
}
std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Ingredient Up");
}
std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Ingredient Down");
}
@ -100,4 +105,38 @@ namespace MWClass
return ref->base->icon;
}
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -30,10 +36,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,11 +5,16 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
@ -39,7 +44,7 @@ namespace MWClass
objects.insertLight (ptr, r, g, b, radius);
}
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
@ -52,14 +57,14 @@ namespace MWClass
}
}
void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
void Light::enable (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
if (!ref->base->sound.empty())
{
environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop);
}
}
@ -75,7 +80,7 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
@ -83,7 +88,7 @@ namespace MWClass
if (!(ref->base->data.flags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -125,16 +130,17 @@ namespace MWClass
registerClass (typeid (ESM::Light).name(), instance);
}
std::string Light::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Light::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Misc Up");
}
std::string Light::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Light::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Misc Down");
}
std::string Light::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
@ -142,4 +148,38 @@ namespace MWClass
return ref->base->icon;
}
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,9 +12,9 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
virtual void enable (const MWWorld::Ptr& ptr) const;
///< Enable reference; only does the non-rendering part
/// \attention This is not the same as the script instruction with the same name. References
/// should only be enabled while in an active cell.
@ -23,8 +23,14 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
@ -39,10 +45,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,10 +5,14 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -32,7 +36,7 @@ namespace MWClass
}
}
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
@ -56,9 +60,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -96,12 +100,12 @@ namespace MWClass
registerClass (typeid (ESM::Tool).name(), instance);
}
std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Lockpick Up");
}
std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Lockpick Down");
}
@ -113,4 +117,42 @@ namespace MWClass
return ref->base->icon;
}
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
/// \todo store remaining uses somewhere
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -34,10 +40,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,14 +5,21 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
#include <boost/lexical_cast.hpp>
namespace MWClass
{
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -31,7 +38,7 @@ namespace MWClass
}
}
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
@ -54,9 +61,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -85,24 +92,24 @@ namespace MWClass
registerClass (typeid (ESM::Miscellaneous).name(), instance);
}
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
{
return std::string("Item Gold Up");
}
return std::string("Item Misc Up");
}
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
{
return std::string("Item Gold Down");
}
@ -116,4 +123,49 @@ namespace MWClass
return ref->base->icon;
}
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
if (ref->ref.soul != "")
{
const ESM::Creature *creature = store.creatures.search(ref->ref.soul);
info.caption += " (" + creature->name + ")";
}
std::string text;
if (ref->base->name == store.gameSettings.search("sGold")->str)
info.caption += " (" + boost::lexical_cast<std::string>(ref->base->data.value) + ")";
else
{
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
}
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -30,10 +36,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -14,11 +14,14 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwbase/environment.hpp"
namespace
{
const Ogre::Radian kOgrePi (Ogre::Math::PI);
@ -105,10 +108,13 @@ namespace MWClass
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{
renderingInterface.getActors().insertNPC(ptr);
renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr));
}
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
@ -130,14 +136,14 @@ namespace MWClass
}
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
void Npc::enable (const MWWorld::Ptr& ptr) const
{
environment.mMechanicsManager->addActor (ptr);
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
}
void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
void Npc::disable (const MWWorld::Ptr& ptr) const
{
environment.mMechanicsManager->removeActor (ptr);
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
}
std::string Npc::getName (const MWWorld::Ptr& ptr) const
@ -163,7 +169,7 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}
@ -281,11 +287,12 @@ namespace MWClass
{
Ogre::Vector3 vector (0, 0, 0);
vector.x = - getMovementSettings (ptr).mLeftRight * 200;
vector.y = getMovementSettings (ptr).mForwardBackward * 200;
vector.x = - getMovementSettings (ptr).mLeftRight * 127;
vector.y = getMovementSettings (ptr).mForwardBackward * 127;
vector.z = getMovementSettings(ptr).mUpDown * 127;
if (getStance (ptr, Run, false))
vector *= 2;
//if (getStance (ptr, Run, false))
// vector *= 2;
return vector;
}
@ -293,7 +300,29 @@ namespace MWClass
void Npc::registerSelf()
{
boost::shared_ptr<Class> instance (new Npc);
std::cout << "class npc:" << typeid (ESM::NPC).name();
registerClass (typeid (ESM::NPC).name(), instance);
}
bool Npc::hasToolTip (const MWWorld::Ptr& ptr) const
{
/// \todo We don't want tooltips for NPCs in combat mode.
return true;
}
MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

@ -17,12 +17,12 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
virtual void enable (const MWWorld::Ptr& ptr) const;
///< Enable reference; only does the non-rendering part
virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
virtual void disable (const MWWorld::Ptr& ptr) const;
///< Enable reference; only does the non-rendering part
virtual std::string getName (const MWWorld::Ptr& ptr) const;
@ -38,11 +38,17 @@ namespace MWClass
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWWorld::InventoryStore& getInventoryStore (const MWWorld::Ptr& ptr) const;
///< Return inventory store
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

@ -5,9 +5,14 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -31,7 +36,7 @@ namespace MWClass
}
}
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
@ -54,9 +59,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -85,17 +90,16 @@ namespace MWClass
registerClass (typeid (ESM::Potion).name(), instance);
}
std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Potion Up");
}
std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Potion Down");
}
std::string Potion::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
@ -103,4 +107,40 @@ namespace MWClass
return ref->base->icon;
}
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
info.effects = &ref->base->effects;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -30,10 +36,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,10 +5,14 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -32,7 +36,7 @@ namespace MWClass
}
}
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
@ -55,9 +59,9 @@ namespace MWClass
return ref->base->name;
}
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -95,12 +99,12 @@ namespace MWClass
registerClass (typeid (ESM::Probe).name(), instance);
}
std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Probe Up");
}
std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Probe Down");
}
@ -112,4 +116,42 @@ namespace MWClass
return ref->base->icon;
}
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
/// \todo store remaining uses somewhere
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -34,10 +40,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -5,9 +5,13 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -31,7 +35,7 @@ namespace MWClass
}
}
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
@ -54,9 +58,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -85,12 +89,12 @@ namespace MWClass
registerClass (typeid (ESM::Repair).name(), instance);
}
std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Repair Up");
}
std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Repair Down");
}
@ -102,4 +106,41 @@ namespace MWClass
return ref->base->icon;
}
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
/// \todo store remaining uses somewhere
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
@ -30,10 +36,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -25,7 +25,7 @@ namespace MWClass
}
}
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
ptr.get<ESM::Static>();

@ -12,7 +12,7 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);

@ -5,10 +5,15 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -32,7 +37,7 @@ namespace MWClass
}
}
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
@ -55,9 +60,9 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
const MWWorld::Ptr& actor) const
{
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
@ -108,8 +113,7 @@ namespace MWClass
return std::make_pair (slots, stack);
}
int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const
int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
@ -154,7 +158,7 @@ namespace MWClass
registerClass (typeid (ESM::Weapon).name(), instance);
}
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
@ -200,7 +204,7 @@ namespace MWClass
return std::string("Item Misc Up");
}
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
@ -246,7 +250,6 @@ namespace MWClass
return std::string("Item Misc Down");
}
std::string Weapon::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
@ -254,4 +257,94 @@ namespace MWClass
return ref->base->icon;
}
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string text;
// weapon type & damage. arrows / bolts don't have his info.
if (ref->base->data.type < 12)
{
text += "\n" + store.gameSettings.search("sType")->str + " ";
std::map <int, std::pair <std::string, std::string> > mapping;
mapping[ESM::Weapon::ShortBladeOneHand] = std::make_pair("sSkillShortblade", "sOneHanded");
mapping[ESM::Weapon::LongBladeOneHand] = std::make_pair("sSkillLongblade", "sOneHanded");
mapping[ESM::Weapon::LongBladeTwoHand] = std::make_pair("sSkillLongblade", "sTwoHanded");
mapping[ESM::Weapon::BluntOneHand] = std::make_pair("sSkillBluntweapon", "sOneHanded");
mapping[ESM::Weapon::BluntTwoClose] = std::make_pair("sSkillBluntweapon", "sTwoHanded");
mapping[ESM::Weapon::BluntTwoWide] = std::make_pair("sSkillBluntweapon", "sTwoHanded");
mapping[ESM::Weapon::SpearTwoWide] = std::make_pair("sSkillSpear", "sTwoHanded");
mapping[ESM::Weapon::AxeOneHand] = std::make_pair("sSkillAxe", "sOneHanded");
mapping[ESM::Weapon::AxeTwoHand] = std::make_pair("sSkillAxe", "sTwoHanded");
mapping[ESM::Weapon::MarksmanBow] = std::make_pair("sSkillMarksman", "");
mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", "");
mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", "");
std::string type = mapping[ref->base->data.type].first;
std::string oneOrTwoHanded = mapping[ref->base->data.type].second;
text += store.gameSettings.search(type)->str +
((oneOrTwoHanded != "") ? ", " + store.gameSettings.search(oneOrTwoHanded)->str : "");
// weapon damage
if (ref->base->data.type >= 9)
{
// marksman
text += "\n" + store.gameSettings.search("sAttack")->str + ": "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
}
else
{
// Chop
text += "\n" + store.gameSettings.search("sChop")->str + ": "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
// Slash
text += "\n" + store.gameSettings.search("sSlash")->str + ": "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[1]));
// Thrust
text += "\n" + store.gameSettings.search("sThrust")->str + ": "
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[0]))
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[1]));
}
}
/// \todo store the current weapon health somewhere
if (ref->base->data.type < 11) // thrown weapons and arrows/bolts don't have health, only quantity
text += "\n" + store.gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
info.enchant = ref->base->enchant;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

@ -12,16 +12,22 @@ namespace MWClass
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
///< \return Item health data available?
@ -35,8 +41,7 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const;
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill.
@ -45,10 +50,10 @@ namespace MWClass
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;

@ -9,9 +9,9 @@
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp"
@ -54,6 +54,20 @@ namespace
return lowerCase;
}
bool stringCompareNoCase (std::string first, std::string second)
{
unsigned int i=0;
while ( (i<first.length()) && (i<second.length()) )
{
if (tolower(first[i])<tolower(second[i])) return true;
else if (tolower(first[i])>tolower(second[i])) return false;
++i;
}
if (first.length()<second.length())
return true;
else
return false;
}
template<typename T1, typename T2>
bool selectCompare (char comp, T1 value1, T2 value2)
@ -147,6 +161,8 @@ namespace MWDialogue
bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice)
{
bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name());
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
iter != info.selects.end(); ++iter)
{
@ -181,7 +197,10 @@ namespace MWDialogue
case 46://Same faction
{
MWMechanics::NpcStats PCstats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer());
if (isCreature)
return false;
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);
int sameFaction = 0;
if(!NPCstats.mFactionRank.empty())
@ -269,6 +288,8 @@ namespace MWDialogue
bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
const ESM::DialInfo::SelectStruct& select) const
{
bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name());
char type = select.selectRule[1];
if (type!='0')
@ -288,12 +309,12 @@ namespace MWDialogue
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
select.type==ESM::VT_Long)
{
if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld))
if (!checkGlobal (comp, toLower (name), select.i, *MWBase::Environment::get().getWorld()))
return false;
}
else if (select.type==ESM::VT_Float)
{
if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld))
if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld()))
return false;
}
else
@ -308,13 +329,13 @@ namespace MWDialogue
select.type==ESM::VT_Long)
{
if (!checkLocal (comp, toLower (name), select.i, actor,
mEnvironment.mWorld->getStore()))
MWBase::Environment::get().getWorld()->getStore()))
return false;
}
else if (select.type==ESM::VT_Float)
{
if (!checkLocal (comp, toLower (name), select.f, actor,
mEnvironment.mWorld->getStore()))
MWBase::Environment::get().getWorld()->getStore()))
return false;
}
else
@ -326,7 +347,7 @@ namespace MWDialogue
case '4'://journal
if(select.type==ESM::VT_Int)
{
if(!selectCompare<int,int>(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false;
if(!selectCompare<int,int>(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.i)) return false;
}
else
throw std::runtime_error (
@ -336,7 +357,7 @@ namespace MWDialogue
case '5'://item
{
MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
int sum = 0;
@ -366,6 +387,9 @@ namespace MWDialogue
return true;
case '8':// not faction
if (isCreature)
return false;
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
@ -380,6 +404,9 @@ namespace MWDialogue
return true;
case '9':// not class
if (isCreature)
return false;
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
@ -394,6 +421,9 @@ namespace MWDialogue
return true;
case 'A'://not Race
if (isCreature)
return false;
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
@ -424,13 +454,13 @@ namespace MWDialogue
select.type==ESM::VT_Long)
{
if (checkLocal (comp, toLower (name), select.i, actor,
mEnvironment.mWorld->getStore()))
MWBase::Environment::get().getWorld()->getStore()))
return false;
}
else if (select.type==ESM::VT_Float)
{
if (checkLocal (comp, toLower (name), select.f, actor,
mEnvironment.mWorld->getStore()))
MWBase::Environment::get().getWorld()->getStore()))
return false;
}
else
@ -450,6 +480,8 @@ namespace MWDialogue
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
{
bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name());
// actor id
if (!info.actor.empty())
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
@ -458,6 +490,9 @@ namespace MWDialogue
//NPC race
if (!info.race.empty())
{
if (isCreature)
return false;
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
if (!cellRef)
@ -470,6 +505,9 @@ namespace MWDialogue
//NPC class
if (!info.clas.empty())
{
if (isCreature)
return false;
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
if (!cellRef)
@ -482,6 +520,9 @@ namespace MWDialogue
//NPC faction
if (!info.npcFaction.empty())
{
if (isCreature)
return false;
//MWWorld::Class npcClass = MWWorld::Class::get(actor);
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(info.npcFaction);
@ -500,7 +541,7 @@ namespace MWDialogue
// TODO check player faction
if(!info.pcFaction.empty())
{
MWMechanics::NpcStats stats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->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(info.pcFaction);
if(it!=stats.mFactionRank.end())
{
@ -515,20 +556,22 @@ namespace MWDialogue
}
//check gender
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
if(npc->base->flags&npc->base->Female)
if (!isCreature)
{
if(static_cast<int> (info.data.gender)==0) return false;
}
else
{
if(static_cast<int> (info.data.gender)==1) return false;
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
if(npc->base->flags&npc->base->Female)
{
if(static_cast<int> (info.data.gender)==0) return false;
}
else
{
if(static_cast<int> (info.data.gender)==1) return false;
}
}
// check cell
if (!info.cell.empty())
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->name != info.cell)
return false;
// TODO check DATAstruct
@ -540,8 +583,8 @@ namespace MWDialogue
return true;
}
DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) :
mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment),
DialogueManager::DialogueManager (const Compiler::Extensions& extensions) :
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
{
mChoice = -1;
@ -549,10 +592,10 @@ namespace MWDialogue
mCompilerContext.setExtensions (&extensions);
mDialogueMap.clear();
actorKnownTopics.clear();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
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++)
{
mDialogueMap[it->first] = it->second;
mDialogueMap[toLower(it->first)] = it->second;
}
}
@ -592,8 +635,8 @@ namespace MWDialogue
actorKnownTopics.clear();
//initialise the GUI
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->startDialogue(MWWorld::Class::get (actor).getName (actor));
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
@ -601,9 +644,9 @@ namespace MWDialogue
//greeting
bool greetingFound = false;
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
//ESMS::RecListT<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++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Greeting)
@ -650,7 +693,7 @@ namespace MWDialogue
if (!actorScript.empty())
{
// grab local variables from actor's script, if available.
locals = mEnvironment.mScriptManager->getLocals (actorScript);
locals = MWBase::Environment::get().getScriptManager()->getLocals (actorScript);
}
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
@ -677,13 +720,12 @@ namespace MWDialogue
void DialogueManager::executeScript(std::string script)
{
std::cout << script;
std::vector<Interpreter::Type_Code> code;
if(compile(script,code))
{
try
{
MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor);
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
interpreter.run (&code[0], code.size(), interpreterContext);
@ -701,9 +743,9 @@ namespace MWDialogue
int choice = mChoice;
mChoice = -1;
actorKnownTopics.clear();
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
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++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Topic)
@ -713,7 +755,7 @@ namespace MWDialogue
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
actorKnownTopics.push_back(it->first);
actorKnownTopics.push_back(toLower(it->first));
//does the player know the topic?
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
{
@ -724,7 +766,11 @@ namespace MWDialogue
}
}
}
// sort again, because the previous sort was case-sensitive
keywordList.sort(stringCompareNoCase);
win->setKeywords(keywordList);
mChoice = choice;
}
@ -747,7 +793,7 @@ namespace MWDialogue
parseText(text);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->addTitle(keyword);
win->addText(iter->response);
@ -767,7 +813,7 @@ namespace MWDialogue
void DialogueManager::goodbyeSelected()
{
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game);
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game);
}
void DialogueManager::questionAnswered(std::string answere)
@ -790,7 +836,7 @@ namespace MWDialogue
mChoiceMap.clear();
mChoice = -1;
mIsInChoice = false;
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
std::string text = iter->response;
parseText(text);
win->addText(text);
@ -808,20 +854,23 @@ namespace MWDialogue
void DialogueManager::printError(std::string error)
{
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->addText(error);
}
void DialogueManager::askQuestion(std::string question, int choice)
{
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->askQuestion(question);
mChoiceMap[question] = choice;
mChoiceMap[toLower(question)] = choice;
mIsInChoice = true;
}
std::string DialogueManager::getFaction()
{
if (mActor.getTypeName() != typeid(ESM::NPC).name())
return "";
std::string factionID("");
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
if(stats.mFactionRank.empty())

@ -11,17 +11,10 @@
#include "../mwworld/ptr.hpp"
#include <map>
namespace MWWorld
{
class Environment;
}
namespace MWDialogue
{
class DialogueManager
{
MWWorld::Environment& mEnvironment;
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const;
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
@ -39,7 +32,7 @@ namespace MWDialogue
MWScript::CompilerContext mCompilerContext;
std::ostream mErrorStream;
Compiler::StreamErrorHandler mErrorHandler;
bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code);
void executeScript(std::string script);
@ -55,7 +48,7 @@ namespace MWDialogue
public:
DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions);
DialogueManager (const Compiler::Extensions& extensions);
void startDialogue (const MWWorld::Ptr& actor);

@ -1,7 +1,7 @@
#include "journal.hpp"
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/messagebox.hpp"
@ -23,31 +23,30 @@ namespace MWDialogue
return iter->second;
}
Journal::Journal (MWWorld::Environment& environment)
: mEnvironment (environment)
Journal::Journal()
{}
void Journal::addEntry (const std::string& id, int index)
{
StampedJournalEntry entry =
StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld);
StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld());
mJournal.push_back (entry);
Quest& quest = getQuest (id);
quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here
quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here
std::vector<std::string> empty;
std::string notification = "Your Journal has been updated.";
mEnvironment.mWindowManager->messageBox (notification, empty);
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
}
void Journal::setJournalIndex (const std::string& id, int index)
{
Quest& quest = getQuest (id);
quest.setIndex (index, *mEnvironment.mWorld);
quest.setIndex (index, *MWBase::Environment::get().getWorld());
}
void Journal::addTopic (const std::string& topicId, const std::string& infoId)
@ -62,7 +61,7 @@ namespace MWDialogue
iter = result.first;
}
iter->second.addEntry (JournalEntry (topicId, infoId), *mEnvironment.mWorld);
iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld());
}
int Journal::getJournalIndex (const std::string& id) const

@ -8,11 +8,6 @@
#include "journalentry.hpp"
#include "quest.hpp"
namespace MWWorld
{
struct Environment;
}
namespace MWDialogue
{
/// \brief The player's journal
@ -29,7 +24,6 @@ namespace MWDialogue
private:
MWWorld::Environment& mEnvironment;
TEntryContainer mJournal;
TQuestContainer mQuests;
TTopicContainer mTopics;
@ -38,7 +32,7 @@ namespace MWDialogue
public:
Journal (MWWorld::Environment& environment);
Journal();
void addEntry (const std::string& id, int index);
///< Add a journal entry.

@ -25,13 +25,14 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager)
birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->setCaption(mWindowManager.getGameSettingString("sBack", ""));
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked);
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
updateBirths();
@ -46,21 +47,16 @@ void BirthDialog::setNextButtonShow(bool shown)
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
// TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system.
if (shown)
{
okButton->setCaption("Next");
// Adjust back button when next is shown
backButton->setCoord(MyGUI::IntCoord(375 - 18, 340, 53, 23));
okButton->setCoord(MyGUI::IntCoord(431 - 18, 340, 42 + 18, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
else
{
okButton->setCaption("OK");
backButton->setCoord(MyGUI::IntCoord(375, 340, 53, 23));
okButton->setCoord(MyGUI::IntCoord(431, 340, 42, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
int okButtonWidth = okButton->getTextSize().width + 24;
int backButtonWidth = backButton->getTextSize().width + 24;
okButton->setCoord(473 - okButtonWidth, 340, okButtonWidth, 23);
backButton->setCoord(473 - okButtonWidth - backButtonWidth - 6, 340, backButtonWidth, 23);
}
void BirthDialog::open()
@ -206,7 +202,7 @@ void BirthDialog::updateSpells()
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?
spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord);
spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0);
coord.top = spellCoord.top;
++i;

@ -8,12 +8,16 @@
#include "dialogue.hpp"
#include "mode.hpp"
#include "../mwbase/environment.hpp"
#include "../mwsound/soundmanager.hpp"
namespace
{
struct Step
{
const char* mText;
const char* mButtons[3];
const char* mSound;
ESM::Class::Specialization mSpecializations[3]; // The specialization for each answer
};
@ -23,6 +27,7 @@ namespace
{"Draw your dagger, mercifully endings its life with a single thrust.",
"Use herbs from your pack to put it to sleep.",
"Do not interfere in the natural evolution of events, but rather take the opportunity to learn more about a strange animal that you have never seen before."},
"vo\\misc\\chargen qa1.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 2
@ -30,6 +35,7 @@ namespace
{"Work in the forge with him casting iron for a new plow.",
"Gather herbs for your mother who is preparing dinner.",
"Go catch fish at the stream using a net and line."},
"vo\\misc\\chargen qa2.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 3
@ -37,6 +43,7 @@ namespace
{"Beat up your cousin, then tell him that if he ever calls you that nickname again, you will bloody him worse than this time.",
"Make up a story that makes your nickname a badge of honor instead of something humiliating.",
"Make up an even more embarrassing nickname for him and use it constantly until he learns his lesson."},
"vo\\misc\\chargen qa3.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 4
@ -44,6 +51,7 @@ namespace
{"This is a terrible practice. A person's thoughts are his own and no one, not even a king, has the right to make such an invasion into another human's mind.",
"Loyal followers to the king have nothing to fear from a Telepath. It is important to have a method of finding assassins and spies before it is too late.",
"In these times, it is a necessary evil. Although you do not necessarily like the idea, a Telepath could have certain advantages during a time of war or in finding someone innocent of a crime."},
"vo\\misc\\chargen qa4.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 5
@ -51,6 +59,7 @@ namespace
{"Return to the store and give the shopkeeper his hard-earned money, explaining to him the mistake?",
"Decide to put the extra money to good use and purchase items that would help your family?",
"Pocket the extra money, knowing that shopkeepers in general tend to overcharge customers anyway?"},
"vo\\misc\\chargen qa5.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 6
@ -58,6 +67,7 @@ namespace
{"Pick up the bag and signal to the guard, knowing that the only honorable thing to do is return the money to its rightful owner.",
"Leave the bag there, knowing that it is better not to get involved.",
"Pick up the bag and pocket it, knowing that the extra windfall will help your family in times of trouble."},
"vo\\misc\\chargen qa6.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 7
@ -65,6 +75,7 @@ namespace
{"Decline his offer, knowing that your father expects you to do the work, and it is better not to be in debt.",
"Ask him to help you, knowing that two people can do the job faster than one, and agree to help him with one task of his choosing in the future.",
"Accept his offer, reasoning that as long as the stables are cleaned, it matters not who does the cleaning."},
"vo\\misc\\chargen qa7.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 8
@ -72,6 +83,7 @@ namespace
{"Position yourself between the pipe and your mother.",
"Grab the hot pipe and try to push it away.",
"Push your mother out of the way."},
"vo\\misc\\chargen qa8.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 9
@ -79,6 +91,7 @@ namespace
{"Drop the sweetroll and step on it, then get ready for the fight.",
"Give him the sweetroll now without argument, knowing that later this afternoon you will have all your friends with you and can come and take whatever he owes you.",
"Act like you're going to give him the sweetroll, but at the last minute throw it in the air, hoping that they'll pay attention to it long enough for you to get a shot in on the leader."},
"vo\\misc\\chargen qa9.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
},
// Question 10
@ -86,6 +99,7 @@ namespace
{"Rush to the town's aid immediately, despite your lack of knowledge of the circumstances.",
"Stand aside and allow the man and the mob to pass, realizing it is probably best not to get involved.",
"Rush to the man's aid immediately, despite your lack of knowledge of the circumstances."},
"vo\\misc\\chargen qa10.wav",
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
}
} };
@ -93,7 +107,7 @@ namespace
using namespace MWGui;
CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment)
CharacterCreation::CharacterCreation(WindowManager* _wm)
: mNameDialog(0)
, mRaceDialog(0)
, mDialogueWindow(0)
@ -105,7 +119,6 @@ CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _
, mBirthSignDialog(0)
, mReviewDialog(0)
, mWM(_wm)
, mEnvironment(_environment)
{
mCreationStage = CSE_NotStarted;
}
@ -279,8 +292,8 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
{
const std::string &classId = mPickClassDialog->getClassId();
if (!classId.empty())
mEnvironment->mMechanicsManager->setPlayerClass(classId);
const ESM::Class *klass = mEnvironment->mWorld->getStore().classes.find(classId);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId);
if (klass)
{
mPlayerClass = *klass;
@ -307,7 +320,7 @@ void CharacterCreation::onPickClassDialogBack()
{
const std::string classId = mPickClassDialog->getClassId();
if (!classId.empty())
mEnvironment->mMechanicsManager->setPlayerClass(classId);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
mWM->removeDialog(mPickClassDialog);
}
@ -345,7 +358,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
{
mPlayerName = mNameDialog->getTextInput();
mWM->setValue("name", mPlayerName);
mEnvironment->mMechanicsManager->setPlayerName(mPlayerName);
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
mWM->removeDialog(mNameDialog);
}
@ -366,7 +379,7 @@ void CharacterCreation::onRaceDialogBack()
{
mPlayerRaceId = mRaceDialog->getRaceId();
if (!mPlayerRaceId.empty())
mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog);
}
@ -380,7 +393,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
mPlayerRaceId = mRaceDialog->getRaceId();
mWM->setValue("race", mPlayerRaceId);
if (!mPlayerRaceId.empty())
mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog);
}
@ -402,7 +415,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
mPlayerBirthSignId = mBirthSignDialog->getBirthId();
mWM->setBirthSign(mPlayerBirthSignId);
if (!mPlayerBirthSignId.empty())
mEnvironment->mMechanicsManager->setPlayerBirthsign(mPlayerBirthSignId);
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
mWM->removeDialog(mBirthSignDialog);
}
@ -419,7 +432,7 @@ void CharacterCreation::onBirthSignDialogBack()
{
if (mBirthSignDialog)
{
mEnvironment->mMechanicsManager->setPlayerBirthsign(mBirthSignDialog->getBirthId());
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
mWM->removeDialog(mBirthSignDialog);
}
@ -450,7 +463,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
klass.data.skills[i][1] = majorSkills[i];
klass.data.skills[i][0] = minorSkills[i];
}
mEnvironment->mMechanicsManager->setPlayerClass(klass);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass);
mPlayerClass = klass;
mWM->setPlayerClass(klass);
@ -478,6 +491,8 @@ void CharacterCreation::onCreateClassDialogBack()
void CharacterCreation::onClassQuestionChosen(int _index)
{
MWBase::Environment::get().getSoundManager()->stopSay();
if (mGenerateClassQuestionDialog)
mWM->removeDialog(mGenerateClassQuestionDialog);
if (_index < 0 || _index >= 3)
@ -583,6 +598,8 @@ void CharacterCreation::showClassQuestionDialog()
mGenerateClassQuestionDialog->setButtons(buttons);
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
mGenerateClassQuestionDialog->open();
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound);
}
void CharacterCreation::onGenerateClassBack()
@ -592,7 +609,7 @@ void CharacterCreation::onGenerateClassBack()
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog);
mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
mWM->setGuiMode(GM_Class);
}
@ -601,7 +618,7 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog);
mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review);

@ -30,7 +30,7 @@ namespace MWGui
public:
typedef std::vector<int> SkillList;
CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment);
CharacterCreation(WindowManager* _wm);
~CharacterCreation();
//Show a dialog
@ -56,7 +56,6 @@ namespace MWGui
ReviewDialog* mReviewDialog;
WindowManager* mWM;
MWWorld::Environment* mEnvironment;
//Player data
std::string mPlayerName;

@ -26,14 +26,20 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
getWidget(classImage, "ClassImage");
getWidget(className, "ClassName");
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->setCaption(mWindowManager.getGameSettingString("sBack", ""));
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
int okButtonWidth = okButton->getTextSize().width + 24;
int backButtonWidth = backButton->getTextSize().width + 24;
okButton->setCoord(315 - okButtonWidth, 219, okButtonWidth, 23);
backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23);
}
void GenerateClassResultDialog::open()
@ -102,7 +108,6 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
getWidget(classImage, "ClassImage");
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked);
@ -123,21 +128,16 @@ void PickClassDialog::setNextButtonShow(bool shown)
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
// TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system.
if (shown)
{
okButton->setCaption("Next");
// Adjust back button when next is shown
backButton->setCoord(MyGUI::IntCoord(382 - 18, 265, 53, 23));
okButton->setCoord(MyGUI::IntCoord(434 - 18, 265, 42 + 18, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
else
{
okButton->setCaption("OK");
backButton->setCoord(MyGUI::IntCoord(382, 265, 53, 23));
okButton->setCoord(MyGUI::IntCoord(434, 265, 42, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
int okButtonWidth = okButton->getTextSize().width + 24;
int backButtonWidth = backButton->getTextSize().width + 24;
okButton->setCoord(476 - okButtonWidth, 265, okButtonWidth, 23);
backButton->setCoord(476 - okButtonWidth - backButtonWidth - 6, 265, backButtonWidth, 23);
}
void PickClassDialog::open()
@ -423,9 +423,9 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
// Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(editName);
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr descriptionButton;
getWidget(descriptionButton, "DescriptionButton");
descriptionButton->setCaption(mWindowManager.getGameSettingString("sCreateClassMenu1", ""));
descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked);
MyGUI::ButtonPtr backButton;
@ -507,32 +507,27 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
void CreateClassDialog::setNextButtonShow(bool shown)
{
MyGUI::ButtonPtr descriptionButton;
getWidget(descriptionButton, "DescriptionButton");
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
// TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system.
if (shown)
{
okButton->setCaption("Next");
MyGUI::ButtonPtr descriptionButton;
getWidget(descriptionButton, "DescriptionButton");
// Adjust back button when next is shown
descriptionButton->setCoord(MyGUI::IntCoord(207 - 18, 158, 143, 23));
backButton->setCoord(MyGUI::IntCoord(356 - 18, 158, 53, 23));
okButton->setCoord(MyGUI::IntCoord(417 - 18, 158, 42 + 18, 23));
}
if (shown)
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
else
{
okButton->setCaption("OK");
descriptionButton->setCoord(MyGUI::IntCoord(207, 158, 143, 23));
backButton->setCoord(MyGUI::IntCoord(356, 158, 53, 23));
okButton->setCoord(MyGUI::IntCoord(417, 158, 42, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
int okButtonWidth = okButton->getTextSize().width + 24;
int backButtonWidth = backButton->getTextSize().width + 24;
int descriptionButtonWidth = descriptionButton->getTextSize().width + 24;
okButton->setCoord(459 - okButtonWidth, 158, okButtonWidth, 23);
backButton->setCoord(459 - okButtonWidth - backButtonWidth - 6, 158, backButtonWidth, 23);
descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23);
}
void CreateClassDialog::open()
@ -679,11 +674,12 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specializationId = ESM::Class::Combat;
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21);
}
// widget controls
@ -728,11 +724,12 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
}
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21);
}
// widget controls
@ -817,11 +814,12 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
}
}
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21);
}
// widget controls
@ -847,11 +845,12 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
getWidget(textEdit, "TextEdit");
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
int buttonWidth = okButton->getTextSize().width + 24;
okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24);
// Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);

@ -7,6 +7,8 @@
#include "../mwscript/extensions.hpp"
#include "../mwbase/environment.hpp"
namespace MWGui
{
class ConsoleInterpreterContext : public MWScript::InterpreterContext
@ -15,15 +17,14 @@ namespace MWGui
public:
ConsoleInterpreterContext (Console& console, MWWorld::Environment& environment,
MWWorld::Ptr reference);
ConsoleInterpreterContext (Console& console, MWWorld::Ptr reference);
virtual void report (const std::string& message);
};
ConsoleInterpreterContext::ConsoleInterpreterContext (Console& console,
MWWorld::Environment& environment, MWWorld::Ptr reference)
: MWScript::InterpreterContext (environment,
MWWorld::Ptr reference)
: MWScript::InterpreterContext (
reference.isEmpty() ? 0 : &reference.getRefData().getLocals(), reference),
mConsole (console)
{}
@ -88,7 +89,7 @@ namespace MWGui
scanner.listKeywords (mNames);
// identifier
const ESMS::ESMStore& store = mEnvironment.mWorld->getStore();
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
for (ESMS::RecListList::const_iterator iter (store.recLists.begin());
iter!=store.recLists.end(); ++iter)
@ -101,11 +102,9 @@ namespace MWGui
}
}
Console::Console(int w, int h, MWWorld::Environment& environment,
const Compiler::Extensions& extensions)
Console::Console(int w, int h, const Compiler::Extensions& extensions)
: Layout("openmw_console_layout.xml"),
mCompilerContext (MWScript::CompilerContext::Type_Console, environment),
mEnvironment (environment)
mCompilerContext (MWScript::CompilerContext::Type_Console)
{
setCoord(10,10, w-10, h/2);
@ -139,7 +138,7 @@ namespace MWGui
void Console::disable()
{
setVisible(false);
// Remove keyboard focus from the console input whenever the
// Remove keyboard focus from the console input whenever the
// console is turned off
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
}
@ -241,7 +240,7 @@ namespace MWGui
{
try
{
ConsoleInterpreterContext interpreterContext (*this, mEnvironment, MWWorld::Ptr());
ConsoleInterpreterContext interpreterContext (*this, MWWorld::Ptr());
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
std::vector<Interpreter::Type_Code> code;

@ -23,7 +23,6 @@ namespace MWGui
private:
MWScript::CompilerContext mCompilerContext;
MWWorld::Environment& mEnvironment;
std::vector<std::string> mNames;
bool compile (const std::string& cmd, Compiler::Output& output);
@ -51,7 +50,7 @@ namespace MWGui
StringList::iterator current;
std::string editString;
Console(int w, int h, MWWorld::Environment& environment, const Compiler::Extensions& extensions);
Console(int w, int h, const Compiler::Extensions& extensions);
void enable();

@ -3,7 +3,7 @@
#include "window_manager.hpp"
#include "widgets.hpp"
#include "components/esm_store/store.hpp"
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include <assert.h>
@ -36,9 +36,8 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
}
DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment)
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager),
mEnvironment(environment)
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
{
// Centre dialog
center();
@ -51,10 +50,10 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm
//An EditBox cannot receive mouse click events, so we use an
//invisible widget on top of the editbox to receive them
/// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution
getWidget(eventbox, "EventBox");
eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked);
eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel);
//Topics list
getWidget(topicsList, "TopicsList");
topicsList->setScrollVisible(true);
@ -83,12 +82,20 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
if(color != "#B29154")
{
UString key = history->getColorTextAt(cursorPosition);
if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key));
if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key);
if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key));
}
}
void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{
if (history->getVScrollPosition() - _rel*0.3 < 0)
history->setVScrollPosition(0);
else
history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3);
}
void DialogueWindow::open()
{
topicsList->removeAllItems();
@ -100,7 +107,7 @@ void DialogueWindow::open()
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{
mEnvironment.mDialogueManager->goodbyeSelected();
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
}
void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index)
@ -108,7 +115,7 @@ void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index)
if (_index == MyGUI::ITEM_NONE)
return;
std::string topic = _sender->getItemNameAt(_index);
mEnvironment.mDialogueManager->keywordSelected(lower_string(topic));
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
}
void DialogueWindow::startDialogue(std::string npcName)
@ -183,6 +190,16 @@ void DialogueWindow::addText(std::string text)
void DialogueWindow::addTitle(std::string text)
{
// This is called from the dialogue manager, so text is
// case-smashed - thus we have to retrieve the correct case
// of the text through the topic list.
for (size_t i=0; i<topicsList->getItemCount(); ++i)
{
std::string item = topicsList->getItemNameAt(i);
if (lower_string(item) == text)
text = item;
}
history->addDialogHeading(text);
}

@ -9,11 +9,6 @@ namespace MWGui
class WindowManager;
}
namespace MWWorld
{
class Environment;
}
/*
This file contains the dialouge window
Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml.
@ -23,17 +18,15 @@ namespace MWGui
{
class DialogueHistory;
using namespace MyGUI;
class DialogueWindow: public WindowBase
{
public:
DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment);
DialogueWindow(WindowManager& parWindowManager);
void open();
// Events
typedef delegates::CMultiDelegate0 EventHandle_Void;
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
@ -52,6 +45,7 @@ namespace MWGui
void onSelectTopic(MyGUI::ListBox* _sender, size_t _index);
void onByeClicked(MyGUI::Widget* _sender);
void onHistoryClicked(MyGUI::Widget* _sender);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
private:
void updateOptions();
@ -65,8 +59,6 @@ namespace MWGui
MyGUI::ProgressPtr pDispositionBar;
MyGUI::EditPtr pDispositionText;
std::map<std::string,std::string> pTopicsText;// this map links keyword and "real" text.
MWWorld::Environment& mEnvironment;
};
}
#endif

@ -1,7 +1,7 @@
#include "journalwindow.hpp"
#include "window_manager.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwsound/soundmanager.hpp"
@ -118,20 +118,20 @@ void MWGui::JournalWindow::open()
{
mPageNumber = 0;
std::string journalOpenSound = "book open";
mWindowManager.getEnvironment().mSoundManager->playSound (journalOpenSound, 1.0, 1.0);
if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end())
MWBase::Environment::get().getSoundManager()->playSound (journalOpenSound, 1.0, 1.0);
if(MWBase::Environment::get().getJournal()->begin()!=MWBase::Environment::get().getJournal()->end())
{
book journal;
journal.endLine = 0;
for(std::deque<MWDialogue::StampedJournalEntry>::const_iterator it = mWindowManager.getEnvironment().mJournal->begin();it!=mWindowManager.getEnvironment().mJournal->end();it++)
for(std::deque<MWDialogue::StampedJournalEntry>::const_iterator it = MWBase::Environment::get().getJournal()->begin();it!=MWBase::Environment::get().getJournal()->end();it++)
{
std::string a = it->getText(mWindowManager.getEnvironment().mWorld->getStore());
std::string a = it->getText(MWBase::Environment::get().getWorld()->getStore());
journal = formatText(a,journal,10,17);
journal.endLine = journal.endLine +1;
journal.pages.back() = journal.pages.back() + std::string("\n");
}
//std::string a = mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore());
//std::string a = MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore());
//std::list<std::string> journal = formatText(a,10,20,1);
bool left = true;
for(std::list<std::string>::iterator it = journal.pages.begin(); it != journal.pages.end();it++)
@ -155,7 +155,7 @@ void MWGui::JournalWindow::open()
}
else
{
//std::cout << mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore());
//std::cout << MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore());
}
}
@ -181,7 +181,7 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
if(mPageNumber < int(leftPages.size())-1)
{
std::string nextSound = "book page2";
mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0);
mPageNumber = mPageNumber + 1;
displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]);
@ -193,7 +193,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
if(mPageNumber > 0)
{
std::string prevSound = "book page";
mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0);
MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0);
mPageNumber = mPageNumber - 1;
displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]);

@ -29,6 +29,9 @@ MapWindow::MapWindow(WindowManager& parWindowManager) :
getWidget(mButton, "WorldButton");
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
mButton->setCaption(mWindowManager.getGameSettingString("sWorld", ""));
int width = mButton->getTextSize().width + 24;
mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22);
MyGUI::Button* eventbox;
getWidget(eventbox, "EventBox");
@ -97,7 +100,10 @@ void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender)
mGlobalMap->setVisible(mGlobal);
mLocalMap->setVisible(!mGlobal);
mButton->setCaption( mGlobal ? "Local" : "World" );
mButton->setCaption( mGlobal ? mWindowManager.getGameSettingString("sWorld", "") :
mWindowManager.getGameSettingString("sLocal", ""));
int width = mButton->getTextSize().width + 24;
mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22);
}
void MapWindow::onPinToggled()

@ -69,13 +69,14 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials"));
getWidget(spellPowerList, "SpellPowerList");
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->setCaption(mWindowManager.getGameSettingString("sBack", ""));
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
updateRaces();
@ -91,21 +92,16 @@ void RaceDialog::setNextButtonShow(bool shown)
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
// TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system.
if (shown)
{
okButton->setCaption("Next");
// Adjust back button when next is shown
backButton->setCoord(MyGUI::IntCoord(471 - 18, 397, 53, 23));
okButton->setCoord(MyGUI::IntCoord(532 - 18, 397, 42 + 18, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
else
{
okButton->setCaption("OK");
backButton->setCoord(MyGUI::IntCoord(471, 397, 53, 23));
okButton->setCoord(MyGUI::IntCoord(532, 397, 42, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
int okButtonWidth = okButton->getTextSize().width + 24;
int backButtonWidth = backButton->getTextSize().width + 24;
okButton->setCoord(574 - okButtonWidth, 397, okButtonWidth, 23);
backButton->setCoord(574 - okButtonWidth - backButtonWidth - 6, 397, backButtonWidth, 23);
}
void RaceDialog::open()

@ -28,21 +28,25 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
getWidget(nameWidget, "NameText");
getWidget(button, "NameButton");
button->setCaption(mWindowManager.getGameSettingString("sName", ""));
adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
getWidget(raceWidget, "RaceText");
getWidget(button, "RaceButton");
button->setCaption(mWindowManager.getGameSettingString("sRace", ""));
adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
getWidget(classWidget, "ClassText");
getWidget(button, "ClassButton");
button->setCaption(mWindowManager.getGameSettingString("sClass", ""));
adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
getWidget(birthSignWidget, "SignText");
getWidget(button, "SignButton");
button->setCaption(mWindowManager.getGameSettingString("sBirthSign", ""));
adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
// Setup dynamic stats
@ -86,14 +90,20 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->setCaption(mWindowManager.getGameSettingString("sBack", ""));
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
int backButtonWidth = backButton->getTextSize().width + 24;
int okButtonWidth = okButton->getTextSize().width + 24;
okButton->setCoord(502 - okButtonWidth, 372, okButtonWidth, 23);
backButton->setCoord(502 - okButtonWidth - backButtonWidth - 6, 372, backButtonWidth, 23);
}
void ReviewDialog::open()
@ -181,13 +191,14 @@ void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanic
{
float modified = value.getModified(), base = value.getBase();
std::string text = boost::lexical_cast<std::string>(std::floor(modified));
ColorStyle style = CS_Normal;
std::string state = "normal";
if (modified > base)
style = CS_Super;
state = "increased";
else if (modified < base)
style = CS_Sub;
state = "decreased";
setStyledText(widget, style, text);
widget->setCaption(text);
widget->_setWidgetState(state);
}
}
@ -210,17 +221,6 @@ void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vec
}
}
void ReviewDialog::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value)
{
widget->setCaption(value);
if (style == CS_Super)
widget->setTextColour(MyGUI::Colour(0, 1, 0));
else if (style == CS_Sub)
widget->setTextColour(MyGUI::Colour(1, 0, 0));
else
widget->setTextColour(MyGUI::Colour(1, 1, 1));
}
void 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);
@ -240,7 +240,7 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M
coord2.top += lineHeight;
}
MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, 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)
{
MyGUI::TextBox* skillNameWidget;
MyGUI::TextBox* skillValueWidget;
@ -249,7 +249,8 @@ MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::st
skillNameWidget->setCaption(text);
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
setStyledText(skillValueWidget, style, value);
skillValueWidget->setCaption(value);
skillValueWidget->_setWidgetState(state);
skillWidgets.push_back(skillNameWidget);
skillWidgets.push_back(skillValueWidget);
@ -295,12 +296,12 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
float base = stat.getBase();
float modified = stat.getModified();
ColorStyle style = CS_Normal;
std::string state = "normal";
if (modified > base)
style = CS_Super;
state = "increased";
else if (modified < base)
style = CS_Sub;
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
state = "decreased";
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), state, coord1, coord2);
skillWidgetMap[skillId] = widget;
}
}

@ -69,17 +69,10 @@ namespace MWGui
void onBirthSignClicked(MyGUI::Widget* _sender);
private:
enum ColorStyle
{
CS_Sub,
CS_Normal,
CS_Super
};
void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value);
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateScroller();
void updateSkillArea();

@ -72,6 +72,8 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
setupToolTips();
}
void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
@ -109,17 +111,7 @@ void StatsWindow::setBar(const std::string& name, const std::string& tname, int
void StatsWindow::setPlayerName(const std::string& playerName)
{
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(playerName);
}
void StatsWindow::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value)
{
widget->setCaption(value);
if (style == CS_Super)
widget->setTextColour(MyGUI::Colour(0, 1, 0));
else if (style == CS_Sub)
widget->setTextColour(MyGUI::Colour(1, 0, 0));
else
widget->setTextColour(MyGUI::Colour(1, 1, 1));
adjustWindowCaption();
}
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
@ -138,12 +130,15 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<int>&
valueString << value.getModified();
setText (id, valueString.str());
MyGUI::TextBox* box;
getWidget(box, id);
if (value.getModified()>value.getBase())
setTextColor (id, 0, 1, 0);
box->_setWidgetState("increased");
else if (value.getModified()<value.getBase())
setTextColor (id, 1, 0, 0);
box->_setWidgetState("decreased");
else
setTextColor (id, 1, 1, 1);
box->_setWidgetState("normal");
break;
}
@ -193,13 +188,14 @@ void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechani
{
float modified = value.getModified(), base = value.getBase();
std::string text = boost::lexical_cast<std::string>(std::floor(modified));
ColorStyle style = CS_Normal;
std::string state = "normal";
if (modified > base)
style = CS_Super;
state = "increased";
else if (modified < base)
style = CS_Sub;
state = "decreased";
setStyledText(widget, style, text);
widget->setCaption(text);
widget->_setWidgetState(state);
}
}
@ -251,15 +247,20 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My
coord2.top += lineHeight;
}
MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{
MyGUI::TextBox *skillNameWidget, *skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text);
skillNameWidget->setUserString("ToolTipType", "Text");
skillNameWidget->setUserString("ToolTipText", tooltip);
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
setStyledText(skillValueWidget, style, value);
skillValueWidget->setUserString("ToolTipType", "Text");
skillValueWidget->setUserString("ToolTipText", tooltip);
skillValueWidget->setCaption(value);
skillValueWidget->_setWidgetState(state);
skillWidgets.push_back(skillNameWidget);
skillWidgets.push_back(skillValueWidget);
@ -305,12 +306,13 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
float base = stat.getBase();
float modified = stat.getModified();
ColorStyle style = CS_Normal;
std::string state = "normal";
if (modified > base)
style = CS_Super;
state = "increased";
else if (modified < base)
style = CS_Sub;
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
state = "decreased";
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), "",
boost::lexical_cast<std::string>(static_cast<int>(modified)), state, coord1, coord2);
skillWidgetMap[skillId] = widget;
}
}
@ -369,8 +371,12 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty())
addSeparator(coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"),
mWindowManager.getGameSettingString("sSkillsMenuReputationHelp", ""),
boost::lexical_cast<std::string>(static_cast<int>(reputation)), "normal", coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"),
mWindowManager.getGameSettingString("sCrimeHelp", ""),
boost::lexical_cast<std::string>(static_cast<int>(bounty)), "normal", coord1, coord2);
clientHeight = coord1.top;
updateScroller();
@ -386,3 +392,98 @@ void StatsWindow::onPinToggled()
{
mWindowManager.setHMSVisibility(!mPinned);
}
void StatsWindow::setupToolTips()
{
const ESMS::ESMStore &store = mWindowManager.getStore();
MyGUI::Widget* widget;
getWidget(widget, "Attrib1");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_strength.dds");
getWidget(widget, "AttribVal1");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_strength.dds");
getWidget(widget, "Attrib2");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_int.dds");
getWidget(widget, "AttribVal2");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_int.dds");
getWidget(widget, "Attrib3");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds");
getWidget(widget, "AttribVal3");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds");
getWidget(widget, "Attrib4");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_agility.dds");
getWidget(widget, "AttribVal4");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_agility.dds");
getWidget(widget, "Attrib5");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_speed.dds");
getWidget(widget, "AttribVal5");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_speed.dds");
getWidget(widget, "Attrib6");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds");
getWidget(widget, "AttribVal6");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds");
getWidget(widget, "Attrib7");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_personality.dds");
getWidget(widget, "AttribVal7");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_personality.dds");
getWidget(widget, "Attrib8");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_luck.dds");
getWidget(widget, "AttribVal8");
widget->setUserString("ToolTipType", "ImageCaptionText");
widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str);
widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str);
widget->setUserString("ToolTipImage", "k\\attribute_luck.dds");
}

@ -43,20 +43,15 @@ namespace MWGui
void updateSkillArea();
private:
enum ColorStyle
{
CS_Sub,
CS_Normal,
CS_Super
};
void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value);
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateScroller();
void setupToolTips();
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onWindowResize(MyGUI::Window* window);

@ -12,7 +12,6 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
getWidget(textEdit, "TextEdit");
textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
@ -25,16 +24,15 @@ void TextInputDialog::setNextButtonShow(bool shown)
{
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
if (shown)
{
okButton->setCaption("Next");
okButton->setCoord(MyGUI::IntCoord(264 - 18, 60, 42 + 18, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
else
{
okButton->setCaption("OK");
okButton->setCoord(MyGUI::IntCoord(264, 60, 42, 23));
}
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
int okButtonWidth = okButton->getTextSize().width + 24;
okButton->setCoord(306 - okButtonWidth, 60, okButtonWidth, 23);
}
void TextInputDialog::setTextLabel(const std::string &label)

@ -0,0 +1,361 @@
#include "tooltips.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/world.hpp"
#include "../mwbase/environment.hpp"
#include <boost/lexical_cast.hpp>
using namespace MWGui;
using namespace MyGUI;
ToolTips::ToolTips(WindowManager* windowManager) :
Layout("openmw_tooltips.xml")
, mGameMode(true)
, mWindowManager(windowManager)
, mFullHelp(false)
{
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
mDynamicToolTipBox->setVisible(false);
// turn off mouse focus so that getMouseFocusWidget returns the correct widget,
// even if the mouse is over the tooltip
mDynamicToolTipBox->setNeedMouseFocus(false);
mMainWidget->setNeedMouseFocus(false);
}
void ToolTips::onFrame(float frameDuration)
{
/// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox);
mDynamicToolTipBox = mMainWidget->createWidget<Widget>("HUD_Box",
IntCoord(0, 0, mMainWidget->getCoord().width, mMainWidget->getCoord().height),
Align::Stretch, "DynamicToolTipBox");
const IntSize &viewSize = RenderManager::getInstance().getViewSize();
if (!mGameMode)
{
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
if (focus == 0)
{
mDynamicToolTipBox->setVisible(false);
return;
}
IntSize tooltipSize;
std::string type = focus->getUserString("ToolTipType");
std::string text = focus->getUserString("ToolTipText");
ToolTipInfo info;
if (type == "")
{
mDynamicToolTipBox->setVisible(false);
return;
}
else if (type == "Text")
{
info.text = text;
}
else if (type == "CaptionText")
{
std::string caption = focus->getUserString("ToolTipCaption");
info.caption = caption;
info.text = text;
}
else if (type == "ImageCaptionText")
{
std::string caption = focus->getUserString("ToolTipCaption");
std::string image = focus->getUserString("ToolTipImage");
std::string sizeString = focus->getUserString("ToolTipImageSize");
info.text = text;
info.caption = caption;
info.icon = image;
}
tooltipSize = createToolTip(info);
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
// make the tooltip stay completely in the viewport
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
{
tooltipPosition.left = viewSize.width - tooltipSize.width;
}
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
{
tooltipPosition.top = viewSize.height - tooltipSize.height;
}
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
mDynamicToolTipBox->setVisible(true);
}
else
{
if (!mFocusObject.isEmpty())
{
IntSize tooltipSize = getToolTipViaPtr();
// adjust tooltip size to fit its content, position it above the crosshair
/// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind)
setCoord(viewSize.width/2 - (tooltipSize.width)/2.f,
viewSize.height/2 - (tooltipSize.height) - 32,
tooltipSize.width,
tooltipSize.height);
}
else
mDynamicToolTipBox->setVisible(false);
}
}
void ToolTips::enterGameMode()
{
mGameMode = true;
}
void ToolTips::enterGuiMode()
{
mGameMode = false;
}
void ToolTips::setFocusObject(const MWWorld::Ptr& focus)
{
mFocusObject = focus;
}
IntSize ToolTips::getToolTipViaPtr ()
{
// this the maximum width of the tooltip before it starts word-wrapping
setCoord(0, 0, 300, 300);
IntSize tooltipSize;
const MWWorld::Class& object = MWWorld::Class::get (mFocusObject);
if (!object.hasToolTip(mFocusObject))
{
mDynamicToolTipBox->setVisible(false);
}
else
{
mDynamicToolTipBox->setVisible(true);
ToolTipInfo info = object.getToolTipInfo(mFocusObject);
tooltipSize = createToolTip(info);
}
return tooltipSize;
}
void ToolTips::findImageExtension(std::string& image)
{
int len = image.size();
if (len < 4) return;
if (!Ogre::ResourceGroupManager::getSingleton().resourceExists(Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, image))
{
// Change texture extension to .dds
image[len-3] = 'd';
image[len-2] = 'd';
image[len-1] = 's';
}
}
IntSize ToolTips::createToolTip(const ToolTipInfo& info)
{
std::string caption = info.caption;
std::string image = info.icon;
int imageSize = (image != "") ? 32 : 0;
std::string text = info.text;
// remove the first newline (easier this way)
if (text.size() > 0 && text[0] == '\n')
text.erase(0, 1);
const ESM::Enchantment* enchant;
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
if (info.enchant != "")
{
enchant = store.enchants.search(info.enchant);
if (enchant->data.type == ESM::Enchantment::CastOnce)
text += "\n" + store.gameSettings.search("sItemCastOnce")->str;
else if (enchant->data.type == ESM::Enchantment::WhenStrikes)
text += "\n" + store.gameSettings.search("sItemCastWhenStrikes")->str;
else if (enchant->data.type == ESM::Enchantment::WhenUsed)
text += "\n" + store.gameSettings.search("sItemCastWhenUsed")->str;
else if (enchant->data.type == ESM::Enchantment::ConstantEffect)
text += "\n" + store.gameSettings.search("sItemCastConstant")->str;
}
// this the maximum width of the tooltip before it starts word-wrapping
setCoord(0, 0, 300, 300);
const IntPoint padding(8, 8);
const int imageCaptionHPadding = (caption != "" ? 8 : 0);
const int imageCaptionVPadding = (caption != "" ? 4 : 0);
std::string realImage = "icons\\" + image;
findImageExtension(realImage);
EditBox* captionWidget = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption");
captionWidget->setProperty("Static", "true");
captionWidget->setCaption(caption);
IntSize captionSize = captionWidget->getTextSize();
int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);
EditBox* textWidget = mDynamicToolTipBox->createWidget<EditBox>("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText");
textWidget->setProperty("Static", "true");
textWidget->setProperty("MultiLine", "true");
textWidget->setProperty("WordWrap", "true");
textWidget->setCaption(text);
textWidget->setTextAlign(Align::HCenter | Align::Top);
IntSize textSize = textWidget->getTextSize();
captionSize += IntSize(imageSize, 0); // adjust for image
IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
if (info.effects != 0)
{
Widget* effectArea = mDynamicToolTipBox->createWidget<Widget>("",
IntCoord(0, totalSize.height, 300, 300-totalSize.height),
Align::Stretch, "ToolTipEffectArea");
IntCoord coord(0, 6, totalSize.width, 24);
/**
* \todo
* the various potion effects should appear in the tooltip depending if the player
* has enough skill in alchemy to know about the effects of this potion.
*/
Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, Align::Default, "ToolTipEffectsWidget");
effectsWidget->setWindowManager(mWindowManager);
effectsWidget->setEffectList(info.effects);
std::vector<MyGUI::WidgetPtr> effectItems;
effectsWidget->createEffectWidgets(effectItems, effectArea, coord, true, Widgets::MWEffectList::EF_Potion);
totalSize.height += coord.top-6;
totalSize.width = std::max(totalSize.width, coord.width);
}
if (info.enchant != "")
{
Widget* enchantArea = mDynamicToolTipBox->createWidget<Widget>("",
IntCoord(0, totalSize.height, 300, 300-totalSize.height),
Align::Stretch, "ToolTipEnchantArea");
IntCoord coord(0, 6, totalSize.width, 24);
Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget");
enchantWidget->setWindowManager(mWindowManager);
enchantWidget->setEffectList(&enchant->effects);
std::vector<MyGUI::WidgetPtr> enchantEffectItems;
int flag = (enchant->data.type == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0;
enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag);
totalSize.height += coord.top-6;
totalSize.width = std::max(totalSize.width, coord.width);
if (enchant->data.type == ESM::Enchantment::WhenStrikes
|| enchant->data.type == ESM::Enchantment::WhenUsed)
{
/// \todo store the current enchantment charge somewhere
int charge = enchant->data.charge;
const int chargeWidth = 204;
TextBox* chargeText = enchantArea->createWidget<TextBox>("SandText", IntCoord(0, 0, 10, 18), Align::Default, "ToolTipEnchantChargeText");
chargeText->setCaption(store.gameSettings.search("sCharges")->str);
chargeText->setProperty("Static", "true");
const int chargeTextWidth = chargeText->getTextSize().width + 5;
const int chargeAndTextWidth = chargeWidth + chargeTextWidth;
chargeText->setCoord((totalSize.width - chargeAndTextWidth)/2, coord.top+6, chargeTextWidth, 18);
IntCoord chargeCoord;
if (totalSize.width < chargeWidth)
{
totalSize.width = chargeWidth;
chargeCoord = IntCoord(0, coord.top+6, chargeWidth, 18);
}
else
{
chargeCoord = IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18);
}
Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget<Widgets::MWDynamicStat>
("MW_ChargeBar", chargeCoord, Align::Default, "ToolTipEnchantCharge");
chargeWidget->setValue(charge, charge);
totalSize.height += 24;
}
}
captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize,
(captionHeight-captionSize.height)/2,
captionSize.width-imageSize,
captionSize.height);
captionWidget->setPosition (captionWidget->getPosition() + padding);
textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter
if (image != "")
{
ImageBox* imageWidget = mDynamicToolTipBox->createWidget<ImageBox>("ImageBox",
IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize),
Align::Left | Align::Top, "ToolTipImage");
imageWidget->setImageTexture(realImage);
imageWidget->setPosition (imageWidget->getPosition() + padding);
}
totalSize += IntSize(padding.left*2, padding.top*2);
return totalSize;
}
std::string ToolTips::toString(const float value)
{
std::ostringstream stream;
stream << std::setprecision(3) << value;
return stream.str();
}
std::string ToolTips::toString(const int value)
{
std::ostringstream stream;
stream << value;
return stream.str();
}
std::string ToolTips::getValueString(const int value, const std::string& prefix)
{
if (value == 0)
return "";
else
return "\n" + prefix + ": " + toString(value);
}
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
{
if (text == "")
return "";
else
return "\n" + prefix + ": " + text;
}
void ToolTips::toggleFullHelp()
{
mFullHelp = !mFullHelp;
}
bool ToolTips::getFullHelp() const
{
return mFullHelp;
}

@ -0,0 +1,76 @@
#ifndef MWGUI_TOOLTIPS_H
#define MWGUI_TOOLTIPS_H
#include <openengine/gui/layout.hpp>
#include "../mwworld/ptr.hpp"
namespace MWGui
{
class WindowManager;
// Info about tooltip that is supplied by the MWWorld::Class object
struct ToolTipInfo
{
public:
ToolTipInfo() :
effects(0)
{
};
std::string caption;
std::string text;
std::string icon;
// enchantment (for cloth, armor, weapons)
std::string enchant;
// effects (for potions, ingredients)
const ESM::EffectList* effects;
};
class ToolTips : public OEngine::GUI::Layout
{
public:
ToolTips(WindowManager* windowManager);
void onFrame(float frameDuration);
void enterGameMode();
void enterGuiMode();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
void setFocusObject(const MWWorld::Ptr& focus);
static std::string getValueString(const int value, const std::string& prefix);
///< @return "prefix: value" or "" if value is 0
static std::string getMiscString(const std::string& text, const std::string& prefix);
///< @return "prefix: text" or "" if text is empty
static std::string toString(const float value);
static std::string toString(const int value);
private:
MyGUI::Widget* mDynamicToolTipBox;
WindowManager* mWindowManager;
MWWorld::Ptr mFocusObject;
void findImageExtension(std::string& image);
MyGUI::IntSize getToolTipViaPtr ();
///< @return requested tooltip size
MyGUI::IntSize createToolTip(const ToolTipInfo& info);
///< @return requested tooltip size
bool mGameMode;
bool mFullHelp;
};
}
#endif

@ -222,7 +222,7 @@ void MWSpell::setSpellId(const std::string &spellId)
updateWidgets();
}
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord)
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
{
const ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id);
@ -234,9 +234,11 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
{
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
effect->setWindowManager(mWindowManager);
effect->setFlags(flags);
effect->setSpellEffect(*it);
effects.push_back(effect);
coord.top += effect->getHeight();
coord.width = std::max(coord.width, effect->getRequestedWidth());
}
}
@ -264,12 +266,82 @@ MWSpell::~MWSpell()
{
}
/* MWEffectList */
MWEffectList::MWEffectList()
: mWindowManager(nullptr)
, mEffectList(0)
{
}
void MWEffectList::setEffectList(const ESM::EffectList* list)
{
mEffectList = list;
updateWidgets();
}
void MWEffectList::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags)
{
// We don't know the width of all the elements beforehand, so we do it in
// 2 steps: first, create all widgets and check their width
MWSpellEffectPtr effect = nullptr;
std::vector<ESM::ENAMstruct>::const_iterator end = mEffectList->list.end();
int maxwidth = coord.width;
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffectList->list.begin(); it != end; ++it)
{
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
effect->setWindowManager(mWindowManager);
effect->setFlags(flags);
effect->setSpellEffect(*it);
effects.push_back(effect);
if (effect->getRequestedWidth() > maxwidth)
maxwidth = effect->getRequestedWidth();
coord.top += effect->getHeight();
}
// then adjust the size for all widgets
for (std::vector<MyGUI::WidgetPtr>::iterator it = effects.begin(); it != effects.end(); ++it)
{
effect = static_cast<MWSpellEffectPtr>(*it);
bool needcenter = center && (maxwidth > effect->getRequestedWidth());
int diff = maxwidth - effect->getRequestedWidth();
if (needcenter)
{
effect->setCoord(diff/2, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
}
else
{
effect->setCoord(0, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
}
}
// inform the parent about width
coord.width = maxwidth;
}
void MWEffectList::updateWidgets()
{
}
void MWEffectList::initialiseOverride()
{
Base::initialiseOverride();
}
MWEffectList::~MWEffectList()
{
}
/* MWSpellEffect */
MWSpellEffect::MWSpellEffect()
: mWindowManager(nullptr)
, imageWidget(nullptr)
, textWidget(nullptr)
, mRequestedWidth(0)
, mFlags(0)
{
}
@ -290,8 +362,14 @@ void MWSpellEffect::updateWidgets()
{
if (magicEffect)
{
// TODO: Get name of effect from GMST
std::string spellLine = "";
std::string pt = mWindowManager->getGameSettingString("spoint", "");
std::string pts = mWindowManager->getGameSettingString("spoints", "");
std::string to = " " + mWindowManager->getGameSettingString("sTo", "") + " ";
std::string sec = " " + mWindowManager->getGameSettingString("ssecond", "");
std::string secs = " " + mWindowManager->getGameSettingString("sseconds", "");
std::string effectIDStr = effectIDToString(effect.effectID);
std::string spellLine = mWindowManager->getGameSettingString(effectIDStr, "");
if (effect.skill >= 0 && effect.skill < ESM::Skill::Length)
{
spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], "");
@ -310,26 +388,40 @@ void MWSpellEffect::updateWidgets()
};
spellLine += " " + mWindowManager->getGameSettingString(attributes[effect.attribute], "");
}
if (effect.magnMin >= 0 || effect.magnMax >= 0)
if ((effect.magnMin >= 0 || effect.magnMax >= 0) && effectHasMagnitude(effectIDStr))
{
if (effect.magnMin == effect.magnMax)
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " pts";
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts);
else
{
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " to " + boost::lexical_cast<std::string>(effect.magnMin) + " pts";
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + to + boost::lexical_cast<std::string>(effect.magnMax) + " " + pts;
}
}
if (effect.duration >= 0)
// constant effects have no duration and no target
if (!(mFlags & MWEffectList::EF_Constant))
{
spellLine += " for " + boost::lexical_cast<std::string>(effect.duration) + " secs";
if (effect.duration >= 0 && effectHasDuration(effectIDStr))
{
spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(effect.duration) + ((effect.duration == 1) ? sec : secs);
}
// potions have no target
if (!(mFlags & MWEffectList::EF_Potion))
{
std::string on = mWindowManager->getGameSettingString("sonword", "");
if (effect.range == ESM::RT_Self)
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", "");
else if (effect.range == ESM::RT_Touch)
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", "");
else if (effect.range == ESM::RT_Target)
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", "");
}
}
if (effect.range == ESM::RT_Self)
spellLine += " on Self";
else if (effect.range == ESM::RT_Touch)
spellLine += " on Touch";
else if (effect.range == ESM::RT_Target)
spellLine += " on Target";
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(spellLine);
mRequestedWidth = textWidget->getTextSize().width + 24;
}
else
static_cast<MyGUI::TextBox*>(textWidget)->setCaption("");
@ -342,6 +434,249 @@ void MWSpellEffect::updateWidgets()
}
}
std::string MWSpellEffect::effectIDToString(const short effectID)
{
// Map effect ID to GMST name
// http://www.uesp.net/morrow/hints/mweffects.shtml
std::map<short, std::string> names;
names[85] ="sEffectAbsorbAttribute";
names[88] ="sEffectAbsorbFatigue";
names[86] ="sEffectAbsorbHealth";
names[87] ="sEffectAbsorbSpellPoints";
names[89] ="sEffectAbsorbSkill";
names[63] ="sEffectAlmsiviIntervention";
names[47] ="sEffectBlind";
names[123] ="sEffectBoundBattleAxe";
names[129] ="sEffectBoundBoots";
names[127] ="sEffectBoundCuirass";
names[120] ="sEffectBoundDagger";
names[131] ="sEffectBoundGloves";
names[128] ="sEffectBoundHelm";
names[125] ="sEffectBoundLongbow";
names[121] ="sEffectBoundLongsword";
names[122] ="sEffectBoundMace";
names[130] ="sEffectBoundShield";
names[124] ="sEffectBoundSpear";
names[7] ="sEffectBurden";
names[50] ="sEffectCalmCreature";
names[49] ="sEffectCalmHumanoid";
names[40] ="sEffectChameleon";
names[44] ="sEffectCharm";
names[118] ="sEffectCommandCreatures";
names[119] ="sEffectCommandHumanoids";
names[132] ="sEffectCorpus"; // NB this typo. (bethesda made it)
names[70] ="sEffectCureBlightDisease";
names[69] ="sEffectCureCommonDisease";
names[71] ="sEffectCureCorprusDisease";
names[73] ="sEffectCureParalyzation";
names[72] ="sEffectCurePoison";
names[22] ="sEffectDamageAttribute";
names[25] ="sEffectDamageFatigue";
names[23] ="sEffectDamageHealth";
names[24] ="sEffectDamageMagicka";
names[26] ="sEffectDamageSkill";
names[54] ="sEffectDemoralizeCreature";
names[53] ="sEffectDemoralizeHumanoid";
names[64] ="sEffectDetectAnimal";
names[65] ="sEffectDetectEnchantment";
names[66] ="sEffectDetectKey";
names[38] ="sEffectDisintegrateArmor";
names[37] ="sEffectDisintegrateWeapon";
names[57] ="sEffectDispel";
names[62] ="sEffectDivineIntervention";
names[17] ="sEffectDrainAttribute";
names[20] ="sEffectDrainFatigue";
names[18] ="sEffectDrainHealth";
names[19] ="sEffectDrainSpellpoints";
names[21] ="sEffectDrainSkill";
names[8] ="sEffectFeather";
names[14] ="sEffectFireDamage";
names[4] ="sEffectFireShield";
names[117] ="sEffectFortifyAttackBonus";
names[79] ="sEffectFortifyAttribute";
names[82] ="sEffectFortifyFatigue";
names[80] ="sEffectFortifyHealth";
names[81] ="sEffectFortifySpellpoints";
names[84] ="sEffectFortifyMagickaMultiplier";
names[83] ="sEffectFortifySkill";
names[52] ="sEffectFrenzyCreature";
names[51] ="sEffectFrenzyHumanoid";
names[16] ="sEffectFrostDamage";
names[6] ="sEffectFrostShield";
names[39] ="sEffectInvisibility";
names[9] ="sEffectJump";
names[10] ="sEffectLevitate";
names[41] ="sEffectLight";
names[5] ="sEffectLightningShield";
names[12] ="sEffectLock";
names[60] ="sEffectMark";
names[43] ="sEffectNightEye";
names[13] ="sEffectOpen";
names[45] ="sEffectParalyze";
names[27] ="sEffectPoison";
names[56] ="sEffectRallyCreature";
names[55] ="sEffectRallyHumanoid";
names[61] ="sEffectRecall";
names[68] ="sEffectReflect";
names[100] ="sEffectRemoveCurse";
names[95] ="sEffectResistBlightDisease";
names[94] ="sEffectResistCommonDisease";
names[96] ="sEffectResistCorprusDisease";
names[90] ="sEffectResistFire";
names[91] ="sEffectResistFrost";
names[93] ="sEffectResistMagicka";
names[98] ="sEffectResistNormalWeapons";
names[99] ="sEffectResistParalysis";
names[97] ="sEffectResistPoison";
names[92] ="sEffectResistShock";
names[74] ="sEffectRestoreAttribute";
names[77] ="sEffectRestoreFatigue";
names[75] ="sEffectRestoreHealth";
names[76] ="sEffectRestoreSpellPoints";
names[78] ="sEffectRestoreSkill";
names[42] ="sEffectSanctuary";
names[3] ="sEffectShield";
names[15] ="sEffectShockDamage";
names[46] ="sEffectSilence";
names[11] ="sEffectSlowFall";
names[58] ="sEffectSoultrap";
names[48] ="sEffectSound";
names[67] ="sEffectSpellAbsorption";
names[136] ="sEffectStuntedMagicka";
names[106] ="sEffectSummonAncestralGhost";
names[110] ="sEffectSummonBonelord";
names[108] ="sEffectSummonLeastBonewalker";
names[134] ="sEffectSummonCenturionSphere";
names[103] ="sEffectSummonClannfear";
names[104] ="sEffectSummonDaedroth";
names[105] ="sEffectSummonDremora";
names[114] ="sEffectSummonFlameAtronach";
names[115] ="sEffectSummonFrostAtronach";
names[113] ="sEffectSummonGoldenSaint";
names[109] ="sEffectSummonGreaterBonewalker";
names[112] ="sEffectSummonHunger";
names[102] ="sEffectSummonScamp";
names[107] ="sEffectSummonSkeletalMinion";
names[116] ="sEffectSummonStormAtronach";
names[111] ="sEffectSummonWingedTwilight";
names[135] ="sEffectSunDamage";
names[1] ="sEffectSwiftSwim";
names[59] ="sEffectTelekinesis";
names[101] ="sEffectTurnUndead";
names[133] ="sEffectVampirism";
names[0] ="sEffectWaterBreathing";
names[2] ="sEffectWaterWalking";
names[33] ="sEffectWeaknesstoBlightDisease";
names[32] ="sEffectWeaknesstoCommonDisease";
names[34] ="sEffectWeaknesstoCorprusDisease";
names[28] ="sEffectWeaknesstoFire";
names[29] ="sEffectWeaknesstoFrost";
names[31] ="sEffectWeaknesstoMagicka";
names[36] ="sEffectWeaknesstoNormalWeapons";
names[35] ="sEffectWeaknesstoPoison";
names[30] ="sEffectWeaknesstoShock";
// bloodmoon
names[138] ="sEffectSummonCreature01";
names[139] ="sEffectSummonCreature02";
names[140] ="sEffectSummonCreature03";
names[141] ="sEffectSummonCreature04";
names[142] ="sEffectSummonCreature05";
// tribunal
names[137] ="sEffectSummonFabricant";
assert(names.find(effectID) != names.end() && "Unimplemented effect type");
return names[effectID];
}
bool MWSpellEffect::effectHasDuration(const std::string& effect)
{
// lists effects that have no duration (e.g. open lock)
std::vector<std::string> effectsWithoutDuration;
effectsWithoutDuration.push_back("sEffectOpen");
effectsWithoutDuration.push_back("sEffectLock");
effectsWithoutDuration.push_back("sEffectDispel");
effectsWithoutDuration.push_back("sEffectSunDamage");
effectsWithoutDuration.push_back("sEffectCorpus");
effectsWithoutDuration.push_back("sEffectVampirism");
effectsWithoutDuration.push_back("sEffectMark");
effectsWithoutDuration.push_back("sEffectRecall");
effectsWithoutDuration.push_back("sEffectDivineIntervention");
effectsWithoutDuration.push_back("sEffectAlmsiviIntervention");
effectsWithoutDuration.push_back("sEffectCureCommonDisease");
effectsWithoutDuration.push_back("sEffectCureBlightDisease");
effectsWithoutDuration.push_back("sEffectCureCorprusDisease");
effectsWithoutDuration.push_back("sEffectCurePoison");
effectsWithoutDuration.push_back("sEffectCureParalyzation");
effectsWithoutDuration.push_back("sEffectRemoveCurse");
effectsWithoutDuration.push_back("sEffectRestoreAttribute");
return (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effect) == effectsWithoutDuration.end());
}
bool MWSpellEffect::effectHasMagnitude(const std::string& effect)
{
// lists effects that have no magnitude (e.g. invisiblity)
std::vector<std::string> effectsWithoutMagnitude;
effectsWithoutMagnitude.push_back("sEffectInvisibility");
effectsWithoutMagnitude.push_back("sEffectStuntedMagicka");
effectsWithoutMagnitude.push_back("sEffectParalyze");
effectsWithoutMagnitude.push_back("sEffectSoultrap");
effectsWithoutMagnitude.push_back("sEffectSilence");
effectsWithoutMagnitude.push_back("sEffectParalyze");
effectsWithoutMagnitude.push_back("sEffectInvisibility");
effectsWithoutMagnitude.push_back("sEffectWaterWalking");
effectsWithoutMagnitude.push_back("sEffectWaterBreathing");
effectsWithoutMagnitude.push_back("sEffectSummonScamp");
effectsWithoutMagnitude.push_back("sEffectSummonClannfear");
effectsWithoutMagnitude.push_back("sEffectSummonDaedroth");
effectsWithoutMagnitude.push_back("sEffectSummonDremora");
effectsWithoutMagnitude.push_back("sEffectSummonAncestralGhost");
effectsWithoutMagnitude.push_back("sEffectSummonSkeletalMinion");
effectsWithoutMagnitude.push_back("sEffectSummonBonewalker");
effectsWithoutMagnitude.push_back("sEffectSummonGreaterBonewalker");
effectsWithoutMagnitude.push_back("sEffectSummonBonelord");
effectsWithoutMagnitude.push_back("sEffectSummonWingedTwilight");
effectsWithoutMagnitude.push_back("sEffectSummonHunger");
effectsWithoutMagnitude.push_back("sEffectSummonGoldenSaint");
effectsWithoutMagnitude.push_back("sEffectSummonFlameAtronach");
effectsWithoutMagnitude.push_back("sEffectSummonFrostAtronach");
effectsWithoutMagnitude.push_back("sEffectSummonStormAtronach");
effectsWithoutMagnitude.push_back("sEffectSummonCenturionSphere");
effectsWithoutMagnitude.push_back("sEffectBoundDagger");
effectsWithoutMagnitude.push_back("sEffectBoundLongsword");
effectsWithoutMagnitude.push_back("sEffectBoundMace");
effectsWithoutMagnitude.push_back("sEffectBoundBattleAxe");
effectsWithoutMagnitude.push_back("sEffectBoundSpear");
effectsWithoutMagnitude.push_back("sEffectBoundLongbow");
effectsWithoutMagnitude.push_back("sEffectBoundCuirass");
effectsWithoutMagnitude.push_back("sEffectBoundHelm");
effectsWithoutMagnitude.push_back("sEffectBoundBoots");
effectsWithoutMagnitude.push_back("sEffectBoundShield");
effectsWithoutMagnitude.push_back("sEffectBoundGloves");
effectsWithoutMagnitude.push_back("sEffectStuntedMagicka");
effectsWithoutMagnitude.push_back("sEffectMark");
effectsWithoutMagnitude.push_back("sEffectRecall");
effectsWithoutMagnitude.push_back("sEffectDivineIntervention");
effectsWithoutMagnitude.push_back("sEffectAlmsiviIntervention");
effectsWithoutMagnitude.push_back("sEffectCureCommonDisease");
effectsWithoutMagnitude.push_back("sEffectCureBlightDisease");
effectsWithoutMagnitude.push_back("sEffectCureCorprusDisease");
effectsWithoutMagnitude.push_back("sEffectCurePoison");
effectsWithoutMagnitude.push_back("sEffectCureParalyzation");
effectsWithoutMagnitude.push_back("sEffectRemoveCurse");
effectsWithoutMagnitude.push_back("sEffectSummonCreature01");
effectsWithoutMagnitude.push_back("sEffectSummonCreature02");
effectsWithoutMagnitude.push_back("sEffectSummonCreature03");
effectsWithoutMagnitude.push_back("sEffectSummonCreature04");
effectsWithoutMagnitude.push_back("sEffectSummonCreature05");
effectsWithoutMagnitude.push_back("sEffectSummonFabricant");
return (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effect) == effectsWithoutMagnitude.end());
}
MWSpellEffect::~MWSpellEffect()
{
}

@ -119,14 +119,22 @@ namespace MWGui
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellId(const std::string &id);
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord);
/**
* @param vector to store the created effect widgets
* @param parent widget
* @param coordinates to use, will be expanded if more space is needed
* @param spell category, if this is 0, this means the spell effects are permanent and won't display e.g. duration
* @param various flags, see MWEffectList::EffectFlags
*/
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags);
const std::string &getSpellId() const { return id; }
protected:
virtual ~MWSpell();
virtual void initialiseOverride();
virtual void initialiseOverride();
private:
void updateWidgets();
@ -137,6 +145,45 @@ namespace MWGui
};
typedef MWSpell* MWSpellPtr;
class MYGUI_EXPORT MWEffectList : public Widget
{
MYGUI_RTTI_DERIVED( MWEffectList );
public:
MWEffectList();
typedef MWMechanics::Stat<int> EnchantmentValue;
enum EffectFlags
{
EF_Potion = 0x01, // potions have no target (target is always the player)
EF_Constant = 0x02 // constant effect means that duration will not be displayed
};
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setEffectList(const ESM::EffectList* list);
/**
* @param vector to store the created effect widgets
* @param parent widget
* @param coordinates to use, will be expanded if more space is needed
* @param center the effect widgets horizontally
* @param various flags, see MWEffectList::EffectFlags
*/
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags);
protected:
virtual ~MWEffectList();
virtual void initialiseOverride();
private:
void updateWidgets();
WindowManager* mWindowManager;
const ESM::EffectList* mEffectList;
};
typedef MWEffectList* MWEffectListPtr;
class MYGUI_EXPORT MWSpellEffect : public Widget
{
MYGUI_RTTI_DERIVED( MWSpellEffect );
@ -147,9 +194,16 @@ namespace MWGui
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellEffect(SpellEffectValue value);
void setFlags(int flags) { mFlags = flags; }
std::string effectIDToString(const short effectID);
bool effectHasMagnitude (const std::string& effect);
bool effectHasDuration (const std::string& effect);
const SpellEffectValue &getSpellEffect() const { return effect; }
int getRequestedWidth() const { return mRequestedWidth; }
protected:
virtual ~MWSpellEffect();
@ -161,8 +215,10 @@ namespace MWGui
WindowManager* mWindowManager;
SpellEffectValue effect;
int mFlags;
MyGUI::ImageBox* imageWidget;
MyGUI::TextBox* textWidget;
int mRequestedWidth;
};
typedef MWSpellEffect* MWSpellEffectPtr;

@ -10,10 +10,13 @@
#include "container.hpp"
#include "inventorywindow.hpp"
#include "itemwidget.hpp"
#include "tooltips.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwbase/environment.hpp"
#include "console.hpp"
#include "journalwindow.hpp"
#include "charactercreation.hpp"
@ -26,14 +29,14 @@
using namespace MWGui;
WindowManager::WindowManager(MWWorld::Environment& environment,
WindowManager::WindowManager(
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath)
: mGuiManager(NULL)
, environment(environment)
, hud(NULL)
, map(NULL)
, menu(NULL)
, stats(NULL)
, mToolTips(NULL)
, mMessageBoxManager(NULL)
, console(NULL)
, mJournal(NULL)
@ -89,17 +92,18 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
menu = new MainMenu(w,h);
map = new MapWindow(*this);
stats = new StatsWindow(*this);
console = new Console(w,h, environment, extensions);
console = new Console(w,h, extensions);
mJournal = new JournalWindow(*this);
mMessageBoxManager = new MessageBoxManager(this);
mDialogueWindow = new DialogueWindow(*this,environment);
mContainerWindow = new ContainerWindow(*this,environment,mDragAndDrop);
mInventoryWindow = new InventoryWindow(*this,environment,mDragAndDrop);
mToolTips = new ToolTips(this);
// The HUD is always on
hud->setVisible(true);
mCharGen = new CharacterCreation(this, &environment);
mCharGen = new CharacterCreation(this);
// Setup player stats
for (int i = 0; i < ESM::Attribute::Length; ++i)
@ -115,6 +119,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWEffectList>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("Widget");
@ -135,6 +140,7 @@ WindowManager::~WindowManager()
delete mDialogueWindow;
delete mContainerWindow;
delete mInventoryWindow;
delete mToolTips;
delete mCharGen;
delete mDragAndDrop;
@ -160,7 +166,7 @@ void WindowManager::update()
if (needModeChange)
{
needModeChange = false;
environment.mInputManager->setGuiMode(nextMode);
MWBase::Environment::get().getInputManager()->setGuiMode(nextMode);
nextMode = GM_Game;
}
if (showFPSLevel > 0)
@ -171,11 +177,6 @@ void WindowManager::update()
}
}
MWWorld::Environment& WindowManager::getEnvironment()
{
return environment;
}
void WindowManager::setNextMode(GuiMode newMode)
{
nextMode = newMode;
@ -184,7 +185,7 @@ void WindowManager::setNextMode(GuiMode newMode)
void WindowManager::setGuiMode(GuiMode newMode)
{
environment.mInputManager->setGuiMode(newMode);
MWBase::Environment::get().getInputManager()->setGuiMode(newMode);
}
void WindowManager::updateVisible()
@ -202,6 +203,11 @@ void WindowManager::updateVisible()
// Mouse is visible whenever we're not in game mode
MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
if (mode == GM_Game)
mToolTips->enterGameMode();
else
mToolTips->enterGuiMode();
switch(mode) {
case GM_Game:
// If in game mode, don't show anything.
@ -414,7 +420,7 @@ int WindowManager::readPressedButton ()
const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
{
const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id);
const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id);
if (setting && setting->type == ESM::VT_String)
return setting->str;
return default_;
@ -436,11 +442,12 @@ void WindowManager::onFrame (float frameDuration)
mMessageBoxManager->onFrame(frameDuration);
mInventoryWindow->Update();
mContainerWindow->Update();
mToolTips->onFrame(frameDuration);
}
const ESMS::ESMStore& WindowManager::getStore() const
{
return environment.mWorld->getStore();
return MWBase::Environment::get().getWorld()->getStore();
}
void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
@ -451,7 +458,10 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
if (cell->cell->name != "")
name = cell->cell->name;
else
name = cell->cell->region;
{
const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region);
name = region->name;
}
map->setCellName( name );
@ -510,3 +520,18 @@ int WindowManager::toggleFps()
Settings::Manager::setInt("fps", "HUD", showFPSLevel);
return showFPSLevel;
}
void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
{
mToolTips->setFocusObject(focus);
}
void WindowManager::toggleFullHelp()
{
mToolTips->toggleFullHelp();
}
bool WindowManager::getFullHelp() const
{
return mToolTips->getFullHelp();
}

@ -34,7 +34,6 @@ namespace Compiler
namespace MWWorld
{
class Environment;
class World;
}
@ -65,6 +64,7 @@ namespace MWGui
class ContainerWindow;
class DragAndDrop;
class InventoryWindow;
class ToolTips;
class TextInputDialog;
class InfoBoxDialog;
class DialogueWindow;
@ -85,7 +85,7 @@ namespace MWGui
typedef std::vector<Faction> FactionList;
typedef std::vector<int> SkillList;
WindowManager(MWWorld::Environment& environment, 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);
virtual ~WindowManager();
void setGuiMode(GuiMode newMode);
@ -97,8 +97,6 @@ namespace MWGui
*/
void update();
MWWorld::Environment& getEnvironment();
void setMode(GuiMode newMode)
{
if (newMode==GM_Inventory && allowed==GW_None)
@ -161,7 +159,11 @@ namespace MWGui
void setPlayerPos(const float x, const float y); ///< set player position in map space
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
void setFocusObject(const MWWorld::Ptr& focus);
void toggleFogOfWar();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
int toggleFps();
///< toggle fps display @return resulting fps level
@ -196,10 +198,10 @@ namespace MWGui
private:
OEngine::GUI::MyGUIManager *mGuiManager;
MWWorld::Environment& environment;
HUD *hud;
MapWindow *map;
MainMenu *menu;
ToolTips *mToolTips;
StatsWindow *stats;
MessageBoxManager *mMessageBoxManager;
Console *console;

@ -60,6 +60,7 @@ namespace MWInput
A_CycleWeaponRight,
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
A_ToggleWalk, //Toggle Walking/Running
A_Crouch,
A_QuickSave,
A_QuickLoad,
@ -97,34 +98,36 @@ namespace MWInput
void toggleSpell()
{
DrawState state = player.getDrawState();
if(state == DrawState_Weapon || state == DrawState_Nothing)
{
player.setDrawState(DrawState_Spell);
std::cout << "Player has now readied his hands for spellcasting!\n";
}
else
{
player.setDrawState(DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n";
}
if (windows.isGuiMode()) return;
DrawState state = player.getDrawState();
if (state == DrawState_Weapon || state == DrawState_Nothing)
{
player.setDrawState(DrawState_Spell);
std::cout << "Player has now readied his hands for spellcasting!\n";
}
else
{
player.setDrawState(DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n";
}
}
void toggleWeapon()
{
DrawState state = player.getDrawState();
if(state == DrawState_Spell || state == DrawState_Nothing)
{
player.setDrawState(DrawState_Weapon);
std::cout << "Player is now drawing his weapon.\n";
}
else
{
player.setDrawState(DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n";
}
if (windows.isGuiMode()) return;
DrawState state = player.getDrawState();
if (state == DrawState_Spell || state == DrawState_Nothing)
{
player.setDrawState(DrawState_Weapon);
std::cout << "Player is now drawing his weapon.\n";
}
else
{
player.setDrawState(DrawState_Nothing);
std::cout << "Player does not have any kind of attack ready now.\n";
}
}
void screenshot()
@ -184,11 +187,13 @@ namespace MWInput
void toggleAutoMove()
{
if (windows.isGuiMode()) return;
player.setAutoMove (!player.getAutoMove());
}
void toggleWalking()
{
if (windows.isGuiMode()) return;
player.toggleRunning();
}
@ -306,6 +311,9 @@ namespace MWInput
poller.bind(A_MoveRight, KC_D);
poller.bind(A_MoveForward, KC_W);
poller.bind(A_MoveBackward, KC_S);
poller.bind(A_Jump, KC_E);
poller.bind(A_Crouch, KC_LCONTROL);
}
//NOTE: Used to check for movement keys
@ -352,6 +360,13 @@ namespace MWInput
}
else
player.setForwardBackward (0);
if (poller.isDown(A_Jump))
player.setUpDown (1);
else if (poller.isDown(A_Crouch))
player.setUpDown (-1);
else
player.setUpDown (0);
}
// Switch between gui modes. Besides controlling the Gui windows

@ -19,10 +19,10 @@ namespace MWMechanics
{
if (!paused && ptr.getRefData().getHandle()!="player")
MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip (
MWWorld::Class::get (ptr).getNpcStats (ptr), mEnvironment);
MWWorld::Class::get (ptr).getNpcStats (ptr));
}
Actors::Actors (MWWorld::Environment& environment) : mEnvironment (environment), mDuration (0) {}
Actors::Actors() : mDuration (0) {}
void Actors::addActor (const MWWorld::Ptr& ptr)
{

@ -12,16 +12,10 @@ namespace Ogre
class Vector3;
}
namespace MWWorld
{
class Environment;
}
namespace MWMechanics
{
class Actors
{
MWWorld::Environment& mEnvironment;
std::set<MWWorld::Ptr> mActors;
float mDuration;
@ -31,7 +25,7 @@ namespace MWMechanics
public:
Actors (MWWorld::Environment& environment);
Actors();
void addActor (const MWWorld::Ptr& ptr);
///< Register an actor for stats management

@ -5,8 +5,9 @@
#include "../mwgui/window_manager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/player.hpp"
@ -14,7 +15,7 @@ namespace MWMechanics
{
void MechanicsManager::buildPlayer()
{
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer();
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
@ -33,10 +34,10 @@ namespace MWMechanics
if (mRaceSelected)
{
const ESM::Race *race =
mEnvironment.mWorld->getStore().races.find (
mEnvironment.mWorld->getPlayer().getRace());
MWBase::Environment::get().getWorld()->getStore().races.find (
MWBase::Environment::get().getWorld()->getPlayer().getRace());
bool male = mEnvironment.mWorld->getPlayer().isMale();
bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale();
for (int i=0; i<8; ++i)
{
@ -76,11 +77,11 @@ namespace MWMechanics
}
// birthsign
if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty())
if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty())
{
const ESM::BirthSign *sign =
mEnvironment.mWorld->getStore().birthSigns.find (
mEnvironment.mWorld->getPlayer().getBirthsign());
MWBase::Environment::get().getWorld()->getStore().birthSigns.find (
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
iter!=sign->powers.list.end(); ++iter)
@ -92,7 +93,7 @@ namespace MWMechanics
// class
if (mClassSelected)
{
const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass();
const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass();
for (int i=0; i<2; ++i)
{
@ -121,7 +122,7 @@ namespace MWMechanics
}
typedef ESMS::IndexListT<ESM::Skill>::MapType ContainerType;
const ContainerType& skills = mEnvironment.mWorld->getStore().skills.list;
const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list;
for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
{
@ -164,7 +165,7 @@ namespace MWMechanics
MWMechanics::CreatureStats& creatureStats =
MWWorld::Class::get (creature).getCreatureStats (creature);
MagicEffects now = creatureStats.mSpells.getMagicEffects (mEnvironment);
MagicEffects now = creatureStats.mSpells.getMagicEffects();
/// \todo add effects from active spells and equipment
@ -175,9 +176,9 @@ namespace MWMechanics
// TODO apply diff to other stats
}
MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
: mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false),
mRaceSelected (false), mActors (environment)
MechanicsManager::MechanicsManager()
: mUpdatePlayer (true), mClassSelected (false),
mRaceSelected (false)
{
buildPlayer();
}
@ -236,7 +237,7 @@ namespace MWMechanics
{
mWatchedCreature.mAttributes[i] = stats.mAttributes[i];
mEnvironment.mWindowManager->setValue (attributeNames[i], stats.mAttributes[i]);
MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.mAttributes[i]);
}
}
@ -246,7 +247,7 @@ namespace MWMechanics
{
mWatchedCreature.mDynamic[i] = stats.mDynamic[i];
mEnvironment.mWindowManager->setValue (dynamicNames[i], stats.mDynamic[i]);
MWBase::Environment::get().getWindowManager()->setValue (dynamicNames[i], stats.mDynamic[i]);
}
}
@ -259,25 +260,25 @@ namespace MWMechanics
{
update = true;
mWatchedNpc.mSkill[i] = npcStats.mSkill[i];
mEnvironment.mWindowManager->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]);
MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]);
}
}
if (update)
mEnvironment.mWindowManager->updateSkillArea();
MWBase::Environment::get().getWindowManager()->updateSkillArea();
mEnvironment.mWindowManager->setValue ("level", stats.mLevel);
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.mLevel);
}
if (mUpdatePlayer)
{
// basic player profile; should not change anymore after the creation phase is finished.
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName());
mEnvironment.mWindowManager->setValue ("race",
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer().
MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName());
MWBase::Environment::get().getWindowManager()->setValue ("race",
MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer().
getRace())->name);
mEnvironment.mWindowManager->setValue ("class",
mEnvironment.mWorld->getPlayer().getClass().name);
MWBase::Environment::get().getWindowManager()->setValue ("class",
MWBase::Environment::get().getWorld()->getPlayer().getClass().name);
mUpdatePlayer = false;
MWGui::WindowManager::SkillList majorSkills (5);
@ -285,11 +286,11 @@ namespace MWMechanics
for (int i=0; i<5; ++i)
{
minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0];
majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1];
minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][0];
majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][1];
}
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills);
}
mActors.update (movement, duration, paused);
@ -297,14 +298,14 @@ namespace MWMechanics
void MechanicsManager::setPlayerName (const std::string& name)
{
mEnvironment.mWorld->getPlayer().setName (name);
MWBase::Environment::get().getWorld()->getPlayer().setName (name);
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
{
mEnvironment.mWorld->getPlayer().setGender (male);
mEnvironment.mWorld->getPlayer().setRace (race);
MWBase::Environment::get().getWorld()->getPlayer().setGender (male);
MWBase::Environment::get().getWorld()->getPlayer().setRace (race);
mRaceSelected = true;
buildPlayer();
mUpdatePlayer = true;
@ -312,14 +313,14 @@ namespace MWMechanics
void MechanicsManager::setPlayerBirthsign (const std::string& id)
{
mEnvironment.mWorld->getPlayer().setBirthsign (id);
MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id);
buildPlayer();
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerClass (const std::string& id)
{
mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id));
mClassSelected = true;
buildPlayer();
mUpdatePlayer = true;
@ -327,7 +328,7 @@ namespace MWMechanics
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
{
mEnvironment.mWorld->getPlayer().setClass (class_);
MWBase::Environment::get().getWorld()->getPlayer().setClass (class_);
mClassSelected = true;
buildPlayer();
mUpdatePlayer = true;

@ -15,16 +15,10 @@ namespace Ogre
class Vector3;
}
namespace MWWorld
{
class Environment;
}
namespace MWMechanics
{
class MechanicsManager
{
MWWorld::Environment& mEnvironment;
MWWorld::Ptr mWatched;
CreatureStats mWatchedCreature;
NpcStats mWatchedNpc;
@ -41,7 +35,7 @@ namespace MWMechanics
public:
MechanicsManager (MWWorld::Environment& environment);
MechanicsManager ();
void configureGUI();

@ -8,8 +8,9 @@ namespace MWMechanics
{
signed char mLeftRight; // 1: wants to move left, -1: wants to move right
signed char mForwardBackward; // 1:wants to move forward, -1: wants to move backward
signed char mUpDown;
Movement() : mLeftRight (0), mForwardBackward (0) {}
Movement() : mLeftRight (0), mForwardBackward (0), mUpDown(0) {}
};
}

@ -3,7 +3,8 @@
#include <components/esm/loadspel.hpp>
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "magiceffects.hpp"
@ -48,13 +49,13 @@ namespace MWMechanics
mSelectedSpell.clear();
}
MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const
MagicEffects Spells::getMagicEffects() const
{
MagicEffects effects;
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{
const ESM::Spell *spell = environment.mWorld->getStore().spells.find (*iter);
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter);
if (spell->data.type==ESM::Spell::ST_Ability || spell->data.type==ESM::Spell::ST_Blight ||
spell->data.type==ESM::Spell::ST_Disease || spell->data.type==ESM::Spell::ST_Curse)

@ -9,11 +9,6 @@ namespace ESM
struct Spell;
}
namespace MWWorld
{
struct Environment;
}
namespace MWMechanics
{
class MagicEffects;
@ -49,7 +44,7 @@ namespace MWMechanics
///< If the spell to be removed is the selected spell, the selected spell will be changed to
/// no spell (empty string).
MagicEffects getMagicEffects (const MWWorld::Environment& environment) const;
MagicEffects getMagicEffects() const;
///< Return sum of magic effects resulting from abilities, blights, deseases and curses.
void clear();

@ -20,12 +20,12 @@ Actors::~Actors(){
void Actors::setMwRoot(Ogre::SceneNode* root){
mMwRoot = root;
}
void Actors::insertNPC(const MWWorld::Ptr& ptr){
void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){
insertBegin(ptr, true, true);
NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend);
insertBegin(ptr, true, true);
NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mRend, inv);
mAllActors[ptr] = anim;
mAllActors[ptr] = anim;
}
void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
Ogre::SceneNode* cellnode;
@ -68,7 +68,7 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
void Actors::insertCreature (const MWWorld::Ptr& ptr){
insertBegin(ptr, true, true);
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend);
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mRend);
//mAllActors.insert(std::pair<MWWorld::Ptr, Animation*>(ptr,anim));
delete mAllActors[ptr];
mAllActors[ptr] = anim;

@ -13,7 +13,6 @@
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
#include "../mwworld/environment.hpp"
#include "npcanimation.hpp"
#include "creatureanimation.hpp"
#include <openengine/bullet/physic.hpp>
@ -23,18 +22,17 @@ namespace MWRender{
OEngine::Render::OgreRenderer &mRend;
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
Ogre::SceneNode* mMwRoot;
MWWorld::Environment& mEnvironment;
std::map<MWWorld::Ptr, Animation*> mAllActors;
public:
Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){}
Actors(OEngine::Render::OgreRenderer& _rend): mRend(_rend) {}
~Actors();
void setMwRoot(Ogre::SceneNode* root);
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertCreature (const MWWorld::Ptr& ptr);
void insertNPC(const MWWorld::Ptr& ptr);
void insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv);
bool deleteObject (const MWWorld::Ptr& ptr);
///< \return found?

@ -4,12 +4,10 @@
namespace MWRender{
std::map<std::string, int> Animation::mUniqueIDs;
Animation::Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend)
Animation::Animation(OEngine::Render::OgreRenderer& _rend)
: insert(NULL)
, mRend(_rend)
, mEnvironment(_env)
, vecRotPos()
, shapeparts()
, time(0.0f)
, startTime(0.0f)
, stopTime(0.0f)
@ -19,7 +17,6 @@ namespace MWRender{
, shapeNumber(0)
, shapeIndexI()
, shapes(NULL)
, entityparts()
, transformations(NULL)
, textmappings(NULL)
, base(NULL)
@ -305,8 +302,8 @@ namespace MWRender{
for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++)
{
if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){
Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(*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();
@ -430,14 +427,7 @@ namespace MWRender{
//base->_updateAnimation();
//base->_notifyMoved();
for(unsigned int i = 0; i < entityparts.size(); i++){
//Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
//Ogre::Bone* b = skel->getRootBone();
//b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
//entityparts[i]->getAllAnimationStates()->_notifyDirty();
}
std::vector<Nif::NiKeyframeData>::iterator iter;

@ -5,7 +5,6 @@
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
#include "../mwworld/environment.hpp"
#include <components/nif/node.hpp>
#include <map>
#include <openengine/bullet/physic.hpp>
@ -21,17 +20,16 @@ struct PosAndRot{
};
class Animation{
protected:
Ogre::SceneNode* insert;
OEngine::Render::OgreRenderer &mRend;
MWWorld::Environment& mEnvironment;
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot> vecRotPos;
static std::map<std::string, int> mUniqueIDs;
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating an npc
float time;
float startTime;
@ -41,14 +39,14 @@ class Animation{
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<Ogre::Entity*> entityparts;
std::vector<Nif::NiKeyframeData>* transformations;
@ -58,16 +56,16 @@ class Animation{
void handleAnimationTransforms();
bool timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x );
std::string getUniqueID(std::string mesh);
public:
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
Animation(OEngine::Render::OgreRenderer& _rend);
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();
virtual ~Animation();
};
}
#endif

@ -10,7 +10,7 @@ namespace MWRender{
CreatureAnimation::~CreatureAnimation(){
}
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){
insert = ptr.getRefData().getBaseNode();
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();

@ -7,20 +7,19 @@
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/environment.hpp"
#include "components/nifogre/ogre_nif_loader.hpp"
namespace MWRender{
class CreatureAnimation: public Animation{
public:
virtual ~CreatureAnimation();
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend);
virtual void runAnimation(float timepassed);
};
}
#endif
#endif

@ -8,7 +8,7 @@
#include <OgreMaterialManager.h>
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include <components/esm/loadstat.hpp>
#include <components/esm/loadpgrd.hpp>
@ -138,8 +138,8 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
return result;
}
Debugging::Debugging(SceneNode *mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine) :
mMwRoot(mwRoot), mEnvironment(env), mEngine(engine),
Debugging::Debugging(SceneNode *mwRoot, OEngine::Physic::PhysicEngine *engine) :
mMwRoot(mwRoot), mEngine(engine),
mSceneMgr(mwRoot->getCreator()),
mPathgridEnabled(false),
mInteriorPathgridNode(NULL), mPathGridRoot(NULL),
@ -218,7 +218,7 @@ void Debugging::togglePathgrid()
void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store)
{
ESM::Pathgrid *pathgrid = mEnvironment.mWorld->getStore().pathgrids.search(*store->cell);
ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell);
if (!pathgrid) return;
Vector3 cellPathGridPos(0, 0, 0);

@ -23,7 +23,6 @@ namespace Ogre
namespace MWWorld
{
class World;
class Environment;
}
namespace MWRender
@ -34,7 +33,6 @@ namespace MWRender
{
OEngine::Physic::PhysicEngine* mEngine;
Ogre::SceneManager *mSceneMgr;
MWWorld::Environment& mEnvironment;
// Path grid stuff
bool mPathgridEnabled;
@ -68,7 +66,7 @@ namespace MWRender
Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid);
Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid);
public:
Debugging(Ogre::SceneNode* mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine);
Debugging(Ogre::SceneNode* mwRoot, OEngine::Physic::PhysicEngine *engine);
~Debugging();
bool toggleRenderMode (int mode);

@ -1,7 +1,7 @@
#include "localmap.hpp"
#include "renderingmanager.hpp"
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "renderconst.hpp"
@ -12,12 +12,11 @@
using namespace MWRender;
using namespace Ogre;
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering, MWWorld::Environment* env) :
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) :
mInterior(false), mCellX(0), mCellY(0)
{
mRendering = rend;
mRenderingManager = rendering;
mEnvironment = env;
mCameraPosNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode();
mCameraRotNode = mCameraPosNode->createChildSceneNode();
@ -54,12 +53,12 @@ void LocalMap::saveTexture(const std::string& texname, const std::string& filena
if (tex.isNull()) return;
HardwarePixelBufferSharedPtr readbuffer = tex->getBuffer();
readbuffer->lock(HardwareBuffer::HBL_NORMAL );
const PixelBox &readrefpb = readbuffer->getCurrentLock();
uchar *readrefdata = static_cast<uchar*>(readrefpb.data);
const PixelBox &readrefpb = readbuffer->getCurrentLock();
uchar *readrefdata = static_cast<uchar*>(readrefpb.data);
Image img;
img = img.loadDynamicImage (readrefdata, tex->getWidth(),
tex->getHeight(), tex->getFormat());
tex->getHeight(), tex->getFormat());
img.save("./" + filename);
readbuffer->unlock();
@ -82,7 +81,7 @@ void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell)
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
Vector2 length = max-min;
// divide into segments
const int segsX = std::ceil( length.x / sSize );
const int segsY = std::ceil( length.y / sSize );
@ -123,7 +122,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
Vector2 z(mBounds.getMaximum().y, mBounds.getMinimum().y);
const Vector2& north = mEnvironment->mWorld->getNorthVector(cell);
const Vector2& north = MWBase::Environment::get().getWorld()->getNorthVector(cell);
Radian angle(std::atan2(-north.x, -north.y));
mAngle = angle.valueRadians();
mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0));
@ -213,7 +212,7 @@ void LocalMap::render(const float x, const float y,
texture,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
xw*sMapResolution/sSize, yw*sMapResolution/sSize,
xw*sMapResolution/sSize, yw*sMapResolution/sSize,
0,
PF_R8G8B8,
TU_RENDERTARGET);
@ -236,7 +235,7 @@ void LocalMap::render(const float x, const float y,
texture + "_fog",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize,
xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize,
0,
PF_A8R8G8B8,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
@ -276,7 +275,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
return;
}
// retrieve the x,y grid coordinates the player is in
// retrieve the x,y grid coordinates the player is in
int x,y;
Vector3 _pos(position.x, 0, position.z);
Vector2 pos(_pos.x, _pos.z);
@ -303,7 +302,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
x = std::ceil((pos.x - min.x)/sSize)-1;
y = std::ceil((pos.y - min.y)/sSize)-1;
mEnvironment->mWindowManager->setInteriorMapTexture(x,y);
MWBase::Environment::get().getWindowManager()->setInteriorMapTexture(x,y);
}
// convert from world coordinates to texture UV coordinates
@ -323,8 +322,8 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
texName = mInteriorName + "_" + coordStr(x,y);
}
mEnvironment->mWindowManager->setPlayerPos(u, v);
mEnvironment->mWindowManager->setPlayerDir(playerdirection.x, -playerdirection.z);
MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v);
MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, -playerdirection.z);
// explore radius (squared)
const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;

@ -5,11 +5,6 @@
#include <openengine/ogre/renderer.hpp>
namespace MWWorld
{
class Environment;
}
namespace MWRender
{
class RenderingManager;
@ -20,7 +15,7 @@ namespace MWRender
class LocalMap
{
public:
LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering, MWWorld::Environment* env);
LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering);
~LocalMap();
/**
@ -61,7 +56,6 @@ namespace MWRender
private:
OEngine::Render::OgreRenderer* mRendering;
MWRender::RenderingManager* mRenderingManager;
MWWorld::Environment* mEnvironment;
// 1024*1024 pixels for a cell
static const int sMapResolution = 1024;

@ -2,6 +2,7 @@
#include "../mwworld/world.hpp"
#include "renderconst.hpp"
#include "../mwbase/environment.hpp"
using namespace Ogre;
using namespace NifOgre;
@ -11,9 +12,49 @@ NpcAnimation::~NpcAnimation(){
}
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_rend), mStateID(-1), inv(_inv), timeToChange(0),
robe(inv.end()), helmet(inv.end()), shirt(inv.end()),
cuirass(inv.end()), greaves(inv.end()),
leftpauldron(inv.end()), rightpauldron(inv.end()),
boots(inv.end()),
leftglove(inv.end()), rightglove(inv.end()), skirtiter(inv.end()),
pants(inv.end()),
lclavicle(0),
rclavicle(0),
rupperArm(0),
lupperArm(0),
rUpperLeg(0),
lUpperLeg(0),
lForearm(0),
rForearm(0),
lWrist(0),
rWrist(0),
rKnee(0),
lKnee(0),
neck(0),
rAnkle(0),
lAnkle(0),
groin(0),
lfoot(0),
rfoot(0)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
Ogre::Entity* blank = 0;
std::vector<Nif::NiTriShapeCopy>* blankshape = 0;
zero = std::make_pair(blank, blankshape);
chest = std::make_pair(blank, blankshape);
tail = std::make_pair(blank, blankshape);
lFreeFoot = std::make_pair(blank, blankshape);
rFreeFoot = std::make_pair(blank, blankshape);
rhand = std::make_pair(blank, blankshape);
lhand = std::make_pair(blank, blankshape);
skirt = std::make_pair(blank, blankshape);
for (int init = 0; init < 27; init++){
partslots[init] = -1; //each slot is empty
partpriorities[init] = 0;
}
//Part selection on last character of the file string
// " Tri Chest
@ -35,16 +76,22 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
std::string hairID = ref->base->hair;
std::string headID = ref->base->head;
std::string npcName = ref->base->name;
headModel = "meshes\\" +
MWBase::Environment::get().getWorld()->getStore().bodyParts.find(headID)->model;
hairModel = "meshes\\" +
MWBase::Environment::get().getWorld()->getStore().bodyParts.find(hairID)->model;
npcName = ref->base->name;
//ESMStore::Races r =
const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race);
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().races.find(ref->base->race);
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
bool female = tolower(secondtolast) == 'f';
isFemale = tolower(secondtolast) == 'f';
std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
/*std::cout << "Race: " << ref->base->race ;
if(female){
@ -57,7 +104,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
std::string smodel = "meshes\\base_anim.nif";
if(beast)
if(isBeast)
smodel = "meshes\\base_animkna.nif";
insert = ptr.getRefData().getBaseNode();
@ -66,6 +113,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
NifOgre::NIFLoader::load(smodel);
base = mRend.getScene()->createEntity(smodel);
base->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int i=0; i<base->getNumSubEntities(); ++i)
@ -87,6 +135,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
}
base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones
//stay in the same place when we skipanim, or open a gui window
@ -105,167 +154,412 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
textmappings = NIFLoader::getSingletonPtr()->getTextIndices(smodel);
insert->attachObject(base);
if(female)
if(isFemale)
insert->scale(race->data.height.female, race->data.height.female, race->data.height.female);
else
insert->scale(race->data.height.male, race->data.height.male, race->data.height.male);
std::string headModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(headID)->model;
std::string hairModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
const ESM::BodyPart *chest = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg");
const ESM::BodyPart *groin = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two
const ESM::BodyPart *neck = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck");
const ESM::BodyPart *knee = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee");
const ESM::BodyPart *ankle = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle");
const ESM::BodyPart *foot = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot");
const ESM::BodyPart *feet = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet");
const ESM::BodyPart *tail = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail");
const ESM::BodyPart *wristl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); //We need two
const ESM::BodyPart *forearml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); //We need two
const ESM::BodyPart *handl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); //We need two
const ESM::BodyPart *hair = mEnvironment.mWorld->getStore().bodyParts.search(hairID);
const ESM::BodyPart *head = mEnvironment.mWorld->getStore().bodyParts.search(headID);
if(bodyRaceID == "b_n_argonian_f_")
forearml = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two
if(!handl)
handl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands");
//const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle");
//const ESM::BodyPart* clavicler = claviclel;
const ESM::BodyPart* handr = handl;
const ESM::BodyPart* forearmr = forearml;
const ESM::BodyPart* wristr = wristl;
const ESM::BodyPart* armr = arml;
if(upperleg){
insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg");
insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg");
updateParts();
}
if(foot){
if(bodyRaceID.compare("b_n_khajiit_m_") == 0)
{
feet = foot;
}
else
{
insertBoundedPart("meshes\\" + foot->model, "Right Foot");
insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot");
}
}
if(groin){
insertBoundedPart("meshes\\" + groin->model, "Groin");
}
if(knee)
{
insertBoundedPart("meshes\\" + knee->model + "*|", "Left Knee"); //e
insertBoundedPart("meshes\\" + knee->model, "Right Knee"); //e
}
}
if(ankle){
void NpcAnimation::updateParts(){
insertBoundedPart("meshes\\" + ankle->model + "*|", "Left Ankle"); //Ogre::Quaternion(Ogre::Radian(3.14 / 4), Ogre::Vector3(1, 0, 0)),blank); //1,0,0, blank);
insertBoundedPart("meshes\\" + ankle->model, "Right Ankle");
}
if (armr){
insertBoundedPart("meshes\\" + armr->model, "Right Upper Arm");
bool apparelChanged = false;
//inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){
//A robe was added or removed
removePartGroup(MWWorld::InventoryStore::Slot_Robe);
robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
apparelChanged = true;
}
if(arml){
insertBoundedPart("meshes\\" + arml->model + "*|", "Left Upper Arm");
if(skirtiter != inv.getSlot(MWWorld::InventoryStore::Slot_Skirt)){
//A robe was added or removed
removePartGroup(MWWorld::InventoryStore::Slot_Skirt);
skirtiter = inv.getSlot(MWWorld::InventoryStore::Slot_Skirt);
apparelChanged = true;
}
if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){
apparelChanged = true;
helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet);
removePartGroup(MWWorld::InventoryStore::Slot_Helmet);
if (forearmr)
{
insertBoundedPart("meshes\\" + forearmr->model, "Right Forearm");
}
if(forearml)
insertBoundedPart("meshes\\" + forearml->model + "*|", "Left Forearm");
}
if(cuirass != inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)){
cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass);
removePartGroup(MWWorld::InventoryStore::Slot_Cuirass);
apparelChanged = true;
if (wristr)
{
insertBoundedPart("meshes\\" + wristr->model, "Right Wrist");
}
}
if(greaves != inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)){
greaves = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves);
removePartGroup(MWWorld::InventoryStore::Slot_Greaves);
apparelChanged = true;
}
if(leftpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)){
leftpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron);
removePartGroup(MWWorld::InventoryStore::Slot_LeftPauldron);
apparelChanged = true;
if(wristl)
insertBoundedPart("meshes\\" + wristl->model + "*|", "Left Wrist");
}
if(rightpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)){
rightpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron);
removePartGroup(MWWorld::InventoryStore::Slot_RightPauldron);
apparelChanged = true;
}
if(!isBeast && boots != inv.getSlot(MWWorld::InventoryStore::Slot_Boots)){
boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
removePartGroup(MWWorld::InventoryStore::Slot_Boots);
apparelChanged = true;
}
if(leftglove != inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)){
leftglove = inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet);
removePartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet);
apparelChanged = true;
}
if(rightglove != inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)){
rightglove = inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet);
removePartGroup(MWWorld::InventoryStore::Slot_RightGauntlet);
apparelChanged = true;
}
if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){
shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt);
removePartGroup(MWWorld::InventoryStore::Slot_Shirt);
apparelChanged = true;
/*if(claviclel)
insertBoundedPart("meshes\\" + claviclel->model + "*|", "Left Clavicle", base);
if(clavicler)
insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/
}
if(pants != inv.getSlot(MWWorld::InventoryStore::Slot_Pants)){
pants = inv.getSlot(MWWorld::InventoryStore::Slot_Pants);
removePartGroup(MWWorld::InventoryStore::Slot_Pants);
apparelChanged = true;
if(neck)
{
insertBoundedPart("meshes\\" + neck->model, "Neck");
}
if(head)
insertBoundedPart("meshes\\" + head->model, "Head");
if(hair)
insertBoundedPart("meshes\\" + hair->model, "Head");
}
if (chest){
insertFreePart("meshes\\" + chest->model, ">\"", insert);
if(apparelChanged){
if(robe != inv.end())
{
MWWorld::Ptr ptr = *robe;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RUpperarm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LUpperarm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RKnee, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LKnee, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RForearm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LForearm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
}
if(skirtiter != inv.end())
{
MWWorld::Ptr ptr = *skirtiter;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4);
reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
}
}
if (handr){
insertFreePart("meshes\\" + handr->model , ">?", insert);
if(helmet != inv.end()){
removeIndividualPart(ESM::PRT_Hair);
const ESM::Armor *armor = (helmet->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts);
}
if (handl){
insertFreePart("meshes\\" + handl->model, ">>", insert);
}
if(cuirass != inv.end()){
const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts);
}
if(tail){
insertFreePart("meshes\\" + tail->model, ">*", insert);
}
if(feet){
std::string num = getUniqueID(feet->model);
insertFreePart("meshes\\" + feet->model,"><", insert);
insertFreePart("meshes\\" + feet->model,">:", insert);
}
if(greaves != inv.end()){
const ESM::Armor *armor = (greaves->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts);
}
if(leftpauldron != inv.end()){
const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts);
}
if(rightpauldron != inv.end()){
const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
}
if(!isBeast && boots != inv.end()){
if(boots->getTypeName() == typeid(ESM::Clothing).name()){
const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts);
}
else if(boots->getTypeName() == typeid(ESM::Armor).name())
{
const ESM::Armor *armor = (boots->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts);
}
}
if(leftglove != inv.end()){
if(leftglove->getTypeName() == typeid(ESM::Clothing).name()){
const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts);
}
else
{
const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts);
}
}
if(rightglove != inv.end()){
if(rightglove->getTypeName() == typeid(ESM::Clothing).name()){
const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts);
}
else
{
const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts);
}
}
if(shirt != inv.end()){
const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts);
}
if(pants != inv.end()){
const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts);
}
}
//originalpos = insert->_getWorldAABB().getCenter();
//originalscenenode = insert->getPosition();
if(partpriorities[ESM::PRT_Head] < 1){
addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel);
}
if(partpriorities[ESM::PRT_Hair] < 1 && partpriorities[ESM::PRT_Head] <= 1){
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel);
}
if(partpriorities[ESM::PRT_Neck] < 1){
const ESM::BodyPart *neckPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "neck");
if(neckPart)
addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model);
}
if(partpriorities[ESM::PRT_Cuirass] < 1){
const ESM::BodyPart *chestPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "chest");
if(chestPart)
addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model);
}
if(partpriorities[ESM::PRT_Groin] < 1){
const ESM::BodyPart *groinPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "groin");
if(groinPart)
addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model);
}
if(partpriorities[ESM::PRT_RHand] < 1){
const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand");
if(!handPart)
handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands");
if(handPart)
addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model);
}
if(partpriorities[ESM::PRT_LHand] < 1){
const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand");
if(!handPart)
handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands");
if(handPart)
addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model);
}
if(partpriorities[ESM::PRT_RWrist] < 1){
const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist");
if(wristPart)
addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model);
}
if(partpriorities[ESM::PRT_LWrist] < 1){
const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist");
if(wristPart)
addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model);
}
if(partpriorities[ESM::PRT_RForearm] < 1){
const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm");
if(bodyRaceID == "b_n_argonian_f_")
forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm");
if(forearmPart)
addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model);
}
if(partpriorities[ESM::PRT_LForearm] < 1){
const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm");
if(bodyRaceID == "b_n_argonian_f_")
forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm");
if(forearmPart)
addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model);
}
if(partpriorities[ESM::PRT_RUpperarm] < 1){
const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm");
if(armPart)
addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model);
}
if(partpriorities[ESM::PRT_LUpperarm] < 1){
const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm");
if(armPart)
addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model);
}
if(partpriorities[ESM::PRT_RFoot] < 1){
const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot");
if(isBeast && !footPart)
footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet");
if(footPart)
addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model);
}
if(partpriorities[ESM::PRT_LFoot] < 1){
const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot");
if(isBeast && !footPart)
footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet");
if(footPart)
addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model);
}
if(partpriorities[ESM::PRT_RAnkle] < 1){
const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle");
if(anklePart)
addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model);
}
if(partpriorities[ESM::PRT_LAnkle] < 1){
const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle");
if(anklePart)
addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model);
}
if(partpriorities[ESM::PRT_RKnee] < 1){
const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee");
if(kneePart)
addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model);
}
if(partpriorities[ESM::PRT_LKnee] < 1){
const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee");
if(kneePart)
addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model);
}
if(partpriorities[ESM::PRT_RLeg] < 1){
const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg");
if(legPart)
addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model);
}
if(partpriorities[ESM::PRT_LLeg] < 1){
const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg");
if(legPart)
addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model);
}
if(partpriorities[ESM::PRT_Tail] < 1){
const ESM::BodyPart *tailPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "tail");
if(tailPart)
addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model);
}
}
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
NIFLoader::load(mesh);
Entity* ent = mRend.getScene()->createEntity(mesh);
ent->setVisibilityFlags(RV_Actors);
Ogre::Entity* part = mRend.getScene()->createEntity(mesh);
part->setVisibilityFlags(RV_Actors);
base->attachObjectToBone(bonename, ent);
return ent;
base->attachObjectToBone(bonename, part);
return part;
}
void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert){
void NpcAnimation::insertFootPart(int type, const std::string &mesh){
std::string meshAndSuffix = mesh;
if(type == ESM::PRT_LFoot)
meshAndSuffix += "*|";
NIFLoader::load(meshAndSuffix);
Ogre::Entity* part = mRend.getScene()->createEntity(meshAndSuffix);
std::vector<Nif::NiTriShapeCopy>* shape = ((NIFLoader::getSingletonPtr())->getShapes(meshAndSuffix));
if(shape == 0){
if(type == ESM::PRT_LFoot){
base->attachObjectToBone("Left Foot", part);
lfoot = part;
}
else if (type == ESM::PRT_RFoot){
base->attachObjectToBone("Right Foot", part);
rfoot = part;
}
}
else{
if(type == ESM::PRT_LFoot)
lFreeFoot = insertFreePart(mesh, "::");
else if (type == ESM::PRT_RFoot)
rFreeFoot = insertFreePart(mesh, ":<");
}
}
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix){
std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix;
NIFLoader::load(meshNumbered);
Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered);
ent->setVisibilityFlags(RV_Actors);
Ogre::Entity* part = mRend.getScene()->createEntity(meshNumbered);
part->setVisibilityFlags(RV_Actors);
insert->attachObject(part);
insert->attachObject(ent);
entityparts.push_back(ent);
shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
if(shapes){
shapeparts.push_back(shapes);
handleShapes(shapes, ent, base->getSkeleton());
std::vector<Nif::NiTriShapeCopy>* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
if(shape){
handleShapes(shape, part, base->getSkeleton());
}
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> pair = std::make_pair(part, shape);
return pair;
}
}
void NpcAnimation::runAnimation(float timepassed){
if(timeToChange > .2){
timeToChange = 0;
updateParts();
}
timeToChange += timepassed;
//1. Add the amount of time passed to time
//2. Handle the animation transforms dependent on time
@ -283,23 +577,285 @@ void NpcAnimation::runAnimation(float timepassed){
time = startTime + (time - stopTime);
}
handleAnimationTransforms();
handleAnimationTransforms();
std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
while(shapepartsiter != shapeparts.end())
{
vecRotPos.clear();
std::vector<Nif::NiTriShapeCopy>* shapes = *shapepartsiter;
Ogre::Entity* theentity = *entitypartsiter;
handleShapes(shapes, theentity, base->getSkeleton());
shapepartsiter++;
entitypartsiter++;
if(lFreeFoot.first)
handleShapes(lFreeFoot.second, lFreeFoot.first, base->getSkeleton());
if(rFreeFoot.first)
handleShapes(rFreeFoot.second, rFreeFoot.first, base->getSkeleton());
if(chest.first)
handleShapes(chest.second, chest.first, base->getSkeleton());
if(tail.first)
handleShapes(tail.second, tail.first, base->getSkeleton());
if(skirt.first){
handleShapes(skirt.second, skirt.first, base->getSkeleton());
}
if(lhand.first)
handleShapes(lhand.second, lhand.first, base->getSkeleton());
if(rhand.first)
handleShapes(rhand.second, rhand.first, base->getSkeleton());
}
}
void NpcAnimation::removeIndividualPart(int type){
partpriorities[type] = 0;
partslots[type] = -1;
if(type == ESM::PRT_Head && head){ //0
base->detachObjectFromBone(head);
head = 0;
}
else if(type == ESM::PRT_Hair && hair){//1
base->detachObjectFromBone(hair);
hair = 0;
}
else if(type == ESM::PRT_Neck && neck){//2
base->detachObjectFromBone(neck);
neck = 0;
}
else if(type == ESM::PRT_Cuirass && chest.first){//3
insert->detachObject(chest.first);
chest = zero;
}
else if(type == ESM::PRT_Groin && groin){//4
base->detachObjectFromBone(groin);
groin = 0;
}
else if(type == ESM::PRT_Skirt && skirt.first){//5
insert->detachObject(skirt.first);
skirt = zero;
}
else if(type == ESM::PRT_RHand && rhand.first){//6
insert->detachObject(rhand.first);
rhand = zero;
}
else if(type == ESM::PRT_LHand && lhand.first){//7
insert->detachObject(lhand.first);
lhand = zero;
}
else if(type == ESM::PRT_RWrist && rWrist){//8
base->detachObjectFromBone(rWrist);
rWrist = 0;
}
else if(type == ESM::PRT_LWrist && lWrist){//9
base->detachObjectFromBone(lWrist);
lWrist = 0;
}
else if(type == ESM::PRT_Shield){//10
}
else if(type == ESM::PRT_RForearm && rForearm){//11
base->detachObjectFromBone(rForearm);
rForearm = 0;
}
else if(type == ESM::PRT_LForearm && lForearm){//12
base->detachObjectFromBone(lForearm);
lForearm = 0;
}
else if(type == ESM::PRT_RUpperarm && rupperArm){//13
base->detachObjectFromBone(rupperArm);
rupperArm = 0;
}
else if(type == ESM::PRT_LUpperarm && lupperArm){//14
base->detachObjectFromBone(lupperArm);
lupperArm = 0;
}
else if(type == ESM::PRT_RFoot){ //15
if(rfoot){
base->detachObjectFromBone(rfoot);
rfoot = 0;
}
else if(rFreeFoot.first){
insert->detachObject(rFreeFoot.first);
rFreeFoot = zero;
}
}
else if(type == ESM::PRT_LFoot){ //16
if(lfoot){
base->detachObjectFromBone(lfoot);
lfoot = 0;
}
else if(lFreeFoot.first){
insert->detachObject(lFreeFoot.first);
lFreeFoot = zero;
}
}
else if(type == ESM::PRT_RAnkle && rAnkle){ //17
base->detachObjectFromBone(rAnkle);
rAnkle = 0;
}
else if(type == ESM::PRT_LAnkle && lAnkle){ //18
base->detachObjectFromBone(lAnkle);
lAnkle = 0;
}
else if(type == ESM::PRT_RKnee && rKnee){ //19
base->detachObjectFromBone(rKnee);
rKnee = 0;
}
else if(type == ESM::PRT_LKnee && lKnee){ //20
base->detachObjectFromBone(lKnee);
lKnee = 0;
}
else if(type == ESM::PRT_RLeg && rUpperLeg){ //21
base->detachObjectFromBone(rUpperLeg);
rUpperLeg = 0;
}
else if(type == ESM::PRT_LLeg && lUpperLeg){ //22
base->detachObjectFromBone(lUpperLeg);
lUpperLeg = 0;
}
else if(type == ESM::PRT_RPauldron && rclavicle){ //23
base->detachObjectFromBone(rclavicle);
rclavicle = 0;
}
else if(type == ESM::PRT_LPauldron && lclavicle){ //24
base->detachObjectFromBone(lclavicle);
lclavicle = 0;
}
else if(type == ESM::PRT_Weapon){ //25
}
else if(type == ESM::PRT_Tail && tail.first){ //26
insert->detachObject(tail.first);
tail = zero;
}
}
void NpcAnimation::reserveIndividualPart(int type, int group, int priority){
if(priority > partpriorities[type]){
removeIndividualPart(type);
partpriorities[type] = priority;
partslots[type] = group;
}
}
}
void NpcAnimation::removePartGroup(int group){
for(int i = 0; i < 27; i++){
if(partslots[i] == group){
removeIndividualPart(i);
}
}
}
bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){
if(priority > partpriorities[type]){
removeIndividualPart(type);
partslots[type] = group;
partpriorities[type] = priority;
switch(type){
case ESM::PRT_Head: //0
head = insertBoundedPart(mesh, "Head");
break;
case ESM::PRT_Hair: //1
hair = insertBoundedPart(mesh, "Head");
break;
case ESM::PRT_Neck: //2
neck = insertBoundedPart(mesh, "Neck");
break;
case ESM::PRT_Cuirass: //3
chest = insertFreePart(mesh, ":\"");
break;
case ESM::PRT_Groin: //4
groin = insertBoundedPart(mesh, "Groin");
break;
case ESM::PRT_Skirt: //5
skirt = insertFreePart(mesh, ":|");
break;
case ESM::PRT_RHand: //6
rhand = insertFreePart(mesh, ":?");
break;
case ESM::PRT_LHand: //7
lhand = insertFreePart(mesh, ":>");
break;
case ESM::PRT_RWrist: //8
rWrist = insertBoundedPart(mesh, "Right Wrist");
break;
case ESM::PRT_LWrist: //9
lWrist = insertBoundedPart(mesh + "*|", "Left Wrist");
break;
case ESM::PRT_Shield: //10
break;
case ESM::PRT_RForearm: //11
rForearm = insertBoundedPart(mesh, "Right Forearm");
break;
case ESM::PRT_LForearm: //12
lForearm = insertBoundedPart(mesh + "*|", "Left Forearm");
break;
case ESM::PRT_RUpperarm: //13
rupperArm = insertBoundedPart(mesh, "Right Upper Arm");
break;
case ESM::PRT_LUpperarm: //14
lupperArm = insertBoundedPart(mesh + "*|", "Left Upper Arm");
break;
case ESM::PRT_RFoot: //15
insertFootPart(type, mesh);
break;
case ESM::PRT_LFoot: //16
insertFootPart(type, mesh);
break;
case ESM::PRT_RAnkle: //17
rAnkle = insertBoundedPart(mesh , "Right Ankle");
break;
case ESM::PRT_LAnkle: //18
lAnkle = insertBoundedPart(mesh + "*|", "Left Ankle");
break;
case ESM::PRT_RKnee: //19
rKnee = insertBoundedPart(mesh , "Right Knee");
break;
case ESM::PRT_LKnee: //20
lKnee = insertBoundedPart(mesh + "*|", "Left Knee");
break;
case ESM::PRT_RLeg: //21
rUpperLeg = insertBoundedPart(mesh, "Right Upper Leg");
break;
case ESM::PRT_LLeg: //22
lUpperLeg = insertBoundedPart(mesh + "*|", "Left Upper Leg");
break;
case ESM::PRT_RPauldron: //23
rclavicle = insertBoundedPart(mesh , "Right Clavicle");
break;
case ESM::PRT_LPauldron: //24
lclavicle = insertBoundedPart(mesh + "*|", "Left Clavicle");
break;
case ESM::PRT_Weapon: //25
break;
case ESM::PRT_Tail: //26
tail = insertFreePart(mesh, ":*");
break;
}
return true;
}
return false;
}
void NpcAnimation::addPartGroup(int group, int priority, std::vector<ESM::PartReference>& parts){
for(std::size_t i = 0; i < parts.size(); i++)
{
ESM::PartReference part = parts[i];
const ESM::BodyPart *bodypart = 0;
if(isFemale)
bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.female);
if(!bodypart)
bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.male);
if(bodypart){
addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model);
}
else
reserveIndividualPart(part.part, group, priority);
}
}
}

@ -6,25 +6,96 @@
#include <components/nif/property.hpp>
#include <components/nif/controller.hpp>
#include <components/nif/extra.hpp>
#include <utility>
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/environment.hpp"
#include "components/nifogre/ogre_nif_loader.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwclass/npc.hpp"
#include "../mwworld/containerstore.hpp"
#include "components/esm/loadarmo.hpp"
namespace MWRender{
class NpcAnimation: public Animation{
private:
MWWorld::InventoryStore& inv;
int mStateID;
//Free Parts
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> chest;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> skirt;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> lhand;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> rhand;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> tail;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> lFreeFoot;
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> rFreeFoot;
int partslots[27]; //Each part slot is taken by clothing, armor, or is empty
int partpriorities[27];
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> zero;
//Bounded Parts
Ogre::Entity* lclavicle;
Ogre::Entity* rclavicle;
Ogre::Entity* rupperArm;
Ogre::Entity* lupperArm;
Ogre::Entity* rUpperLeg;
Ogre::Entity* lUpperLeg;
Ogre::Entity* lForearm;
Ogre::Entity* rForearm;
Ogre::Entity* lWrist;
Ogre::Entity* rWrist;
Ogre::Entity* rKnee;
Ogre::Entity* lKnee;
Ogre::Entity* neck;
Ogre::Entity* rAnkle;
Ogre::Entity* lAnkle;
Ogre::Entity* groin;
Ogre::Entity* lfoot;
Ogre::Entity* rfoot;
Ogre::Entity* hair;
Ogre::Entity* head;
Ogre::SceneNode* insert;
bool isBeast;
bool isFemale;
std::string headModel;
std::string hairModel;
std::string npcName;
std::string bodyRaceID;
float timeToChange;
MWWorld::ContainerStoreIterator robe;
MWWorld::ContainerStoreIterator helmet;
MWWorld::ContainerStoreIterator shirt;
MWWorld::ContainerStoreIterator cuirass;
MWWorld::ContainerStoreIterator greaves;
MWWorld::ContainerStoreIterator leftpauldron;
MWWorld::ContainerStoreIterator rightpauldron;
MWWorld::ContainerStoreIterator boots;
MWWorld::ContainerStoreIterator pants;
MWWorld::ContainerStoreIterator leftglove;
MWWorld::ContainerStoreIterator rightglove;
MWWorld::ContainerStoreIterator skirtiter;
public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv);
virtual ~NpcAnimation();
Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert);
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> insertFreePart(const std::string &mesh, const std::string suffix);
void insertFootPart(int type, const std::string &mesh);
virtual void runAnimation(float timepassed);
void updateParts();
void removeIndividualPart(int type);
void reserveIndividualPart(int type, int group, int priority);
bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh);
void removePartGroup(int group);
void addPartGroup(int group, int priority, std::vector<ESM::PartReference>& parts);
};
}
#endif
#endif

@ -8,20 +8,15 @@
using namespace MWRender;
bool Objects::lightConst = false;
float Objects::lightConstValue = 0.0f;
bool Objects::lightLinear = true;
int Objects::lightLinearMethod = 1;
// These are the Morrowind.ini defaults
float Objects::lightLinearValue = 3;
float Objects::lightLinearRadiusMult = 1;
bool Objects::lightQuadratic = false;
int Objects::lightQuadraticMethod = 2;
float Objects::lightQuadraticValue = 16;
float Objects::lightQuadraticRadiusMult = 1;
bool Objects::lightOutQuadInLin = false;
bool Objects::lightOutQuadInLin = true;
bool Objects::lightQuadratic = false;
int Objects::uniqueID = 0;
@ -58,8 +53,10 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
const float *f = ptr.getRefData().getPosition().pos;
insert->setPosition(f[0], f[1], f[2]);
insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale);
// Convert MW rotation to a quaternion:
f = ptr.getCellRef().pos.rot;
@ -132,7 +129,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
}
}
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects"))
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || transparent)
{
insert->attachObject(ent);
@ -144,18 +141,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
{
Ogre::StaticGeometry* sg = 0;
/* if (transparent)
{
if( mStaticGeometryAlpha.find(ptr.getCell()) == mStaticGeometryAlpha.end())
{
uniqueID = uniqueID +1;
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
mStaticGeometryAlpha[ptr.getCell()] = sg;
}
else
sg = mStaticGeometryAlpha[ptr.getCell()];
}
else*/ if (small)
if (small)
{
if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end())
{
@ -207,35 +193,61 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
assert(insert);
Ogre::Light *light = mRenderer.getScene()->createLight();
light->setDiffuseColour (r, g, b);
mLights.push_back(light->getName());
float cval=0.0f, lval=0.0f, qval=0.0f;
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
LightInfo info;
info.name = light->getName();
info.radius = radius;
info.colour = Ogre::ColourValue(r, g, b);
if (ref->base->data.flags & ESM::Light::Negative)
info.colour *= -1;
if(lightConst)
cval = lightConstValue;
info.interior = (ptr.getCell()->cell->data.flags & ESM::Cell::Interior);
if(!lightOutQuadInLin)
if (ref->base->data.flags & ESM::Light::Flicker)
info.type = LT_Flicker;
else if (ref->base->data.flags & ESM::Light::FlickerSlow)
info.type = LT_FlickerSlow;
else if (ref->base->data.flags & ESM::Light::Pulse)
info.type = LT_Pulse;
else if (ref->base->data.flags & ESM::Light::PulseSlow)
info.type = LT_PulseSlow;
else
info.type = LT_Normal;
// random starting phase for the animation
info.time = Ogre::Math::RangeRandom(0, 2 * M_PI);
// adjust the lights depending if we're in an interior or exterior cell
// quadratic means the light intensity falls off quite fast, resulting in a
// dark, atmospheric environment (perfect for exteriors)
// for interiors, we want more "warm" lights, so use linear attenuation.
bool quadratic = false;
if (!lightOutQuadInLin)
quadratic = lightQuadratic;
else
{
quadratic = !info.interior;
}
if (!quadratic)
{
if(lightLinear)
radius *= lightLinearRadiusMult;
if(lightQuadratic)
radius *= lightQuadraticRadiusMult;
if(lightLinear)
lval = lightLinearValue / pow(radius, lightLinearMethod);
if(lightQuadratic)
qval = lightQuadraticValue / pow(radius, lightQuadraticMethod);
float r = radius * lightLinearRadiusMult;
float attenuation = lightLinearValue / r;
light->setAttenuation(r*10, 0, attenuation, 0);
}
else
{
// FIXME:
// Do quadratic or linear, depending if we're in an exterior or interior
// cell, respectively. Ignore lightLinear and lightQuadratic.
float r = radius * lightQuadraticRadiusMult;
float attenuation = lightQuadraticValue / pow(r, 2);
light->setAttenuation(r*10, 0, 0, attenuation);
}
light->setAttenuation(10*radius, cval, lval, qval);
insert->attachObject(light);
mLights.push_back(info);
}
bool Objects::deleteObject (const MWWorld::Ptr& ptr)
@ -290,13 +302,6 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store)
mRenderer.getScene()->destroyStaticGeometry (sg);
sg = 0;
}
/*if(mStaticGeometryAlpha.find(store) != mStaticGeometryAlpha.end())
{
Ogre::StaticGeometry* sg = mStaticGeometryAlpha[store];
mStaticGeometryAlpha.erase(store);
mRenderer.getScene()->destroyStaticGeometry (sg);
sg = 0;
}*/
if(mBounds.find(store) != mBounds.end())
mBounds.erase(store);
@ -314,11 +319,6 @@ void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell)
Ogre::StaticGeometry* sg = mStaticGeometrySmall[&cell];
sg->build();
}
/*if(mStaticGeometryAlpha.find(&cell) != mStaticGeometryAlpha.end())
{
Ogre::StaticGeometry* sg = mStaticGeometryAlpha[&cell];
sg->build();
}*/
}
Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell)
@ -328,12 +328,12 @@ Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell)
void Objects::enableLights()
{
std::vector<std::string>::iterator it = mLights.begin();
std::vector<LightInfo>::iterator it = mLights.begin();
while (it != mLights.end())
{
if (mMwRoot->getCreator()->hasLight(*it))
if (mMwRoot->getCreator()->hasLight(it->name))
{
mMwRoot->getCreator()->getLight(*it)->setVisible(true);
mMwRoot->getCreator()->getLight(it->name)->setVisible(true);
++it;
}
else
@ -343,12 +343,12 @@ void Objects::enableLights()
void Objects::disableLights()
{
std::vector<std::string>::iterator it = mLights.begin();
std::vector<LightInfo>::iterator it = mLights.begin();
while (it != mLights.end())
{
if (mMwRoot->getCreator()->hasLight(*it))
if (mMwRoot->getCreator()->hasLight(it->name))
{
mMwRoot->getCreator()->getLight(*it)->setVisible(false);
mMwRoot->getCreator()->getLight(it->name)->setVisible(false);
++it;
}
else
@ -356,3 +356,90 @@ void Objects::disableLights()
}
}
void Objects::update(const float dt)
{
std::vector<LightInfo>::iterator it = mLights.begin();
while (it != mLights.end())
{
if (mMwRoot->getCreator()->hasLight(it->name))
{
Ogre::Light* light = mMwRoot->getCreator()->getLight(it->name);
// Light animation (pulse & flicker)
it->time += dt;
const float phase = std::fmod(static_cast<double> (it->time), (32 * 2 * M_PI)) * 20;
float pulseConstant;
// These formulas are just guesswork, but they work pretty well
if (it->type == LT_Normal)
{
// Less than 1/255 light modifier for a constant light:
pulseConstant = (const float)(1.0 + sin(phase) / 255.0 );
}
else if (it->type == LT_Flicker)
{
// Let's do a 50% -> 100% sine wave pulse over 1 second:
// This is 75% +/- 25%
pulseConstant = (const float)(0.75 + sin(phase) * 0.25);
// Then add a 25% flicker variation:
it->resetTime -= dt;
if (it->resetTime < 0)
{
it->flickerVariation = (rand() % 1000) / 1000 * 0.25;
it->resetTime = 0.5;
}
if (it->resetTime > 0.25)
{
pulseConstant = (pulseConstant+it->flickerVariation) * (1-it->resetTime * 2.0f) + pulseConstant * it->resetTime * 2.0f;
}
else
{
pulseConstant = (pulseConstant+it->flickerVariation) * (it->resetTime * 2.0f) + pulseConstant * (1-it->resetTime * 2.0f);
}
}
else if (it->type == LT_FlickerSlow)
{
// Let's do a 50% -> 100% sine wave pulse over 1 second:
// This is 75% +/- 25%
pulseConstant = (const float)(0.75 + sin(phase / 4.0) * 0.25);
// Then add a 25% flicker variation:
it->resetTime -= dt;
if (it->resetTime < 0)
{
it->flickerVariation = (rand() % 1000) / 1000 * 0.25;
it->resetTime = 0.5;
}
if (it->resetTime > 0.5)
{
pulseConstant = (pulseConstant+it->flickerVariation) * (1-it->resetTime) + pulseConstant * it->resetTime;
}
else
{
pulseConstant = (pulseConstant+it->flickerVariation) * (it->resetTime) + pulseConstant * (1-it->resetTime);
}
}
else if (it->type == LT_Pulse)
{
// Let's do a 75% -> 125% sine wave pulse over 1 second:
// This is 100% +/- 25%
pulseConstant = (const float)(1.0 + sin(phase) * 0.25);
}
else if (it->type == LT_PulseSlow)
{
// Let's do a 75% -> 125% sine wave pulse over 1 second:
// This is 100% +/- 25%
pulseConstant = (const float)(1.0 + sin(phase / 4.0) * 0.25);
}
else
assert(0 && "Invalid light type");
light->setDiffuseColour( it->colour * pulseConstant );
++it;
}
else
it = mLights.erase(it);
}
}

@ -10,27 +10,55 @@
namespace MWRender{
/// information about light needed for rendering
enum LightType
{
// These are all mutually exclusive
LT_Normal=0,
LT_Flicker=1,
LT_FlickerSlow=2,
LT_Pulse=3,
LT_PulseSlow=4
};
struct LightInfo
{
// Constants
std::string name; // ogre handle
Ogre::ColourValue colour;
float radius;
bool interior; // Does this light belong to an interior or exterior cell
LightType type;
// Runtime variables
float flickerVariation; // 25% flicker variation, reset once every 0.5 seconds
float flickerSlowVariation; // 25% flicker variation, reset once every 1.0 seconds
float resetTime;
long double time;
LightInfo() :
flickerVariation(0), resetTime(0.5),
flickerSlowVariation(0), time(0), interior(true)
{
}
};
class Objects{
OEngine::Render::OgreRenderer &mRenderer;
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometry;
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall;
//std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometryAlpha;
std::map<MWWorld::Ptr::CellStore *, Ogre::AxisAlignedBox> mBounds;
std::vector<std::string> mLights;
std::vector<LightInfo> mLights;
Ogre::SceneNode* mMwRoot;
bool mIsStatic;
static int uniqueID;
static bool lightConst;
static float lightConstValue;
static bool lightLinear;
static int lightLinearMethod;
static float lightLinearValue;
static float lightLinearRadiusMult;
static bool lightQuadratic;
static int lightQuadraticMethod;
static float lightQuadraticValue;
static float lightQuadraticRadiusMult;
@ -40,7 +68,7 @@ class Objects{
///< Remove all movable objects from \a node.
public:
Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer){}
Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer) {}
~Objects(){}
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
@ -49,6 +77,9 @@ public:
void enableLights();
void disableLights();
void update (const float dt);
///< per-frame update
Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*);
///< get a bounding box that encloses all objects in the specified cell

@ -65,6 +65,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
mBBQueryTotal->createBillboard(Vector3::ZERO);
mBBQueryTotal->setMaterialName("QueryTotalPixels");
mBBQueryTotal->setRenderQueueGroup(RQG_OcclusionQuery+1);
mBBQueryTotal->setVisibilityFlags(RV_OcclusionQuery);
mBBNodeReal->attachObject(mBBQueryTotal);
mBBQueryVisible = mRendering->getScene()->createBillboardSet(1);
@ -73,6 +74,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
mBBQueryVisible->createBillboard(Vector3::ZERO);
mBBQueryVisible->setMaterialName("QueryVisiblePixels");
mBBQueryVisible->setRenderQueueGroup(RQG_OcclusionQuery+1);
mBBQueryVisible->setVisibilityFlags(RV_OcclusionQuery);
mBBNodeReal->attachObject(mBBQueryVisible);
mBBQuerySingleObject = mRendering->getScene()->createBillboardSet(1);
@ -82,6 +84,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
mBBQuerySingleObject->createBillboard(Vector3::ZERO);
mBBQuerySingleObject->setMaterialName("QueryVisiblePixels");
mBBQuerySingleObject->setRenderQueueGroup(RQG_OcclusionQuery);
mBBQuerySingleObject->setVisibilityFlags(RV_OcclusionQuery);
mObjectNode->attachObject(mBBQuerySingleObject);
mRendering->getScene()->addRenderObjectListener(this);

@ -52,6 +52,8 @@ enum VisibilityFlags
// Sun glare (not visible in reflection)
RV_Glare = 128,
RV_OcclusionQuery = 256,
RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water,
/// \todo markers (normally hidden)

@ -24,8 +24,8 @@ using namespace Ogre;
namespace MWRender {
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mSunEnabled(0)
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine)
:mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0)
{
mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
@ -52,11 +52,16 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
// Load resources
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Due to the huge world size of MW, we'll want camera-relative rendering.
// This prevents precision artifacts when moving very far from the origin.
mRendering.getScene()->setCameraRelativeRendering(true);
// disable unsupported effects
const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities();
if (caps->getNumMultiRenderTargets() < 2)
if (caps->getNumMultiRenderTargets() < 2 || !Settings::Manager::getBool("shaders", "Objects"))
Settings::Manager::setBool("shader", "Water", false);
if (!caps->isShaderProfileSupported("fp40") && !caps->isShaderProfileSupported("ps_4_0"))
if ( !(caps->isShaderProfileSupported("fp40") || caps->isShaderProfileSupported("ps_4_0"))
|| !Settings::Manager::getBool("shaders", "Objects"))
Settings::Manager::setBool("enabled", "Shadows", false);
// note that the order is important here
@ -93,19 +98,18 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
mShadows = new Shadows(&mRendering);
mShaderHelper = new ShaderHelper(this);
mTerrainManager = new TerrainManager(mRendering.getScene(), this,
environment);
mTerrainManager = new TerrainManager(mRendering.getScene(), this);
//mSkyManager = 0;
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment);
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera());
mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode());
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
mSun = 0;
mDebugging = new Debugging(mMwRoot, environment, engine);
mLocalMap = new MWRender::LocalMap(&mRendering, this, &environment);
mDebugging = new Debugging(mMwRoot, engine);
mLocalMap = new MWRender::LocalMap(&mRendering, this);
}
RenderingManager::~RenderingManager ()
@ -208,6 +212,7 @@ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Ve
void RenderingManager::update (float duration){
mActors.update (duration);
mObjects.update (duration);
mOcclusionQuery->update(duration);
@ -220,6 +225,8 @@ void RenderingManager::update (float duration){
mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealOrientation() );
checkUnderwater();
mWater->update();
}
void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
if(store->cell->data.flags & store->cell->HasWater){
@ -501,4 +508,14 @@ Shadows* RenderingManager::getShadows()
return mShadows;
}
void RenderingManager::switchToInterior()
{
mRendering.getScene()->setCameraRelativeRendering(false);
}
void RenderingManager::switchToExterior()
{
mRendering.getScene()->setCameraRelativeRendering(true);
}
} // namespace

@ -57,7 +57,7 @@ class RenderingManager: private RenderingInterface {
virtual MWRender::Actors& getActors();
public:
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment);
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine);
virtual ~RenderingManager();
@ -117,6 +117,9 @@ class RenderingManager: private RenderingInterface {
Shadows* getShadows();
void switchToInterior();
void switchToExterior();
void setGlare(bool glare);
void skyEnable ();
void skyDisable ();

@ -256,9 +256,9 @@ void ShaderHelper::createShader(const bool mrt, const bool shadows, const bool s
}
outStream <<
" float3 lightingFinal = lightColour.xyz * diffuse.xyz * vertexColour.xyz + ambient.xyz * lightAmbient.xyz + emissive.xyz; \n"
" float3 lightingFinal = lightColour.xyz * diffuse.xyz + ambient.xyz * lightAmbient.xyz + emissive.xyz; \n"
" float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); \n"
" oColor.xyz = lerp(lightingFinal * tex.xyz, fogColour.xyz, fogValue); \n"
" oColor.xyz = lerp(lightingFinal * tex.xyz * vertexColour.xyz, fogColour.xyz, fogValue); \n"
" oColor.a = tex.a * diffuse.a * vertexColour.a; \n";
if (mrt) outStream <<

@ -66,7 +66,10 @@ void Shadows::recreate()
if (split)
{
mPSSMSetup = new PSSMShadowCameraSetup();
mPSSMSetup->setSplitPadding(5);
// Make sure to keep this in sync with the camera's near clip distance!
mPSSMSetup->setSplitPadding(mRendering->getCamera()->getNearClipDistance());
mPSSMSetup->calculateSplitPoints(3, mRendering->getCamera()->getNearClipDistance(), mShadowFar);
const Real adjustFactors[3] = {64, 64, 64};

@ -10,7 +10,7 @@
#include <components/nifogre/ogre_nif_loader.hpp>
#include "../mwworld/environment.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "renderconst.hpp"
#include "renderingmanager.hpp"
@ -271,10 +271,10 @@ void Moon::setPhase(const Moon::Phase& phase)
{
// Colour texture
Ogre::String textureName = "textures\\tx_";
if (mType == Moon::Type_Secunda) textureName += "secunda_";
else textureName += "masser_";
if (phase == Moon::Phase_New) textureName += "new";
else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax";
else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax";
@ -283,9 +283,9 @@ void Moon::setPhase(const Moon::Phase& phase)
else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan";
else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan";
else if (phase == Moon::Phase_Full) textureName += "full";
textureName += ".dds";
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
mPhase = phase;
@ -365,9 +365,8 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
}
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env)
: mEnvironment(env)
, mHour(0.0f)
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
: mHour(0.0f)
, mDay(0)
, mMonth(0)
, mSun(NULL)
@ -713,7 +712,7 @@ void SkyManager::update(float duration)
if (!mEnabled) return;
// UV Scroll the clouds
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f);
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
/// \todo improve this
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
@ -752,7 +751,7 @@ void SkyManager::update(float duration)
mSecunda->setVisible(mSecundaEnabled);
// rotate the stars by 360 degrees every 4 days
mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f)));
mAtmosphereNight->roll(Degree(MWBase::Environment::get().getWorld()->getTimeScaleFactor()*duration*360 / (3600*96.f)));
}
void SkyManager::enable()

@ -59,8 +59,8 @@ namespace MWRender
Ogre::MaterialPtr mMaterial;
Ogre::BillboardSet* mBBSet;
};
/*
* The moons need a seperate class because of their shader (which allows them to be partially transparent)
*/
@ -104,11 +104,11 @@ namespace MWRender
Type mType;
Phase mPhase;
};
class SkyManager
{
public:
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env);
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera);
~SkyManager();
void update(float duration);
@ -176,7 +176,6 @@ namespace MWRender
private:
bool mCreated;
MWWorld::Environment* mEnvironment;
float mHour;
int mDay;
int mMonth;

@ -4,6 +4,8 @@
#include "../mwworld/world.hpp"
#include "../mwbase/environment.hpp"
#include "terrainmaterial.hpp"
#include "terrain.hpp"
#include "renderconst.hpp"
@ -17,8 +19,8 @@ namespace MWRender
//----------------------------------------------------------------------------------------------
TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend, const MWWorld::Environment& evn) :
mEnvironment(evn), mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend)
TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend) :
mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend)
{
TerrainMaterialGeneratorPtr matGen;
@ -107,7 +109,7 @@ namespace MWRender
const int cellX = store->cell->getGridX();
const int cellY = store->cell->getGridY();
ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY);
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY);
if ( land != NULL )
{
if (!land->dataLoaded)
@ -268,7 +270,7 @@ namespace MWRender
{
//NB: All vtex ids are +1 compared to the ltex ids
assert( (int)mEnvironment.mWorld->getStore().landTexts.getSize() >= (int)ltexIndex - 1 &&
assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 &&
"LAND.VTEX must be within the bounds of the LTEX array");
std::string texture;
@ -278,7 +280,7 @@ namespace MWRender
}
else
{
texture = mEnvironment.mWorld->getStore().landTexts.search(ltexIndex-1)->texture;
texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture;
//TODO this is needed due to MWs messed up texture handling
texture = texture.substr(0, texture.rfind(".")) + ".dds";
}
@ -434,7 +436,7 @@ namespace MWRender
}
ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY);
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY);
if ( land != NULL )
{
if (!land->dataLoaded)

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

Loading…
Cancel
Save