mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Merge branch 'master' of git://github.com/zinnschlag/openmw into jenkins-code-coverage-and-unittests
This commit is contained in:
commit
99c46093dd
207 changed files with 13403 additions and 5681 deletions
|
@ -98,19 +98,13 @@ ENDIF()
|
|||
|
||||
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
|
||||
|
||||
set(MANGLE_INPUT ${LIBDIR}/mangle/input/servers/ois_driver.cpp)
|
||||
set(MANGLE_ALL ${MANGLE_INPUT})
|
||||
source_group(libs\\mangle FILES ${MANGLE_ALL})
|
||||
|
||||
set(OENGINE_OGRE
|
||||
${LIBDIR}/openengine/ogre/renderer.cpp
|
||||
${LIBDIR}/openengine/ogre/mouselook.cpp
|
||||
${LIBDIR}/openengine/ogre/fader.cpp
|
||||
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
||||
${LIBDIR}/openengine/ogre/atlas.cpp
|
||||
)
|
||||
set(OENGINE_GUI
|
||||
${LIBDIR}/openengine/gui/events.cpp
|
||||
${LIBDIR}/openengine/gui/manager.cpp
|
||||
)
|
||||
|
||||
|
@ -137,7 +131,7 @@ set(OENGINE_BULLET
|
|||
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
|
||||
source_group(libs\\openengine FILES ${OENGINE_ALL})
|
||||
|
||||
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL})
|
||||
set(OPENMW_LIBS ${OENGINE_ALL})
|
||||
set(OPENMW_LIBS_HEADER)
|
||||
|
||||
# Sound setup
|
||||
|
@ -447,6 +441,7 @@ endif(WIN32)
|
|||
|
||||
# Extern
|
||||
add_subdirectory (extern/shiny)
|
||||
add_subdirectory (extern/oics)
|
||||
|
||||
# Components
|
||||
add_subdirectory (components)
|
||||
|
|
|
@ -197,7 +197,7 @@ bool DataFilesPage::setupDataFiles()
|
|||
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||
// ("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||
|
||||
|
@ -206,11 +206,10 @@ bool DataFilesPage::setupDataFiles()
|
|||
// Put the paths in a boost::filesystem vector to use with Files::Collections
|
||||
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||
|
||||
// std::string local = variables["data-local"].as<std::string>();
|
||||
// if (!local.empty()) {
|
||||
// mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||
// dataDirs.push_back(Files::PathContainer::value_type(local));
|
||||
// }
|
||||
std::string local = variables["data-local"].as<std::string>();
|
||||
if (!local.empty()) {
|
||||
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
if (mDataDirs.size()>1)
|
||||
mDataDirs.resize (1);
|
||||
|
|
|
@ -21,7 +21,6 @@ add_openmw_dir (mwrender
|
|||
|
||||
add_openmw_dir (mwinput
|
||||
inputmanagerimp
|
||||
mouselookevent
|
||||
)
|
||||
|
||||
add_openmw_dir (mwgui
|
||||
|
@ -29,7 +28,8 @@ add_openmw_dir (mwgui
|
|||
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
||||
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu
|
||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||
itemselection
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
@ -61,7 +61,7 @@ add_openmw_dir (mwclass
|
|||
|
||||
add_openmw_dir (mwmechanics
|
||||
mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells
|
||||
activespells npcstats
|
||||
activespells npcstats aipackage aisequence
|
||||
)
|
||||
|
||||
add_openmw_dir (mwbase
|
||||
|
@ -104,6 +104,7 @@ target_link_libraries(openmw
|
|||
${MYGUI_PLATFORM_LIBRARIES}
|
||||
"shiny"
|
||||
"shiny.OgrePlatform"
|
||||
"oics"
|
||||
components
|
||||
)
|
||||
|
||||
|
@ -114,7 +115,9 @@ endif()
|
|||
|
||||
if(APPLE)
|
||||
find_library(CARBON_FRAMEWORK Carbon)
|
||||
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||
find_library(COCOA_FRAMEWORK Cocoa)
|
||||
find_library(IOKIT_FRAMEWORK IOKit)
|
||||
target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})
|
||||
endif(APPLE)
|
||||
|
||||
if(DPKG_PROGRAM)
|
||||
|
|
|
@ -270,6 +270,10 @@ void OMW::Engine::go()
|
|||
else if (boost::filesystem::exists(globaldefault))
|
||||
settings.loadUser(globaldefault);
|
||||
|
||||
// Get the path for the keybinder xml file
|
||||
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
|
||||
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||
|
||||
mFpsLevel = settings.getInt("fps", "HUD");
|
||||
|
||||
// load nif overrides
|
||||
|
@ -321,7 +325,7 @@ void OMW::Engine::go()
|
|||
|
||||
// Create the world
|
||||
mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
||||
mResDir, mNewGame, mEncoding, mFallbackMap));
|
||||
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap));
|
||||
|
||||
// Create window manager - this manages all the MW-specific GUI windows
|
||||
MWScript::registerExtensions (mExtensions);
|
||||
|
@ -368,9 +372,9 @@ void OMW::Engine::go()
|
|||
|
||||
// Sets up the input system
|
||||
|
||||
mEnvironment.setInputManager (new MWInput::MWInputManager (*mOgre,
|
||||
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
||||
MWBase::Environment::get().getWorld()->getPlayer(),
|
||||
*MWBase::Environment::get().getWindowManager(), mDebug, *this));
|
||||
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
|
||||
|
||||
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
||||
|
||||
|
|
|
@ -207,15 +207,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
std::string local(variables["data-local"].as<std::string>());
|
||||
if (!local.empty())
|
||||
{
|
||||
std::cout << "Ignoring data-local (currently not supported)" << std::endl;
|
||||
// dataDirs.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
if (dataDirs.size()>1)
|
||||
{
|
||||
dataDirs.resize (1);
|
||||
std::cout << "Ignoring all but the first data path (multiple data paths currently not supported)"
|
||||
<< std::endl;
|
||||
dataDirs.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
cfgMgr.processPaths(dataDirs);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace MWBase
|
|||
|
||||
virtual ~InputManager() {}
|
||||
|
||||
virtual void update(float duration) = 0;
|
||||
virtual void update(float dt) = 0;
|
||||
|
||||
virtual void changeInputMode(bool guiMode) = 0;
|
||||
|
||||
|
@ -32,7 +32,12 @@ namespace MWBase
|
|||
|
||||
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
|
||||
|
||||
virtual void resetIdleTime() = 0;
|
||||
virtual std::string getActionDescription (int action) = 0;
|
||||
virtual std::string getActionBindingName (int action) = 0;
|
||||
virtual std::vector<int> getActionSorting () = 0;
|
||||
virtual int getNumActions() = 0;
|
||||
virtual void enableDetectingBindingMode (int action) = 0;
|
||||
virtual void resetToDefaultBindings() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -171,12 +171,22 @@ namespace MWBase
|
|||
virtual void setWeaponVisibility(bool visible) = 0;
|
||||
virtual void setSpellVisibility(bool visible) = 0;
|
||||
|
||||
virtual void activateQuickKey (int index) = 0;
|
||||
|
||||
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0;
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) = 0;
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) = 0;
|
||||
virtual void unsetSelectedSpell() = 0;
|
||||
virtual void unsetSelectedWeapon() = 0;
|
||||
|
||||
virtual void showCrosshair(bool show) = 0;
|
||||
virtual bool getSubtitlesEnabled() = 0;
|
||||
virtual void toggleHud() = 0;
|
||||
|
||||
virtual void disallowMouse() = 0;
|
||||
virtual void allowMouse() = 0;
|
||||
virtual void notifyInputActionBound() = 0;
|
||||
|
||||
virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
|
||||
///< Hides dialog and schedules dialog to be deleted.
|
||||
|
||||
|
|
|
@ -65,6 +65,12 @@ namespace MWBase
|
|||
Render_Compositors
|
||||
};
|
||||
|
||||
struct DoorMarker
|
||||
{
|
||||
std::string name;
|
||||
float x, y; // world position
|
||||
};
|
||||
|
||||
World() {}
|
||||
|
||||
virtual ~World() {}
|
||||
|
@ -108,6 +114,15 @@ namespace MWBase
|
|||
virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0;
|
||||
///< get north vector (OGRE coordinates) for given interior cell
|
||||
|
||||
virtual std::vector<DoorMarker> getDoorMarkers (MWWorld::CellStore* cell) = 0;
|
||||
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
||||
|
||||
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y) = 0;
|
||||
///< see MWRender::LocalMap::getInteriorMapPosition
|
||||
|
||||
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior) = 0;
|
||||
///< see MWRender::LocalMap::isPositionExplored
|
||||
|
||||
virtual MWWorld::Globals::Data& getGlobalVariable (const std::string& name) = 0;
|
||||
|
||||
virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -63,10 +62,12 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(
|
||||
new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -66,10 +65,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
|
@ -271,9 +271,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -62,12 +61,13 @@ namespace MWClass
|
|||
}
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
@ -222,9 +222,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -88,30 +87,30 @@ namespace MWClass
|
|||
const std::string lockedSound = "LockedChest";
|
||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||
|
||||
|
||||
if (ptr.getCellRef().lockLevel>0)
|
||||
{
|
||||
// TODO check for key
|
||||
std::cout << "Locked container" << std::endl;
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||
action->setSound(lockedSound);
|
||||
return action;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Unlocked container" << std::endl;
|
||||
if(ptr.getCellRef().trap.empty())
|
||||
{
|
||||
// Not trapped, Inventory GUI goes here
|
||||
//return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr));
|
||||
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
||||
action->setSound ("chest open");
|
||||
return action;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Trap activation goes here
|
||||
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||
action->setSound(trapActivationSound);
|
||||
ptr.getCellRef().trap = "";
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ namespace MWClass
|
|||
|
||||
data->mCreatureStats.setLevel(ref->base->data.level);
|
||||
|
||||
data->mCreatureStats.setHello(ref->base->AI.hello);
|
||||
data->mCreatureStats.setFight(ref->base->AI.fight);
|
||||
data->mCreatureStats.setFlee(ref->base->AI.flee);
|
||||
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
|
||||
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
|
||||
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
|
||||
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||
|
||||
// store
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
|
@ -80,17 +79,25 @@ namespace MWClass
|
|||
// TODO check for key
|
||||
// TODO report failure to player (message, sound?). Look up behaviour of original MW.
|
||||
std::cout << "Locked!" << std::endl;
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||
|
||||
action->setSound(lockedSound);
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
if(!ptr.getCellRef().trap.empty())
|
||||
{
|
||||
// Trap activation
|
||||
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0);
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||
|
||||
action->setSound(trapActivationSound);
|
||||
ptr.getCellRef().trap = "";
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
if (ref->ref.teleport)
|
||||
|
@ -99,11 +106,11 @@ namespace MWClass
|
|||
/// \todo remove this if clause once ActionTeleport can also support other actors
|
||||
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
|
||||
MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0);
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
|
||||
|
||||
action->setSound(openSound);
|
||||
|
||||
return action;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,8 +124,11 @@ namespace MWClass
|
|||
// TODO return action for rotating the door
|
||||
|
||||
// This is a little pointless, but helps with testing
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0);
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||
|
||||
action->setSound(openSound);
|
||||
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -62,10 +61,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -94,10 +94,11 @@ namespace MWClass
|
|||
if (!(ref->base->data.flags & ESM::Light::Carry))
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Light::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
@ -191,9 +192,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -64,10 +63,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
@ -160,9 +160,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -67,10 +66,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -100,10 +100,10 @@ namespace MWClass
|
|||
/// \todo do something with npdt12 maybe:p
|
||||
}
|
||||
|
||||
data->mCreatureStats.setHello(ref->base->AI.hello);
|
||||
data->mCreatureStats.setFight(ref->base->AI.fight);
|
||||
data->mCreatureStats.setFlee(ref->base->AI.flee);
|
||||
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
|
||||
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
|
||||
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
|
||||
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||
|
||||
// store
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -64,10 +63,12 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(
|
||||
new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound (getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Potion::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -63,10 +62,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
@ -159,9 +159,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -62,10 +61,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
std::string Repair::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -64,10 +63,11 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
|
@ -360,9 +360,11 @@ namespace MWClass
|
|||
|
||||
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||
action->setSound(getUpSoundId(ptr));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
|
|
|
@ -769,14 +769,14 @@ namespace MWDialogue
|
|||
if (mActor.getTypeName() == typeid(ESM::NPC).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>();
|
||||
if (ref->base->hasAI)
|
||||
services = ref->base->AI.services;
|
||||
if (ref->base->mHasAI)
|
||||
services = ref->base->mAiData.mServices;
|
||||
}
|
||||
else if (mActor.getTypeName() == typeid(ESM::Creature).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>();
|
||||
if (ref->base->hasAI)
|
||||
services = ref->base->AI.services;
|
||||
if (ref->base->mHasAI)
|
||||
services = ref->base->mAiData.mServices;
|
||||
}
|
||||
|
||||
if (services & ESM::NPC::Weapon
|
||||
|
|
|
@ -65,9 +65,9 @@ void BirthDialog::setNextButtonShow(bool shown)
|
|||
|
||||
void BirthDialog::open()
|
||||
{
|
||||
WindowBase::open();
|
||||
updateBirths();
|
||||
updateSpells();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MWGui
|
|||
void setBirthId(const std::string &raceId);
|
||||
|
||||
void setNextButtonShow(bool shown);
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
|
|
@ -194,7 +194,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mNameDialog->setTextInput(mPlayerName);
|
||||
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
|
||||
mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
|
||||
mNameDialog->open();
|
||||
mNameDialog->setVisible(true);
|
||||
break;
|
||||
|
||||
case GM_Race:
|
||||
|
@ -205,7 +205,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mRaceDialog->setRaceId(mPlayerRaceId);
|
||||
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||
mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
|
||||
mRaceDialog->open();
|
||||
mRaceDialog->setVisible(true);;
|
||||
break;
|
||||
|
||||
case GM_Class:
|
||||
|
@ -213,7 +213,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mClassChoiceDialog = 0;
|
||||
mClassChoiceDialog = new ClassChoiceDialog(*mWM);
|
||||
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
||||
mClassChoiceDialog->open();
|
||||
mClassChoiceDialog->setVisible(true);
|
||||
break;
|
||||
|
||||
case GM_ClassPick:
|
||||
|
@ -224,7 +224,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mPickClassDialog->setClassId(mPlayerClass.name);
|
||||
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
||||
mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
|
||||
mPickClassDialog->open();
|
||||
mPickClassDialog->setVisible(true);
|
||||
break;
|
||||
|
||||
case GM_Birth:
|
||||
|
@ -234,7 +234,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
|
||||
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
||||
mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
|
||||
mBirthSignDialog->open();
|
||||
mBirthSignDialog->setVisible(true);
|
||||
break;
|
||||
|
||||
case GM_ClassCreate:
|
||||
|
@ -244,7 +244,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
||||
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
||||
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
||||
mCreateClassDialog->open();
|
||||
mCreateClassDialog->setVisible(true);
|
||||
break;
|
||||
case GM_ClassGenerate:
|
||||
mGenerateClassStep = 0;
|
||||
|
@ -289,7 +289,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||
mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
|
||||
mReviewDialog->open();
|
||||
mReviewDialog->setVisible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ void CharacterCreation::showClassQuestionDialog()
|
|||
mGenerateClassResultDialog->setClassId(mGenerateClass);
|
||||
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
||||
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
||||
mGenerateClassResultDialog->open();
|
||||
mGenerateClassResultDialog->setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ void CharacterCreation::showClassQuestionDialog()
|
|||
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
|
||||
mGenerateClassQuestionDialog->setButtons(buttons);
|
||||
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
|
||||
mGenerateClassQuestionDialog->open();
|
||||
mGenerateClassQuestionDialog->setVisible(true);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound);
|
||||
}
|
||||
|
|
|
@ -46,11 +46,6 @@ GenerateClassResultDialog::GenerateClassResultDialog(MWBase::WindowManager& parW
|
|||
backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23);
|
||||
}
|
||||
|
||||
void GenerateClassResultDialog::open()
|
||||
{
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
std::string GenerateClassResultDialog::getClassId() const
|
||||
{
|
||||
return mClassName->getCaption();
|
||||
|
@ -143,7 +138,6 @@ void PickClassDialog::open()
|
|||
{
|
||||
updateClasses();
|
||||
updateStats();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -341,7 +335,6 @@ void InfoBoxDialog::open()
|
|||
layoutVertically(mMainWidget, 4 + 6);
|
||||
|
||||
center();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
int InfoBoxDialog::getChosenButton() const
|
||||
|
@ -549,11 +542,6 @@ void CreateClassDialog::setNextButtonShow(bool shown)
|
|||
descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23);
|
||||
}
|
||||
|
||||
void CreateClassDialog::open()
|
||||
{
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
||||
void CreateClassDialog::onDialogCancel()
|
||||
|
@ -695,7 +683,7 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
|||
/* SelectSpecializationDialog */
|
||||
|
||||
SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_chargen_select_specialization.layout", parWindowManager)
|
||||
: WindowModal("openmw_chargen_select_specialization.layout", parWindowManager)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
@ -727,13 +715,10 @@ SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& pa
|
|||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
||||
int buttonWidth = cancelButton->getTextSize().width + 24;
|
||||
cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21);
|
||||
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
SelectSpecializationDialog::~SelectSpecializationDialog()
|
||||
{
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -760,7 +745,7 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender)
|
|||
/* SelectAttributeDialog */
|
||||
|
||||
SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_chargen_select_attribute.layout", parWindowManager)
|
||||
: WindowModal("openmw_chargen_select_attribute.layout", parWindowManager)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
@ -785,13 +770,10 @@ SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowMan
|
|||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
||||
int buttonWidth = cancelButton->getTextSize().width + 24;
|
||||
cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21);
|
||||
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
SelectAttributeDialog::~SelectAttributeDialog()
|
||||
{
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -812,7 +794,7 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender)
|
|||
/* SelectSkillDialog */
|
||||
|
||||
SelectSkillDialog::SelectSkillDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_chargen_select_skill.layout", parWindowManager)
|
||||
: WindowModal("openmw_chargen_select_skill.layout", parWindowManager)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
@ -884,12 +866,10 @@ SelectSkillDialog::SelectSkillDialog(MWBase::WindowManager& parWindowManager)
|
|||
int buttonWidth = cancelButton->getTextSize().width + 24;
|
||||
cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21);
|
||||
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
SelectSkillDialog::~SelectSkillDialog()
|
||||
{
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -908,7 +888,7 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender)
|
|||
/* DescriptionDialog */
|
||||
|
||||
DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_chargen_class_description.layout", parWindowManager)
|
||||
: WindowModal("openmw_chargen_class_description.layout", parWindowManager)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
@ -924,13 +904,10 @@ DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
// Make sure the edit box has focus
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
|
||||
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
DescriptionDialog::~DescriptionDialog()
|
||||
{
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace MWGui
|
|||
std::string getText() const;
|
||||
void setButtons(ButtonList &buttons);
|
||||
|
||||
void open();
|
||||
virtual void open();
|
||||
int getChosenButton() const;
|
||||
|
||||
// Events
|
||||
|
@ -74,8 +74,6 @@ namespace MWGui
|
|||
std::string getClassId() const;
|
||||
void setClassId(const std::string &classId);
|
||||
|
||||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
|
@ -104,7 +102,7 @@ namespace MWGui
|
|||
void setClassId(const std::string &classId);
|
||||
|
||||
void setNextButtonShow(bool shown);
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
@ -134,7 +132,7 @@ namespace MWGui
|
|||
std::string mCurrentClassId;
|
||||
};
|
||||
|
||||
class SelectSpecializationDialog : public WindowBase
|
||||
class SelectSpecializationDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
SelectSpecializationDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -165,7 +163,7 @@ namespace MWGui
|
|||
ESM::Class::Specialization mSpecializationId;
|
||||
};
|
||||
|
||||
class SelectAttributeDialog : public WindowBase
|
||||
class SelectAttributeDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
SelectAttributeDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -198,7 +196,7 @@ namespace MWGui
|
|||
ESM::Attribute::AttributeID mAttributeId;
|
||||
};
|
||||
|
||||
class SelectSkillDialog : public WindowBase
|
||||
class SelectSkillDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
SelectSkillDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -234,7 +232,7 @@ namespace MWGui
|
|||
ESM::Skill::SkillEnum mSkillId;
|
||||
};
|
||||
|
||||
class DescriptionDialog : public WindowBase
|
||||
class DescriptionDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
DescriptionDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -264,7 +262,6 @@ namespace MWGui
|
|||
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
|
||||
|
||||
void setNextButtonShow(bool shown);
|
||||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace MWGui
|
||||
{
|
||||
ConfirmationDialog::ConfirmationDialog(MWBase::WindowManager& parWindowManager) :
|
||||
WindowBase("openmw_confirmation_dialog.layout", parWindowManager)
|
||||
WindowModal("openmw_confirmation_dialog.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mMessage, "Message");
|
||||
getWidget(mOkButton, "OkButton");
|
||||
|
@ -32,9 +32,6 @@ namespace MWGui
|
|||
|
||||
center();
|
||||
|
||||
// make other gui elements inaccessible while this dialog is open
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
|
||||
int okButtonWidth = mOkButton->getTextSize().width + 24;
|
||||
mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth,
|
||||
mOkButton->getTop(),
|
||||
|
@ -52,19 +49,13 @@ namespace MWGui
|
|||
{
|
||||
eventCancelClicked();
|
||||
|
||||
close();
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
eventOkClicked();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void ConfirmationDialog::close()
|
||||
{
|
||||
setVisible(false);
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class ConfirmationDialog : public WindowBase
|
||||
class ConfirmationDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
ConfirmationDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -26,8 +26,6 @@ namespace MWGui
|
|||
|
||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace MWGui
|
||||
{
|
||||
CountDialog::CountDialog(MWBase::WindowManager& parWindowManager) :
|
||||
WindowBase("openmw_count_window.layout", parWindowManager)
|
||||
WindowModal("openmw_count_window.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mSlider, "CountSlider");
|
||||
getWidget(mItemEdit, "ItemEdit");
|
||||
|
@ -40,9 +40,6 @@ namespace MWGui
|
|||
width,
|
||||
mMainWidget->getHeight());
|
||||
|
||||
// make other gui elements inaccessible while this dialog is open
|
||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
||||
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(mItemEdit);
|
||||
|
||||
mSlider->setScrollPosition(maxCount-1);
|
||||
|
@ -63,14 +60,14 @@ namespace MWGui
|
|||
|
||||
void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
close();
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
eventOkClicked(NULL, mSlider->getScrollPosition()+1);
|
||||
|
||||
close();
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void CountDialog::onEditTextChange(MyGUI::EditBox* _sender)
|
||||
|
@ -99,10 +96,4 @@ namespace MWGui
|
|||
{
|
||||
mItemEdit->setCaption(boost::lexical_cast<std::string>(_position+1));
|
||||
}
|
||||
|
||||
void CountDialog::close()
|
||||
{
|
||||
setVisible(false);
|
||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class CountDialog : public WindowBase
|
||||
class CountDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
CountDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
@ -30,8 +30,6 @@ namespace MWGui
|
|||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onEditTextChange(MyGUI::EditBox* _sender);
|
||||
void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position);
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ using namespace MWGui;
|
|||
|
||||
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
||||
: Layout("openmw_hud.layout")
|
||||
, health(NULL)
|
||||
, magicka(NULL)
|
||||
, stamina(NULL)
|
||||
, mHealth(NULL)
|
||||
, mMagicka(NULL)
|
||||
, mStamina(NULL)
|
||||
, mWeapImage(NULL)
|
||||
, mSpellImage(NULL)
|
||||
, mWeapStatus(NULL)
|
||||
|
@ -36,10 +36,10 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
, mMinimap(NULL)
|
||||
, mCompass(NULL)
|
||||
, mCrosshair(NULL)
|
||||
, fpsbox(NULL)
|
||||
, fpscounter(NULL)
|
||||
, trianglecounter(NULL)
|
||||
, batchcounter(NULL)
|
||||
, mFpsBox(NULL)
|
||||
, mFpsCounter(NULL)
|
||||
, mTriangleCounter(NULL)
|
||||
, mBatchCounter(NULL)
|
||||
, mHealthManaStaminaBaseLeft(0)
|
||||
, mWeapBoxBaseLeft(0)
|
||||
, mSpellBoxBaseLeft(0)
|
||||
|
@ -57,10 +57,9 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
|
||||
// Energy bars
|
||||
getWidget(mHealthFrame, "HealthFrame");
|
||||
getWidget(health, "Health");
|
||||
getWidget(magicka, "Magicka");
|
||||
getWidget(stamina, "Stamina");
|
||||
|
||||
getWidget(mHealth, "Health");
|
||||
getWidget(mMagicka, "Magicka");
|
||||
getWidget(mStamina, "Stamina");
|
||||
mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
|
||||
|
||||
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
|
||||
|
@ -93,9 +92,10 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
|
||||
getWidget(mMinimapBox, "MiniMapBox");
|
||||
mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
|
||||
mMinimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
||||
getWidget(mMinimap, "MiniMap");
|
||||
getWidget(mCompass, "Compass");
|
||||
getWidget(mMinimapButton, "MiniMapButton");
|
||||
mMinimapButton->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
||||
|
||||
getWidget(mCellNameBox, "CellName");
|
||||
getWidget(mWeaponSpellBox, "WeaponSpellName");
|
||||
|
@ -104,8 +104,8 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
|
||||
setFpsLevel(fpsLevel);
|
||||
|
||||
getWidget(trianglecounter, "TriangleCounter");
|
||||
getWidget(batchcounter, "BatchCounter");
|
||||
getWidget(mTriangleCounter, "TriangleCounter");
|
||||
getWidget(mBatchCounter, "BatchCounter");
|
||||
|
||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||
|
||||
|
@ -118,7 +118,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
|
||||
void HUD::setFpsLevel(int level)
|
||||
{
|
||||
fpscounter = 0;
|
||||
mFpsCounter = 0;
|
||||
|
||||
MyGUI::Widget* fps;
|
||||
getWidget(fps, "FPSBoxAdv");
|
||||
|
@ -128,32 +128,32 @@ void HUD::setFpsLevel(int level)
|
|||
|
||||
if (level == 2)
|
||||
{
|
||||
getWidget(fpsbox, "FPSBoxAdv");
|
||||
fpsbox->setVisible(true);
|
||||
getWidget(fpscounter, "FPSCounterAdv");
|
||||
getWidget(mFpsBox, "FPSBoxAdv");
|
||||
mFpsBox->setVisible(true);
|
||||
getWidget(mFpsCounter, "FPSCounterAdv");
|
||||
}
|
||||
else if (level == 1)
|
||||
{
|
||||
getWidget(fpsbox, "FPSBox");
|
||||
fpsbox->setVisible(true);
|
||||
getWidget(fpscounter, "FPSCounter");
|
||||
getWidget(mFpsBox, "FPSBox");
|
||||
mFpsBox->setVisible(true);
|
||||
getWidget(mFpsCounter, "FPSCounter");
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::setFPS(float fps)
|
||||
{
|
||||
if (fpscounter)
|
||||
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||
if (mFpsCounter)
|
||||
mFpsCounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||
}
|
||||
|
||||
void HUD::setTriangleCount(unsigned int count)
|
||||
{
|
||||
trianglecounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
mTriangleCounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setBatchCount(unsigned int count)
|
||||
{
|
||||
batchcounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
mBatchCounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setEffect(const char *img)
|
||||
|
@ -176,20 +176,20 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
health->setProgressRange (value.getModified());
|
||||
health->setProgressPosition (value.getCurrent());
|
||||
mHealth->setProgressRange (value.getModified());
|
||||
mHealth->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "HealthFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
||||
break;
|
||||
case 1:
|
||||
magicka->setProgressRange (value.getModified());
|
||||
magicka->setProgressPosition (value.getCurrent());
|
||||
mMagicka->setProgressRange (value.getModified());
|
||||
mMagicka->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "MagickaFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
|
||||
break;
|
||||
case 2:
|
||||
stamina->setProgressRange (value.getModified());
|
||||
stamina->setProgressPosition (value.getCurrent());
|
||||
mStamina->setProgressRange (value.getModified());
|
||||
mStamina->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "FatigueFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
||||
break;
|
||||
|
@ -197,46 +197,11 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||
}
|
||||
}
|
||||
|
||||
void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible)
|
||||
{
|
||||
int weapDx = 0, spellDx = 0;
|
||||
if (!hmsVisible)
|
||||
spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft;
|
||||
|
||||
if (!weapVisible)
|
||||
spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft;
|
||||
|
||||
mWeaponVisible = weapVisible;
|
||||
mSpellVisible = spellVisible;
|
||||
if (!mWeaponVisible && !mSpellVisible)
|
||||
mWeaponSpellBox->setVisible(false);
|
||||
|
||||
health->setVisible(hmsVisible);
|
||||
stamina->setVisible(hmsVisible);
|
||||
magicka->setVisible(hmsVisible);
|
||||
mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop());
|
||||
mWeapBox->setVisible(weapVisible);
|
||||
mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop());
|
||||
mSpellBox->setVisible(spellVisible);
|
||||
}
|
||||
|
||||
void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible)
|
||||
{
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
||||
// effect box can have variable width -> variable left coordinate
|
||||
int effectsDx = 0;
|
||||
if (!minimapBoxVisible)
|
||||
effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
|
||||
|
||||
mMapVisible = minimapBoxVisible;
|
||||
mMinimapBox->setVisible(minimapBoxVisible);
|
||||
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
||||
mEffectBox->setVisible(effectBoxVisible);
|
||||
}
|
||||
|
||||
void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (!MWBase::Environment::get().getWindowManager ()->isGuiMode ())
|
||||
return;
|
||||
|
||||
if (mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
// drop item into the gameworld
|
||||
|
@ -517,3 +482,68 @@ void HUD::unsetSelectedWeapon()
|
|||
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
||||
mWeapBox->clearUserStrings();
|
||||
}
|
||||
|
||||
void HUD::setCrosshairVisible(bool visible)
|
||||
{
|
||||
mCrosshair->setVisible (visible);
|
||||
}
|
||||
|
||||
void HUD::setHmsVisible(bool visible)
|
||||
{
|
||||
mHealth->setVisible(visible);
|
||||
mMagicka->setVisible(visible);
|
||||
mStamina->setVisible(visible);
|
||||
updatePositions();
|
||||
}
|
||||
|
||||
void HUD::setWeapVisible(bool visible)
|
||||
{
|
||||
mWeapBox->setVisible(visible);
|
||||
updatePositions();
|
||||
}
|
||||
|
||||
void HUD::setSpellVisible(bool visible)
|
||||
{
|
||||
mSpellBox->setVisible(visible);
|
||||
updatePositions();
|
||||
}
|
||||
|
||||
void HUD::setEffectVisible(bool visible)
|
||||
{
|
||||
mEffectBox->setVisible (visible);
|
||||
updatePositions();
|
||||
}
|
||||
|
||||
void HUD::setMinimapVisible(bool visible)
|
||||
{
|
||||
mMinimapBox->setVisible (visible);
|
||||
updatePositions();
|
||||
}
|
||||
|
||||
void HUD::updatePositions()
|
||||
{
|
||||
int weapDx = 0, spellDx = 0;
|
||||
if (!mHealth->getVisible())
|
||||
spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft;
|
||||
|
||||
if (!mWeapBox->getVisible())
|
||||
spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft;
|
||||
|
||||
mWeaponVisible = mWeapBox->getVisible();
|
||||
mSpellVisible = mSpellBox->getVisible();
|
||||
if (!mWeaponVisible && !mSpellVisible)
|
||||
mWeaponSpellBox->setVisible(false);
|
||||
|
||||
mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop());
|
||||
mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop());
|
||||
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
||||
// effect box can have variable width -> variable left coordinate
|
||||
int effectsDx = 0;
|
||||
if (!mMinimapBox->getVisible ())
|
||||
effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
|
||||
|
||||
mMapVisible = mMinimapBox->getVisible ();
|
||||
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
||||
}
|
||||
|
|
|
@ -18,8 +18,14 @@ namespace MWGui
|
|||
void setFPS(float fps);
|
||||
void setTriangleCount(unsigned int count);
|
||||
void setBatchCount(unsigned int count);
|
||||
void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible);
|
||||
void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible);
|
||||
|
||||
void setHmsVisible(bool visible);
|
||||
void setWeapVisible(bool visible);
|
||||
void setSpellVisible(bool visible);
|
||||
|
||||
void setEffectVisible(bool visible);
|
||||
void setMinimapVisible(bool visible);
|
||||
|
||||
void setFpsLevel(const int level);
|
||||
|
||||
void setSelectedSpell(const std::string& spellId, int successChancePercent);
|
||||
|
@ -28,6 +34,8 @@ namespace MWGui
|
|||
void unsetSelectedSpell();
|
||||
void unsetSelectedWeapon();
|
||||
|
||||
void setCrosshairVisible(bool visible);
|
||||
|
||||
void onFrame(float dt);
|
||||
void onResChange(int width, int height);
|
||||
|
||||
|
@ -35,12 +43,14 @@ namespace MWGui
|
|||
|
||||
bool getWorldMouseOver() { return mWorldMouseOver; }
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
private:
|
||||
MyGUI::ProgressPtr mHealth, mMagicka, mStamina;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
MyGUI::Widget *mWeapBox, *mSpellBox;
|
||||
MyGUI::ImageBox *mWeapImage, *mSpellImage;
|
||||
MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
|
||||
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||
MyGUI::Button* mMinimapButton;
|
||||
MyGUI::ImageBox* mEffect1;
|
||||
MyGUI::ScrollView* mMinimap;
|
||||
MyGUI::ImageBox* mCompass;
|
||||
|
@ -48,12 +58,13 @@ namespace MWGui
|
|||
MyGUI::TextBox* mCellNameBox;
|
||||
MyGUI::TextBox* mWeaponSpellBox;
|
||||
|
||||
MyGUI::WidgetPtr fpsbox;
|
||||
MyGUI::TextBox* fpscounter;
|
||||
MyGUI::TextBox* trianglecounter;
|
||||
MyGUI::TextBox* batchcounter;
|
||||
MyGUI::Widget* mDummy;
|
||||
|
||||
MyGUI::WidgetPtr mFpsBox;
|
||||
MyGUI::TextBox* mFpsCounter;
|
||||
MyGUI::TextBox* mTriangleCounter;
|
||||
MyGUI::TextBox* mBatchCounter;
|
||||
|
||||
private:
|
||||
// bottom left elements
|
||||
int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft;
|
||||
// bottom right elements
|
||||
|
@ -81,5 +92,7 @@ namespace MWGui
|
|||
void onWeaponClicked(MyGUI::Widget* _sender);
|
||||
void onMagicClicked(MyGUI::Widget* _sender);
|
||||
void onMapClicked(MyGUI::Widget* _sender);
|
||||
|
||||
void updatePositions();
|
||||
};
|
||||
}
|
||||
|
|
45
apps/openmw/mwgui/itemselection.cpp
Normal file
45
apps/openmw/mwgui/itemselection.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "itemselection.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
ItemSelectionDialog::ItemSelectionDialog(const std::string &label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager)
|
||||
: ContainerBase(NULL)
|
||||
, WindowModal("openmw_itemselection_dialog.layout", parWindowManager)
|
||||
{
|
||||
mFilter = filter;
|
||||
|
||||
MyGUI::ScrollView* itemView;
|
||||
MyGUI::Widget* containerWidget;
|
||||
getWidget(containerWidget, "Items");
|
||||
getWidget(itemView, "ItemView");
|
||||
setWidgets(containerWidget, itemView);
|
||||
|
||||
MyGUI::TextBox* l;
|
||||
getWidget(l, "Label");
|
||||
l->setCaptionWithReplacing (label);
|
||||
|
||||
MyGUI::Button* cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
||||
|
||||
int dx = (cancelButton->getTextSize().width + 24) - cancelButton->getWidth();
|
||||
cancelButton->setCoord(cancelButton->getLeft() - dx,
|
||||
cancelButton->getTop(),
|
||||
cancelButton->getTextSize ().width + 24,
|
||||
cancelButton->getHeight());
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::onSelectedItemImpl(MWWorld::Ptr item)
|
||||
{
|
||||
eventItemSelected(item);
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
eventDialogCanceled();
|
||||
}
|
||||
|
||||
}
|
28
apps/openmw/mwgui/itemselection.hpp
Normal file
28
apps/openmw/mwgui/itemselection.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "container.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemSelectionDialog : public ContainerBase, public WindowModal
|
||||
{
|
||||
public:
|
||||
ItemSelectionDialog(const std::string& label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager);
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item;
|
||||
|
||||
EventHandle_Item eventItemSelected;
|
||||
EventHandle_Void eventDialogCanceled;
|
||||
|
||||
|
||||
private:
|
||||
virtual void onReferenceUnavailable() { ; }
|
||||
|
||||
virtual void onSelectedItemImpl(MWWorld::Ptr item);
|
||||
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
};
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ namespace MWGui
|
|||
{
|
||||
public:
|
||||
JournalWindow(MWBase::WindowManager& parWindowManager);
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
virtual void setVisible(bool visible); // only used to play close sound
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "map_window.hpp"
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <OgreVector2.h>
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
LocalMapBase::LocalMapBase()
|
||||
|
@ -89,13 +93,34 @@ void LocalMapBase::applyFogOfWar()
|
|||
}
|
||||
}
|
||||
|
||||
void LocalMapBase::onMarkerFocused (MyGUI::Widget* w1, MyGUI::Widget* w2)
|
||||
{
|
||||
applyFogOfWar ();
|
||||
}
|
||||
|
||||
void LocalMapBase::onMarkerUnfocused (MyGUI::Widget* w1, MyGUI::Widget* w2)
|
||||
{
|
||||
applyFogOfWar ();
|
||||
}
|
||||
|
||||
void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||
{
|
||||
if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell
|
||||
|
||||
// clear all previous markers
|
||||
for (unsigned int i=0; i< mLocalMap->getChildCount(); ++i)
|
||||
{
|
||||
if (mLocalMap->getChildAt(i)->getName ().substr (0, 6) == "Marker")
|
||||
{
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mLocalMap->getChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int mx=0; mx<3; ++mx)
|
||||
{
|
||||
for (int my=0; my<3; ++my)
|
||||
{
|
||||
// map
|
||||
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
|
||||
+ boost::lexical_cast<std::string>(y + (interior ? (my-1) : -1*(my-1)));
|
||||
|
||||
|
@ -108,12 +133,78 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
|||
box->setImageTexture(image);
|
||||
else
|
||||
box->setImageTexture("black.png");
|
||||
|
||||
|
||||
// door markers
|
||||
|
||||
// interior map only consists of one cell, so handle the markers only once
|
||||
if (interior && (mx != 2 || my != 2))
|
||||
continue;
|
||||
|
||||
MWWorld::CellStore* cell;
|
||||
if (interior)
|
||||
cell = MWBase::Environment::get().getWorld ()->getInterior (mPrefix);
|
||||
else
|
||||
cell = MWBase::Environment::get().getWorld ()->getExterior (x+mx-1, y-(my-1));
|
||||
|
||||
std::vector<MWBase::World::DoorMarker> doors = MWBase::Environment::get().getWorld ()->getDoorMarkers (cell);
|
||||
|
||||
for (std::vector<MWBase::World::DoorMarker>::iterator it = doors.begin(); it != doors.end(); ++it)
|
||||
{
|
||||
MWBase::World::DoorMarker marker = *it;
|
||||
|
||||
// convert world coordinates to normalized cell coordinates
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
float nX,nY;
|
||||
int cellDx, cellDy;
|
||||
if (!interior)
|
||||
{
|
||||
const int cellSize = 8192;
|
||||
|
||||
nX = (marker.x - cellSize * (x+mx-1)) / cellSize;
|
||||
nY = 1 - (marker.y - cellSize * (y-(my-1))) / cellSize;
|
||||
|
||||
widgetCoord = MyGUI::IntCoord(nX * 512 - 4 + mx * 512, nY * 512 - 4 + my * 512, 8, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ogre::Vector2 position (marker.x, -marker.y);
|
||||
MWBase::Environment::get().getWorld ()->getInteriorMapPosition (position, nX, nY, cellDx, cellDy);
|
||||
|
||||
widgetCoord = MyGUI::IntCoord(nX * 512 - 4 + (1+cellDx-x) * 512, nY * 512 - 4 + (1+cellDy-y) * 512, 8, 8);
|
||||
}
|
||||
|
||||
static int counter = 0;
|
||||
++counter;
|
||||
MyGUI::Button* markerWidget = mLocalMap->createWidget<MyGUI::Button>("ButtonImage",
|
||||
widgetCoord, MyGUI::Align::Default, "Marker" + boost::lexical_cast<std::string>(counter));
|
||||
markerWidget->setImageResource("DoorMarker");
|
||||
markerWidget->setUserString("ToolTipType", "Layout");
|
||||
markerWidget->setUserString("ToolTipLayout", "TextToolTip");
|
||||
markerWidget->setUserString("Caption_Text", marker.name);
|
||||
markerWidget->setUserString("IsMarker", "true");
|
||||
markerWidget->eventMouseSetFocus += MyGUI::newDelegate(this, &LocalMapBase::onMarkerFocused);
|
||||
markerWidget->eventMouseLostFocus += MyGUI::newDelegate(this, &LocalMapBase::onMarkerUnfocused);
|
||||
|
||||
MarkerPosition markerPos;
|
||||
markerPos.interior = interior;
|
||||
markerPos.cellX = interior ? cellDx : x + mx - 1;
|
||||
markerPos.cellY = interior ? cellDy : y + ((my - 1)*-1);
|
||||
markerPos.nX = nX;
|
||||
markerPos.nY = nY;
|
||||
|
||||
markerWidget->setUserData(markerPos);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
mInterior = interior;
|
||||
mCurX = x;
|
||||
mCurY = y;
|
||||
mChanged = false;
|
||||
|
||||
// fog of war
|
||||
applyFogOfWar();
|
||||
|
||||
// set the compass texture again, because MyGUI determines sorting of ImageBox widgets
|
||||
|
|
|
@ -18,6 +18,15 @@ namespace MWGui
|
|||
|
||||
void toggleFogOfWar();
|
||||
|
||||
struct MarkerPosition
|
||||
{
|
||||
bool interior;
|
||||
int cellX;
|
||||
int cellY;
|
||||
float nX;
|
||||
float nY;
|
||||
};
|
||||
|
||||
protected:
|
||||
int mCurX, mCurY;
|
||||
bool mInterior;
|
||||
|
@ -32,6 +41,9 @@ namespace MWGui
|
|||
|
||||
void applyFogOfWar();
|
||||
|
||||
void onMarkerFocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
|
||||
void onMarkerUnfocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
|
||||
|
||||
OEngine::GUI::Layout* mLayout;
|
||||
|
||||
bool mMapDragAndDrop;
|
||||
|
|
|
@ -32,7 +32,9 @@ namespace MWGui
|
|||
GM_Review,
|
||||
|
||||
// interactive MessageBox
|
||||
GM_InterMessageBox
|
||||
GM_InterMessageBox,
|
||||
|
||||
GM_QuickKeysMenu
|
||||
};
|
||||
|
||||
// Windows shown in inventory mode
|
||||
|
|
630
apps/openmw/mwgui/quickkeysmenu.cpp
Normal file
630
apps/openmw/mwgui/quickkeysmenu.cpp
Normal file
|
@ -0,0 +1,630 @@
|
|||
#include "quickkeysmenu.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/actionequip.hpp"
|
||||
#include "../mwmechanics/spells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/spellsuccess.hpp"
|
||||
#include "../mwgui/inventorywindow.hpp"
|
||||
#include "../mwgui/bookwindow.hpp"
|
||||
#include "../mwgui/scrollwindow.hpp"
|
||||
|
||||
#include "windowmanagerimp.hpp"
|
||||
#include "itemselection.hpp"
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
bool sortItems(const MWWorld::Ptr& left, const MWWorld::Ptr& right)
|
||||
{
|
||||
int cmp = MWWorld::Class::get(left).getName(left).compare(
|
||||
MWWorld::Class::get(right).getName(right));
|
||||
return cmp < 0;
|
||||
}
|
||||
|
||||
bool sortSpells(const std::string& left, const std::string& right)
|
||||
{
|
||||
const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left);
|
||||
const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right);
|
||||
|
||||
int cmp = a->name.compare(b->name);
|
||||
return cmp < 0;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
QuickKeysMenu::QuickKeysMenu(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_quickkeys_menu.layout", parWindowManager)
|
||||
, mAssignDialog(0)
|
||||
, mItemSelectionDialog(0)
|
||||
, mMagicSelectionDialog(0)
|
||||
{
|
||||
getWidget(mOkButton, "OKButton");
|
||||
getWidget(mInstructionLabel, "InstructionLabel");
|
||||
|
||||
mMainWidget->setSize(mMainWidget->getWidth(),
|
||||
mMainWidget->getHeight() + (mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight()));
|
||||
|
||||
int okButtonWidth = mOkButton->getTextSize ().width + 24;
|
||||
mOkButton->setCoord(mOkButton->getLeft() - (okButtonWidth - mOkButton->getWidth()),
|
||||
mOkButton->getTop(),
|
||||
okButtonWidth,
|
||||
mOkButton->getHeight());
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked);
|
||||
|
||||
center();
|
||||
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
MyGUI::Button* button;
|
||||
getWidget(button, "QuickKey" + boost::lexical_cast<std::string>(i+1));
|
||||
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
unassign(button, i);
|
||||
|
||||
mQuickKeyButtons.push_back(button);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QuickKeysMenu::~QuickKeysMenu()
|
||||
{
|
||||
delete mAssignDialog;
|
||||
delete mItemSelectionDialog;
|
||||
delete mMagicSelectionDialog;
|
||||
}
|
||||
|
||||
void QuickKeysMenu::unassign(MyGUI::Widget* key, int index)
|
||||
{
|
||||
while (key->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (key->getChildAt(0));
|
||||
|
||||
key->setUserData(Type_Unassigned);
|
||||
|
||||
MyGUI::TextBox* textBox = key->createWidgetReal<MyGUI::TextBox>("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
||||
textBox->setTextAlign (MyGUI::Align::Center);
|
||||
textBox->setCaption (boost::lexical_cast<std::string>(index+1));
|
||||
textBox->setNeedMouseFocus (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onQuickKeyButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
if (sender == mQuickKeyButtons[i] || sender->getParent () == mQuickKeyButtons[i])
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(index != -1);
|
||||
mSelectedIndex = index;
|
||||
|
||||
{
|
||||
// open assign dialog
|
||||
if (!mAssignDialog)
|
||||
mAssignDialog = new QuickKeysMenuAssign(mWindowManager, this);
|
||||
mAssignDialog->setVisible (true);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onOkButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode(GM_QuickKeysMenu);
|
||||
}
|
||||
|
||||
|
||||
void QuickKeysMenu::onItemButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
if (!mItemSelectionDialog )
|
||||
{
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sQuickMenu6}", ContainerBase::Filter_All, mWindowManager);
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItem);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItemCancel);
|
||||
}
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
mItemSelectionDialog->drawItems ();
|
||||
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onMagicButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
if (!mMagicSelectionDialog )
|
||||
{
|
||||
mMagicSelectionDialog = new MagicSelectionDialog(mWindowManager, this);
|
||||
}
|
||||
mMagicSelectionDialog->setVisible(true);
|
||||
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onUnassignButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
unassign(mQuickKeyButtons[mSelectedIndex], mSelectedIndex);
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Item);
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_barter.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(4, 4, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignItemCancel()
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_MagicItem);
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Magic);
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "Spell");
|
||||
frame->setUserString ("Spell", spellId);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
|
||||
// use the icon of the first effect
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
|
||||
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID);
|
||||
std::string path = effect->icon;
|
||||
int slashPos = path.find("\\");
|
||||
path.insert(slashPos+1, "b_");
|
||||
path = std::string("icons\\") + path;
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagicCancel ()
|
||||
{
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::activateQuickKey(int index)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[index-1];
|
||||
|
||||
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
|
||||
if (type == Type_Magic)
|
||||
{
|
||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||
spells.setSelectedSpell(spellId);
|
||||
store.setSelectedEnchantItem(store.end());
|
||||
mWindowManager.setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
||||
}
|
||||
else if (type == Type_Item)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
|
||||
// make sure the item is available
|
||||
if (item.getRefData ().getCount() == 0)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item), std::vector<std::string>());
|
||||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(item).use(item);
|
||||
|
||||
action->execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
|
||||
// this is necessary for books/scrolls: if they are already in the player's inventory,
|
||||
// the "Take" button should not be visible.
|
||||
// NOTE: the take button is "reset" when the window opens, so we can safely do the following
|
||||
// without screwing up future book windows
|
||||
mWindowManager.getBookWindow()->setTakeButtonShow(false);
|
||||
mWindowManager.getScrollWindow()->setTakeButtonShow(false);
|
||||
|
||||
// since we changed equipping status, update the inventory window
|
||||
mWindowManager.getInventoryWindow()->drawItems();
|
||||
}
|
||||
else if (type == Type_MagicItem)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
|
||||
// make sure the item is available
|
||||
if (item.getRefData ().getCount() == 0)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item), std::vector<std::string>());
|
||||
return;
|
||||
}
|
||||
|
||||
// retrieve ContainerStoreIterator to the item
|
||||
MWWorld::ContainerStoreIterator it = store.begin();
|
||||
for (; it != store.end(); ++it)
|
||||
{
|
||||
if (*it == item)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(it != store.end());
|
||||
|
||||
// equip, if it can be equipped
|
||||
if (!MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
||||
{
|
||||
// Note: can't use Class::use here because enchanted scrolls for example would then open the scroll window instead of equipping
|
||||
|
||||
MWWorld::ActionEquip action(item);
|
||||
action.execute (MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ());
|
||||
|
||||
// since we changed equipping status, update the inventory window
|
||||
mWindowManager.getInventoryWindow()->drawItems();
|
||||
}
|
||||
|
||||
store.setSelectedEnchantItem(it);
|
||||
spells.setSelectedSpell("");
|
||||
mWindowManager.setSelectedEnchantItem(item, 100); /// \todo track charge %
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
QuickKeysMenuAssign::QuickKeysMenuAssign (MWBase::WindowManager &parWindowManager, QuickKeysMenu* parent)
|
||||
: WindowModal("openmw_quickkeys_menu_assign.layout", parWindowManager)
|
||||
, mParent(parent)
|
||||
{
|
||||
getWidget(mLabel, "Label");
|
||||
getWidget(mItemButton, "ItemButton");
|
||||
getWidget(mMagicButton, "MagicButton");
|
||||
getWidget(mUnassignButton, "UnassignButton");
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
|
||||
mItemButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onItemButtonClicked);
|
||||
mMagicButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onMagicButtonClicked);
|
||||
mUnassignButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onUnassignButtonClicked);
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onCancelButtonClicked);
|
||||
|
||||
|
||||
int maxWidth = mItemButton->getTextSize ().width + 24;
|
||||
maxWidth = std::max(maxWidth, mMagicButton->getTextSize ().width + 24);
|
||||
maxWidth = std::max(maxWidth, mUnassignButton->getTextSize ().width + 24);
|
||||
maxWidth = std::max(maxWidth, mCancelButton->getTextSize ().width + 24);
|
||||
|
||||
mMainWidget->setSize(maxWidth + 24, mMainWidget->getHeight());
|
||||
mLabel->setSize(maxWidth, mLabel->getHeight());
|
||||
|
||||
mItemButton->setCoord((maxWidth - mItemButton->getTextSize().width-24)/2 + 8,
|
||||
mItemButton->getTop(),
|
||||
mItemButton->getTextSize().width + 24,
|
||||
mItemButton->getHeight());
|
||||
mMagicButton->setCoord((maxWidth - mMagicButton->getTextSize().width-24)/2 + 8,
|
||||
mMagicButton->getTop(),
|
||||
mMagicButton->getTextSize().width + 24,
|
||||
mMagicButton->getHeight());
|
||||
mUnassignButton->setCoord((maxWidth - mUnassignButton->getTextSize().width-24)/2 + 8,
|
||||
mUnassignButton->getTop(),
|
||||
mUnassignButton->getTextSize().width + 24,
|
||||
mUnassignButton->getHeight());
|
||||
mCancelButton->setCoord((maxWidth - mCancelButton->getTextSize().width-24)/2 + 8,
|
||||
mCancelButton->getTop(),
|
||||
mCancelButton->getTextSize().width + 24,
|
||||
mCancelButton->getHeight());
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
MagicSelectionDialog::MagicSelectionDialog(MWBase::WindowManager &parWindowManager, QuickKeysMenu* parent)
|
||||
: WindowModal("openmw_magicselection_dialog.layout", parWindowManager)
|
||||
, mParent(parent)
|
||||
, mWidth(0)
|
||||
, mHeight(0)
|
||||
{
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
getWidget(mMagicList, "MagicList");
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked);
|
||||
|
||||
int dx = (mCancelButton->getTextSize().width + 24) - mCancelButton->getWidth();
|
||||
mCancelButton->setCoord(mCancelButton->getLeft() - dx,
|
||||
mCancelButton->getTop(),
|
||||
mCancelButton->getTextSize ().width + 24,
|
||||
mCancelButton->getHeight());
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::onCancelButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
mParent->onAssignMagicCancel ();
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::open ()
|
||||
{
|
||||
WindowModal::open();
|
||||
|
||||
while (mMagicList->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mMagicList->getChildAt (0));
|
||||
|
||||
mHeight = 0;
|
||||
|
||||
const int spellHeight = 18;
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
|
||||
/// \todo lots of copy&pasted code from SpellWindow
|
||||
|
||||
// retrieve powers & spells, sort by name
|
||||
std::vector<std::string> spellList;
|
||||
|
||||
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||
{
|
||||
spellList.push_back(*it);
|
||||
}
|
||||
|
||||
std::vector<std::string> powers;
|
||||
std::vector<std::string>::iterator it = spellList.begin();
|
||||
while (it != spellList.end())
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it);
|
||||
if (spell->data.type == ESM::Spell::ST_Power)
|
||||
{
|
||||
powers.push_back(*it);
|
||||
it = spellList.erase(it);
|
||||
}
|
||||
else if (spell->data.type == ESM::Spell::ST_Ability
|
||||
|| spell->data.type == ESM::Spell::ST_Blight
|
||||
|| spell->data.type == ESM::Spell::ST_Curse
|
||||
|| spell->data.type == ESM::Spell::ST_Disease)
|
||||
{
|
||||
it = spellList.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
std::sort(powers.begin(), powers.end(), sortSpells);
|
||||
std::sort(spellList.begin(), spellList.end(), sortSpells);
|
||||
|
||||
// retrieve usable magic items & sort
|
||||
std::vector<MWWorld::Ptr> items;
|
||||
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
||||
{
|
||||
std::string enchantId = MWWorld::Class::get(*it).getEnchantment(*it);
|
||||
if (enchantId != "")
|
||||
{
|
||||
// only add items with "Cast once" or "Cast on use"
|
||||
const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId);
|
||||
int type = enchant->data.type;
|
||||
if (type != ESM::Enchantment::CastOnce
|
||||
&& type != ESM::Enchantment::WhenUsed)
|
||||
continue;
|
||||
|
||||
items.push_back(*it);
|
||||
}
|
||||
}
|
||||
std::sort(items.begin(), items.end(), sortItems);
|
||||
|
||||
|
||||
int height = estimateHeight(items.size() + powers.size() + spellList.size());
|
||||
bool scrollVisible = height > mMagicList->getHeight();
|
||||
mWidth = mMagicList->getWidth() - scrollVisible * 18;
|
||||
|
||||
|
||||
// powers
|
||||
addGroup("#{sPowers}", "");
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it)
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it);
|
||||
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
|
||||
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
||||
t->setCaption(spell->name);
|
||||
t->setTextAlign(MyGUI::Align::Left);
|
||||
t->setUserString("ToolTipType", "Spell");
|
||||
t->setUserString("Spell", *it);
|
||||
t->eventMouseWheel += MyGUI::newDelegate(this, &MagicSelectionDialog::onMouseWheel);
|
||||
t->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onSpellSelected);
|
||||
|
||||
mHeight += spellHeight;
|
||||
}
|
||||
|
||||
// other spells
|
||||
addGroup("#{sSpells}", "");
|
||||
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it);
|
||||
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
|
||||
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
||||
t->setCaption(spell->name);
|
||||
t->setTextAlign(MyGUI::Align::Left);
|
||||
t->setUserString("ToolTipType", "Spell");
|
||||
t->setUserString("Spell", *it);
|
||||
t->eventMouseWheel += MyGUI::newDelegate(this, &MagicSelectionDialog::onMouseWheel);
|
||||
t->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onSpellSelected);
|
||||
|
||||
mHeight += spellHeight;
|
||||
}
|
||||
|
||||
|
||||
// enchanted items
|
||||
addGroup("#{sMagicItem}", "");
|
||||
|
||||
for (std::vector<MWWorld::Ptr>::const_iterator it = items.begin(); it != items.end(); ++it)
|
||||
{
|
||||
MWWorld::Ptr item = *it;
|
||||
|
||||
// check if the item is currently equipped (will display in a different color)
|
||||
bool equipped = false;
|
||||
for (int i=0; i < MWWorld::InventoryStore::Slots; ++i)
|
||||
{
|
||||
if (store.getSlot(i) != store.end() && *store.getSlot(i) == item)
|
||||
{
|
||||
equipped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
||||
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
||||
t->setCaption(MWWorld::Class::get(item).getName(item));
|
||||
t->setTextAlign(MyGUI::Align::Left);
|
||||
t->setUserData(item);
|
||||
t->setUserString("ToolTipType", "ItemPtr");
|
||||
t->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onEnchantedItemSelected);
|
||||
t->eventMouseWheel += MyGUI::newDelegate(this, &MagicSelectionDialog::onMouseWheel);
|
||||
|
||||
mHeight += spellHeight;
|
||||
}
|
||||
|
||||
|
||||
mMagicList->setCanvasSize (mWidth, std::max(mMagicList->getHeight(), mHeight));
|
||||
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::addGroup(const std::string &label, const std::string& label2)
|
||||
{
|
||||
if (mMagicList->getChildCount() > 0)
|
||||
{
|
||||
MyGUI::ImageBox* separator = mMagicList->createWidget<MyGUI::ImageBox>("MW_HLine",
|
||||
MyGUI::IntCoord(4, mHeight, mWidth-8, 18),
|
||||
MyGUI::Align::Left | MyGUI::Align::Top);
|
||||
separator->setNeedMouseFocus(false);
|
||||
mHeight += 18;
|
||||
}
|
||||
|
||||
MyGUI::TextBox* groupWidget = mMagicList->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, mHeight, mWidth, 24),
|
||||
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
||||
groupWidget->setCaptionWithReplacing(label);
|
||||
groupWidget->setTextAlign(MyGUI::Align::Left);
|
||||
groupWidget->setNeedMouseFocus(false);
|
||||
|
||||
if (label2 != "")
|
||||
{
|
||||
MyGUI::TextBox* groupWidget2 = mMagicList->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, mHeight, mWidth-4, 24),
|
||||
MyGUI::Align::Left | MyGUI::Align::Top);
|
||||
groupWidget2->setCaptionWithReplacing(label2);
|
||||
groupWidget2->setTextAlign(MyGUI::Align::Right);
|
||||
groupWidget2->setNeedMouseFocus(false);
|
||||
}
|
||||
|
||||
mHeight += 24;
|
||||
}
|
||||
|
||||
|
||||
void MagicSelectionDialog::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||
{
|
||||
if (mMagicList->getViewOffset().top + _rel*0.3 > 0)
|
||||
mMagicList->setViewOffset(MyGUI::IntPoint(0, 0));
|
||||
else
|
||||
mMagicList->setViewOffset(MyGUI::IntPoint(0, mMagicList->getViewOffset().top + _rel*0.3));
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::onEnchantedItemSelected(MyGUI::Widget* _sender)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
||||
|
||||
mParent->onAssignMagicItem (item);
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::onSpellSelected(MyGUI::Widget* _sender)
|
||||
{
|
||||
mParent->onAssignMagic (_sender->getUserString("Spell"));
|
||||
}
|
||||
|
||||
int MagicSelectionDialog::estimateHeight(int numSpells) const
|
||||
{
|
||||
int height = 0;
|
||||
height += 24 * 3 + 18 * 2; // group headings
|
||||
height += numSpells * 18;
|
||||
return height;
|
||||
}
|
||||
|
||||
}
|
107
apps/openmw/mwgui/quickkeysmenu.hpp
Normal file
107
apps/openmw/mwgui/quickkeysmenu.hpp
Normal file
|
@ -0,0 +1,107 @@
|
|||
#ifndef MWGUI_QUICKKEYS_H
|
||||
#define MWGUI_QUICKKEYS_H
|
||||
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class QuickKeysMenuAssign;
|
||||
class ItemSelectionDialog;
|
||||
class MagicSelectionDialog;
|
||||
|
||||
class QuickKeysMenu : public WindowBase
|
||||
{
|
||||
public:
|
||||
QuickKeysMenu(MWBase::WindowManager& parWindowManager);
|
||||
~QuickKeysMenu();
|
||||
|
||||
|
||||
void onItemButtonClicked(MyGUI::Widget* sender);
|
||||
void onMagicButtonClicked(MyGUI::Widget* sender);
|
||||
void onUnassignButtonClicked(MyGUI::Widget* sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void onAssignItem (MWWorld::Ptr item);
|
||||
void onAssignItemCancel ();
|
||||
void onAssignMagicItem (MWWorld::Ptr item);
|
||||
void onAssignMagic (const std::string& spellId);
|
||||
void onAssignMagicCancel ();
|
||||
|
||||
void activateQuickKey(int index);
|
||||
|
||||
enum QuickKeyType
|
||||
{
|
||||
Type_Item,
|
||||
Type_Magic,
|
||||
Type_MagicItem,
|
||||
Type_Unassigned
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
MyGUI::EditBox* mInstructionLabel;
|
||||
MyGUI::Button* mOkButton;
|
||||
|
||||
std::vector<MyGUI::Button*> mQuickKeyButtons;
|
||||
|
||||
QuickKeysMenuAssign* mAssignDialog;
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
MagicSelectionDialog* mMagicSelectionDialog;
|
||||
|
||||
int mSelectedIndex;
|
||||
|
||||
|
||||
void onQuickKeyButtonClicked(MyGUI::Widget* sender);
|
||||
void onOkButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void unassign(MyGUI::Widget* key, int index);
|
||||
};
|
||||
|
||||
class QuickKeysMenuAssign : public WindowModal
|
||||
{
|
||||
public:
|
||||
QuickKeysMenuAssign(MWBase::WindowManager& parWindowManager, QuickKeysMenu* parent);
|
||||
|
||||
private:
|
||||
MyGUI::TextBox* mLabel;
|
||||
MyGUI::Button* mItemButton;
|
||||
MyGUI::Button* mMagicButton;
|
||||
MyGUI::Button* mUnassignButton;
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
||||
QuickKeysMenu* mParent;
|
||||
};
|
||||
|
||||
class MagicSelectionDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
MagicSelectionDialog(MWBase::WindowManager& parWindowManager, QuickKeysMenu* parent);
|
||||
|
||||
virtual void open();
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::ScrollView* mMagicList;
|
||||
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
QuickKeysMenu* mParent;
|
||||
|
||||
void onCancelButtonClicked (MyGUI::Widget* sender);
|
||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void onEnchantedItemSelected(MyGUI::Widget* _sender);
|
||||
void onSpellSelected(MyGUI::Widget* _sender);
|
||||
int estimateHeight(int numSpells) const;
|
||||
|
||||
|
||||
void addGroup(const std::string& label, const std::string& label2);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -113,7 +113,6 @@ void RaceDialog::open()
|
|||
updateRaces();
|
||||
updateSkills();
|
||||
updateSpellPowers();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace MWGui
|
|||
// setHair()
|
||||
|
||||
void setNextButtonShow(bool shown);
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
|
|
@ -110,7 +110,6 @@ ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager)
|
|||
void ReviewDialog::open()
|
||||
{
|
||||
updateSkillArea();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MWGui
|
|||
void configureSkills(const SkillList& major, const SkillList& minor);
|
||||
void setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value);
|
||||
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace MWGui
|
|||
WindowBase("openmw_settings_window.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mOkButton, "OkButton");
|
||||
getWidget(mSubtitlesButton, "SubtitlesButton");
|
||||
getWidget(mCrosshairButton, "CrosshairButton");
|
||||
getWidget(mResolutionList, "ResolutionList");
|
||||
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
|
||||
getWidget(mToolTipDelaySlider, "ToolTipDelaySlider");
|
||||
|
@ -115,7 +117,15 @@ namespace MWGui
|
|||
getWidget(mMiscShadows, "MiscShadows");
|
||||
getWidget(mShadowsDebug, "ShadowsDebug");
|
||||
getWidget(mUnderwaterButton, "UnderwaterButton");
|
||||
getWidget(mControlsBox, "ControlsBox");
|
||||
getWidget(mResetControlsButton, "ResetControlsButton");
|
||||
getWidget(mInvertYButton, "InvertYButton");
|
||||
getWidget(mUISensitivitySlider, "UISensitivitySlider");
|
||||
getWidget(mCameraSensitivitySlider, "CameraSensitivitySlider");
|
||||
|
||||
mSubtitlesButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mCrosshairButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mInvertYButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
|
||||
|
@ -154,6 +164,9 @@ namespace MWGui
|
|||
mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(),
|
||||
okSize, mOkButton->getHeight());
|
||||
|
||||
mResetControlsButton->setSize (mResetControlsButton->getTextSize ().width + 24, mResetControlsButton->getHeight());
|
||||
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
||||
|
||||
// fill resolution list
|
||||
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
|
||||
Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues;
|
||||
|
@ -183,6 +196,9 @@ namespace MWGui
|
|||
int tooltip_delay = (mToolTipDelaySlider->getScrollRange()-1) * Settings::Manager::getFloat("tooltip delay", "GUI");
|
||||
mToolTipDelaySlider->setScrollPosition(tooltip_delay);
|
||||
|
||||
mSubtitlesButton->setCaptionWithReplacing(Settings::Manager::getBool("subtitles", "GUI") ? "#{sOn}" : "#{sOff}");
|
||||
mCrosshairButton->setCaptionWithReplacing(Settings::Manager::getBool("crosshair", "HUD") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
float fovVal = (Settings::Manager::getFloat("field of view", "General")-sFovMin)/(sFovMax-sFovMin);
|
||||
mFOVSlider->setScrollPosition(fovVal * (mFOVSlider->getScrollRange()-1));
|
||||
MyGUI::TextBox* fovText;
|
||||
|
@ -219,6 +235,16 @@ namespace MWGui
|
|||
mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
float cameraSens = (Settings::Manager::getFloat("camera sensitivity", "Input")-0.2)/(5.0-0.2);
|
||||
mCameraSensitivitySlider->setScrollPosition (cameraSens * (mCameraSensitivitySlider->getScrollRange()-1));
|
||||
float uiSens = (Settings::Manager::getFloat("ui sensitivity", "Input")-0.2)/(5.0-0.2);
|
||||
mUISensitivitySlider->setScrollPosition (uiSens * (mUISensitivitySlider->getScrollRange()-1));
|
||||
mCameraSensitivitySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mUISensitivitySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
||||
|
||||
mInvertYButton->setCaptionWithReplacing(Settings::Manager::getBool("invert y axis", "Input") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
std::string shaders;
|
||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||
shaders = "off";
|
||||
|
@ -382,6 +408,12 @@ namespace MWGui
|
|||
Settings::Manager::setBool("misc shadows", "Shadows", newState);
|
||||
else if (_sender == mShadowsDebug)
|
||||
Settings::Manager::setBool("debug", "Shadows", newState);
|
||||
else if (_sender == mInvertYButton)
|
||||
Settings::Manager::setBool("invert y axis", "Input", newState);
|
||||
else if (_sender == mCrosshairButton)
|
||||
Settings::Manager::setBool("crosshair", "HUD", newState);
|
||||
else if (_sender == mSubtitlesButton)
|
||||
Settings::Manager::setBool("subtitles", "GUI", newState);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
@ -499,6 +531,10 @@ namespace MWGui
|
|||
Settings::Manager::setFloat("footsteps volume", "Sound", val);
|
||||
else if (scroller == mMusicVolumeSlider)
|
||||
Settings::Manager::setFloat("music volume", "Sound", val);
|
||||
else if (scroller == mUISensitivitySlider)
|
||||
Settings::Manager::setFloat("ui sensitivity", "Input", (1-val) * 0.2 + val * 5.f);
|
||||
else if (scroller == mCameraSensitivitySlider)
|
||||
Settings::Manager::setFloat("camera sensitivity", "Input", (1-val) * 0.2 + val * 5.f);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
@ -511,4 +547,78 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
|
||||
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
|
||||
}
|
||||
|
||||
void SettingsWindow::updateControlsBox()
|
||||
{
|
||||
while (mControlsBox->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mControlsBox->getChildAt(0));
|
||||
|
||||
std::vector<int> actions = MWBase::Environment::get().getInputManager()->getActionSorting ();
|
||||
|
||||
const int h = 18;
|
||||
const int w = mControlsBox->getWidth() - 28;
|
||||
int curH = 0;
|
||||
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it)
|
||||
{
|
||||
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it);
|
||||
if (desc == "")
|
||||
continue;
|
||||
|
||||
std::string binding = MWBase::Environment::get().getInputManager()->getActionBindingName (*it);
|
||||
|
||||
MyGUI::TextBox* leftText = mControlsBox->createWidget<MyGUI::TextBox>("SandText", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default);
|
||||
leftText->setCaptionWithReplacing(desc);
|
||||
|
||||
MyGUI::Button* rightText = mControlsBox->createWidget<MyGUI::Button>("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default);
|
||||
rightText->setCaptionWithReplacing(binding);
|
||||
rightText->setTextAlign (MyGUI::Align::Right);
|
||||
rightText->setUserData(*it); // save the action id for callbacks
|
||||
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
|
||||
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);
|
||||
curH += h;
|
||||
}
|
||||
|
||||
mControlsBox->setCanvasSize (mControlsBox->getWidth(), std::max(curH, mControlsBox->getHeight()));
|
||||
}
|
||||
|
||||
void SettingsWindow::onRebindAction(MyGUI::Widget* _sender)
|
||||
{
|
||||
int actionId = *_sender->getUserData<int>();
|
||||
|
||||
static_cast<MyGUI::Button*>(_sender)->setCaptionWithReplacing("#{sNone}");
|
||||
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sControlsMenu3}", std::vector<std::string>());
|
||||
MWBase::Environment::get().getWindowManager ()->disallowMouse();
|
||||
|
||||
MWBase::Environment::get().getInputManager ()->enableDetectingBindingMode (actionId);
|
||||
|
||||
}
|
||||
|
||||
void SettingsWindow::onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||
{
|
||||
if (mControlsBox->getViewOffset().top + _rel*0.3 > 0)
|
||||
mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0));
|
||||
else
|
||||
mControlsBox->setViewOffset(MyGUI::IntPoint(0, mControlsBox->getViewOffset().top + _rel*0.3));
|
||||
}
|
||||
|
||||
void SettingsWindow::onResetDefaultBindings(MyGUI::Widget* _sender)
|
||||
{
|
||||
ConfirmationDialog* dialog = mWindowManager.getConfirmationDialog();
|
||||
dialog->open("#{sNotifyMessage66}");
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindingsAccept);
|
||||
dialog->eventCancelClicked.clear();
|
||||
}
|
||||
|
||||
void SettingsWindow::onResetDefaultBindingsAccept()
|
||||
{
|
||||
MWBase::Environment::get().getInputManager ()->resetToDefaultBindings ();
|
||||
updateControlsBox ();
|
||||
}
|
||||
|
||||
void SettingsWindow::open()
|
||||
{
|
||||
updateControlsBox ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@ namespace MWGui
|
|||
public:
|
||||
SettingsWindow(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void updateControlsBox();
|
||||
|
||||
private:
|
||||
static int const sFovMin = 30;
|
||||
static int const sFovMax = 140;
|
||||
|
@ -26,6 +30,8 @@ namespace MWGui
|
|||
|
||||
MyGUI::ScrollBar* mMenuTransparencySlider;
|
||||
MyGUI::ScrollBar* mToolTipDelaySlider;
|
||||
MyGUI::Button* mSubtitlesButton;
|
||||
MyGUI::Button* mCrosshairButton;
|
||||
|
||||
// graphics
|
||||
MyGUI::ListBox* mResolutionList;
|
||||
|
@ -60,6 +66,13 @@ namespace MWGui
|
|||
MyGUI::ScrollBar* mFootstepsVolumeSlider;
|
||||
MyGUI::ScrollBar* mMusicVolumeSlider;
|
||||
|
||||
// controls
|
||||
MyGUI::ScrollView* mControlsBox;
|
||||
MyGUI::Button* mResetControlsButton;
|
||||
MyGUI::Button* mInvertYButton;
|
||||
MyGUI::ScrollBar* mUISensitivitySlider;
|
||||
MyGUI::ScrollBar* mCameraSensitivitySlider;
|
||||
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onFpsToggled(MyGUI::Widget* _sender);
|
||||
void onTextureFilteringToggled(MyGUI::Widget* _sender);
|
||||
|
@ -72,6 +85,11 @@ namespace MWGui
|
|||
void onShadersToggled(MyGUI::Widget* _sender);
|
||||
void onShadowTextureSize(MyGUI::Widget* _sender);
|
||||
|
||||
void onRebindAction(MyGUI::Widget* _sender);
|
||||
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void onResetDefaultBindings(MyGUI::Widget* _sender);
|
||||
void onResetDefaultBindingsAccept ();
|
||||
|
||||
void apply();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/actionequip.hpp"
|
||||
|
||||
#include "../mwmechanics/spells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
@ -350,34 +351,10 @@ namespace MWGui
|
|||
if (_sender->getUserString("Equipped") == "false"
|
||||
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
||||
{
|
||||
// sound
|
||||
MWBase::Environment::get().getSoundManager()->playSound(MWWorld::Class::get(item).getUpSoundId(item), 1.0, 1.0);
|
||||
|
||||
// Note: can't use Class::use here because enchanted scrolls for example would then open the scroll window instead of equipping
|
||||
|
||||
/// \todo the following code is pretty much copy&paste from ActionEquip, put it in a function?
|
||||
// slots that this item can be equipped in
|
||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(item).getEquipmentSlots(item);
|
||||
|
||||
// equip the item in the first free slot
|
||||
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||
slot!=slots.first.end(); ++slot)
|
||||
{
|
||||
// if all slots are occupied, replace the last slot
|
||||
if (slot == --slots.first.end())
|
||||
{
|
||||
store.equip(*slot, it);
|
||||
break;
|
||||
}
|
||||
|
||||
if (store.getSlot(*slot) == store.end())
|
||||
{
|
||||
// slot is not occupied
|
||||
store.equip(*slot, it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// \todo scripts?
|
||||
MWWorld::ActionEquip action(item);
|
||||
action.execute (MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ());
|
||||
|
||||
// since we changed equipping status, update the inventory window
|
||||
mWindowManager.getInventoryWindow()->drawItems();
|
||||
|
|
|
@ -45,7 +45,6 @@ void TextInputDialog::open()
|
|||
{
|
||||
// Make sure the edit box has focus
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace MWGui
|
|||
|
||||
void setNextButtonShow(bool shown);
|
||||
void setTextLabel(const std::string &label);
|
||||
void open();
|
||||
virtual void open();
|
||||
|
||||
protected:
|
||||
void onOkClicked(MyGUI::Widget* _sender);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "map_window.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
@ -150,7 +151,19 @@ void ToolTips::onFrame(float frameDuration)
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if (type == "ItemPtr")
|
||||
|
||||
// special handling for markers on the local map: the tooltip should only be visible
|
||||
// if the marker is not hidden due to the fog of war.
|
||||
if (focus->getUserString ("IsMarker") == "true")
|
||||
{
|
||||
LocalMapBase::MarkerPosition pos = *focus->getUserData<LocalMapBase::MarkerPosition>();
|
||||
|
||||
if (!MWBase::Environment::get().getWorld ()->isPositionExplored (pos.nX, pos.nY, pos.cellX, pos.cellY, pos.interior))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (type == "ItemPtr")
|
||||
{
|
||||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||
tooltipSize = getToolTipViaPtr(false);
|
||||
|
@ -199,7 +212,8 @@ void ToolTips::onFrame(float frameDuration)
|
|||
it != userStrings.end(); ++it)
|
||||
{
|
||||
if (it->first == "ToolTipType"
|
||||
|| it->first == "ToolTipLayout")
|
||||
|| it->first == "ToolTipLayout"
|
||||
|| it->first == "IsMarker")
|
||||
continue;
|
||||
|
||||
|
||||
|
|
|
@ -291,14 +291,14 @@ namespace MWGui
|
|||
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
|
||||
if (ref->base->hasAI)
|
||||
services = ref->base->AI.services;
|
||||
if (ref->base->mHasAI)
|
||||
services = ref->base->mAiData.mServices;
|
||||
}
|
||||
else if (mPtr.getTypeName() == typeid(ESM::Creature).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
|
||||
if (ref->base->hasAI)
|
||||
services = ref->base->AI.services;
|
||||
if (ref->base->mHasAI)
|
||||
services = ref->base->mAiData.mServices;
|
||||
}
|
||||
|
||||
/// \todo what about potions, there doesn't seem to be a flag for them??
|
||||
|
|
|
@ -12,17 +12,15 @@ WindowBase::WindowBase(const std::string& parLayout, MWBase::WindowManager& parW
|
|||
{
|
||||
}
|
||||
|
||||
void WindowBase::open()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowBase::setVisible(bool visible)
|
||||
{
|
||||
bool wasVisible = mMainWidget->getVisible();
|
||||
mMainWidget->setVisible(visible);
|
||||
|
||||
if (!wasVisible && visible)
|
||||
if (visible)
|
||||
open();
|
||||
else if (wasVisible && !visible)
|
||||
close();
|
||||
}
|
||||
|
||||
void WindowBase::center()
|
||||
|
@ -40,3 +38,18 @@ void WindowBase::center()
|
|||
coord.top = (gameWindowSize.height - coord.height)/2;
|
||||
mMainWidget->setCoord(coord);
|
||||
}
|
||||
|
||||
WindowModal::WindowModal(const std::string& parLayout, MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase(parLayout, parWindowManager)
|
||||
{
|
||||
}
|
||||
|
||||
void WindowModal::open()
|
||||
{
|
||||
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
||||
}
|
||||
|
||||
void WindowModal::close()
|
||||
{
|
||||
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ namespace MWGui
|
|||
// Events
|
||||
typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase;
|
||||
|
||||
virtual void open();
|
||||
virtual void setVisible(bool visible); // calls open() if visible is true and was false before
|
||||
virtual void open() {}
|
||||
virtual void close () {}
|
||||
virtual void setVisible(bool visible);
|
||||
void center();
|
||||
|
||||
/** Event : Dialog finished, OK button clicked.\n
|
||||
|
@ -33,6 +34,18 @@ namespace MWGui
|
|||
/// \todo remove
|
||||
MWBase::WindowManager& mWindowManager;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* "Modal" windows cause the rest of the interface to be unaccessible while they are visible
|
||||
*/
|
||||
class WindowModal : public WindowBase
|
||||
{
|
||||
public:
|
||||
WindowModal(const std::string& parLayout, MWBase::WindowManager& parWindowManager);
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "confirmationdialog.hpp"
|
||||
#include "alchemywindow.hpp"
|
||||
#include "spellwindow.hpp"
|
||||
#include "quickkeysmenu.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
|
@ -83,6 +84,9 @@ WindowManager::WindowManager(
|
|||
, mFPS(0.0f)
|
||||
, mTriangleCount(0)
|
||||
, mBatchCount(0)
|
||||
, mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD"))
|
||||
, mSubtitlesEnabled(Settings::Manager::getBool ("subtitles", "GUI"))
|
||||
, mHudEnabled(true)
|
||||
{
|
||||
|
||||
// Set up the GUI system
|
||||
|
@ -133,6 +137,9 @@ WindowManager::WindowManager(
|
|||
mConfirmationDialog = new ConfirmationDialog(*this);
|
||||
mAlchemyWindow = new AlchemyWindow(*this);
|
||||
mSpellWindow = new SpellWindow(*this);
|
||||
mQuickKeysMenu = new QuickKeysMenu(*this);
|
||||
|
||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
|
||||
|
||||
// The HUD is always on
|
||||
mHud->setVisible(true);
|
||||
|
@ -224,17 +231,23 @@ void WindowManager::updateVisible()
|
|||
mSettingsWindow->setVisible(false);
|
||||
mAlchemyWindow->setVisible(false);
|
||||
mSpellWindow->setVisible(false);
|
||||
mQuickKeysMenu->setVisible(false);
|
||||
|
||||
// Mouse is visible whenever we're not in game mode
|
||||
MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
|
||||
|
||||
bool gameMode = !isGuiMode();
|
||||
|
||||
mInputBlocker->setVisible (gameMode);
|
||||
|
||||
if (gameMode)
|
||||
mToolTips->enterGameMode();
|
||||
else
|
||||
mToolTips->enterGuiMode();
|
||||
|
||||
if (gameMode)
|
||||
MyGUI::InputManager::getInstance ().setKeyFocusWidget (NULL);
|
||||
|
||||
setMinimapVisibility((mAllowed & GW_Map) && !mMap->pinned());
|
||||
setWeaponVisibility((mAllowed & GW_Inventory) && !mInventoryWindow->pinned());
|
||||
setSpellVisibility((mAllowed & GW_Magic) && !mSpellWindow->pinned());
|
||||
|
@ -247,6 +260,9 @@ void WindowManager::updateVisible()
|
|||
GuiMode mode = mGuiModes.back();
|
||||
|
||||
switch(mode) {
|
||||
case GM_QuickKeysMenu:
|
||||
mQuickKeysMenu->setVisible (true);
|
||||
break;
|
||||
case GM_MainMenu:
|
||||
mMenu->setVisible(true);
|
||||
break;
|
||||
|
@ -305,7 +321,6 @@ void WindowManager::updateVisible()
|
|||
break;
|
||||
case GM_Journal:
|
||||
mJournal->setVisible(true);
|
||||
mJournal->open();
|
||||
break;
|
||||
default:
|
||||
// Unsupported mode, switch back to game
|
||||
|
@ -552,12 +567,12 @@ void WindowManager::setPlayerDir(const float x, const float y)
|
|||
|
||||
void WindowManager::setHMSVisibility(bool visible)
|
||||
{
|
||||
mHud->setBottomLeftVisibility(visible, mHud->mWeapBox->getVisible(), mHud->mSpellBox->getVisible());
|
||||
mHud->setHmsVisible (visible);
|
||||
}
|
||||
|
||||
void WindowManager::setMinimapVisibility(bool visible)
|
||||
{
|
||||
mHud->setBottomRightVisibility(mHud->mEffectBox->getVisible(), visible);
|
||||
mHud->setMinimapVisible (visible);
|
||||
}
|
||||
|
||||
void WindowManager::toggleFogOfWar()
|
||||
|
@ -588,13 +603,13 @@ bool WindowManager::getFullHelp() const
|
|||
|
||||
void WindowManager::setWeaponVisibility(bool visible)
|
||||
{
|
||||
mHud->setBottomLeftVisibility(mHud->health->getVisible(), visible, mHud->mSpellBox->getVisible());
|
||||
mHud->setWeapVisible (visible);
|
||||
}
|
||||
|
||||
void WindowManager::setSpellVisibility(bool visible)
|
||||
{
|
||||
mHud->setBottomLeftVisibility(mHud->health->getVisible(), mHud->mWeapBox->getVisible(), visible);
|
||||
mHud->setBottomRightVisibility(visible, mHud->mMinimapBox->getVisible());
|
||||
mHud->setSpellVisible (visible);
|
||||
mHud->setEffectVisible (visible);
|
||||
}
|
||||
|
||||
void WindowManager::setMouseVisible(bool visible)
|
||||
|
@ -632,6 +647,10 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
{
|
||||
changeRes = true;
|
||||
}
|
||||
else if (it->first == "HUD" && it->second == "crosshair")
|
||||
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
|
||||
else if (it->first == "GUI" && it->second == "subtitles")
|
||||
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
||||
}
|
||||
|
||||
if (changeRes)
|
||||
|
@ -645,7 +664,9 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
mAlchemyWindow->center();
|
||||
mScrollWindow->center();
|
||||
mBookWindow->center();
|
||||
mQuickKeysMenu->center();
|
||||
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||
mInputBlocker->setSize(MyGUI::IntSize(x,y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -823,3 +844,41 @@ WindowManager::SkillList WindowManager::getPlayerMajorSkills()
|
|||
{
|
||||
return mPlayerMajorSkills;
|
||||
}
|
||||
|
||||
void WindowManager::disallowMouse()
|
||||
{
|
||||
mInputBlocker->setVisible (true);
|
||||
}
|
||||
|
||||
void WindowManager::allowMouse()
|
||||
{
|
||||
mInputBlocker->setVisible (!isGuiMode ());
|
||||
}
|
||||
|
||||
void WindowManager::notifyInputActionBound ()
|
||||
{
|
||||
mSettingsWindow->updateControlsBox ();
|
||||
allowMouse();
|
||||
}
|
||||
|
||||
|
||||
void WindowManager::showCrosshair (bool show)
|
||||
{
|
||||
mHud->setCrosshairVisible (show && mCrosshairEnabled);
|
||||
}
|
||||
|
||||
void WindowManager::activateQuickKey (int index)
|
||||
{
|
||||
mQuickKeysMenu->activateQuickKey(index);
|
||||
}
|
||||
|
||||
bool WindowManager::getSubtitlesEnabled ()
|
||||
{
|
||||
return mSubtitlesEnabled;
|
||||
}
|
||||
|
||||
void WindowManager::toggleHud ()
|
||||
{
|
||||
mHudEnabled = !mHudEnabled;
|
||||
mHud->setVisible (mHudEnabled);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace MWGui
|
|||
class MessageBoxManager;
|
||||
class SettingsWindow;
|
||||
class AlchemyWindow;
|
||||
class QuickKeysMenu;
|
||||
|
||||
class WindowManager : public MWBase::WindowManager
|
||||
{
|
||||
|
@ -151,12 +152,22 @@ namespace MWGui
|
|||
virtual void setWeaponVisibility(bool visible);
|
||||
virtual void setSpellVisibility(bool visible);
|
||||
|
||||
virtual void activateQuickKey (int index);
|
||||
|
||||
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent);
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent);
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent);
|
||||
virtual void unsetSelectedSpell();
|
||||
virtual void unsetSelectedWeapon();
|
||||
|
||||
virtual void showCrosshair(bool show);
|
||||
virtual bool getSubtitlesEnabled();
|
||||
virtual void toggleHud();
|
||||
|
||||
virtual void disallowMouse();
|
||||
virtual void allowMouse();
|
||||
virtual void notifyInputActionBound();
|
||||
|
||||
virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
|
||||
|
||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||
|
@ -205,9 +216,16 @@ namespace MWGui
|
|||
ConfirmationDialog* mConfirmationDialog;
|
||||
AlchemyWindow* mAlchemyWindow;
|
||||
SpellWindow* mSpellWindow;
|
||||
QuickKeysMenu* mQuickKeysMenu;
|
||||
|
||||
CharacterCreation* mCharGen;
|
||||
|
||||
MyGUI::Widget* mInputBlocker;
|
||||
|
||||
bool mCrosshairEnabled;
|
||||
bool mSubtitlesEnabled;
|
||||
bool mHudEnabled;
|
||||
|
||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
||||
// Various stats about player as needed by window manager
|
||||
ESM::Class mPlayerClass;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,20 +9,20 @@
|
|||
|
||||
namespace OEngine
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
class OgreRenderer;
|
||||
}
|
||||
namespace Render
|
||||
{
|
||||
class OgreRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Player;
|
||||
class Player;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
{
|
||||
class WindowManager;
|
||||
class WindowManager;
|
||||
}
|
||||
|
||||
namespace OMW
|
||||
|
@ -30,39 +30,214 @@ namespace OMW
|
|||
class Engine;
|
||||
}
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
class InputControlSystem;
|
||||
}
|
||||
|
||||
namespace OIS
|
||||
{
|
||||
class Keyboard;
|
||||
class Mouse;
|
||||
class InputManager;
|
||||
}
|
||||
|
||||
#include <OIS/OISKeyboard.h>
|
||||
#include <OIS/OISMouse.h>
|
||||
|
||||
#include <extern/oics/ICSChannelListener.h>
|
||||
#include <extern/oics/ICSInputControlSystem.h>
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
// Forward declaration of the real implementation.
|
||||
class InputImpl;
|
||||
|
||||
/* Class that handles all input and key bindings for OpenMW.
|
||||
/**
|
||||
* @brief Class that handles all input and key bindings for OpenMW.
|
||||
*/
|
||||
class InputManager : public MWBase::InputManager, public OIS::KeyListener, public OIS::MouseListener, public ICS::ChannelListener, public ICS::DetectingBindingListener
|
||||
{
|
||||
public:
|
||||
InputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||
MWWorld::Player&_player,
|
||||
MWBase::WindowManager &_windows,
|
||||
bool debug,
|
||||
OMW::Engine& engine,
|
||||
const std::string& userFile, bool userFileExists);
|
||||
|
||||
This class is just an interface. All the messy details are in
|
||||
inputmanager.cpp.
|
||||
*/
|
||||
struct MWInputManager : public MWBase::InputManager
|
||||
{
|
||||
InputImpl *impl;
|
||||
virtual ~InputManager();
|
||||
|
||||
public:
|
||||
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||
MWWorld::Player&_player,
|
||||
MWBase::WindowManager &_windows,
|
||||
bool debug,
|
||||
OMW::Engine& engine);
|
||||
virtual ~MWInputManager();
|
||||
virtual void update(float dt);
|
||||
|
||||
void update(float duration);
|
||||
virtual void changeInputMode(bool guiMode);
|
||||
|
||||
virtual void changeInputMode(bool guiMode);
|
||||
virtual void processChangedSettings(const Settings::CategorySettingVector& changed);
|
||||
|
||||
virtual void processChangedSettings(const Settings::CategorySettingVector& changed);
|
||||
virtual void setDragDrop(bool dragDrop);
|
||||
|
||||
virtual void setDragDrop(bool dragDrop);
|
||||
virtual void toggleControlSwitch (const std::string& sw, bool value);
|
||||
|
||||
void toggleControlSwitch(const std::string &sw, bool value);
|
||||
virtual std::string getActionDescription (int action);
|
||||
virtual std::string getActionBindingName (int action);
|
||||
virtual int getNumActions() { return A_Last; }
|
||||
virtual std::vector<int> getActionSorting ();
|
||||
virtual void enableDetectingBindingMode (int action);
|
||||
virtual void resetToDefaultBindings();
|
||||
|
||||
void resetIdleTime();
|
||||
};
|
||||
public:
|
||||
virtual bool keyPressed( const OIS::KeyEvent &arg );
|
||||
virtual bool keyReleased( const OIS::KeyEvent &arg );
|
||||
|
||||
virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
|
||||
virtual bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
|
||||
virtual bool mouseMoved( const OIS::MouseEvent &arg );
|
||||
|
||||
virtual void channelChanged(ICS::Channel* channel, float currentValue, float previousValue);
|
||||
|
||||
virtual void mouseAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, OIS::KeyCode key, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int axis, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickPOVBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int pov,ICS:: InputControlSystem::POVAxis axis, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickSliderBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int slider, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
void clearAllBindings (ICS::Control* control);
|
||||
|
||||
private:
|
||||
OEngine::Render::OgreRenderer &mOgre;
|
||||
MWWorld::Player &mPlayer;
|
||||
MWBase::WindowManager &mWindows;
|
||||
OMW::Engine& mEngine;
|
||||
|
||||
ICS::InputControlSystem* mInputCtrl;
|
||||
|
||||
OIS::Keyboard* mKeyboard;
|
||||
OIS::Mouse* mMouse;
|
||||
OIS::InputManager* mInputManager;
|
||||
|
||||
std::string mUserFile;
|
||||
|
||||
bool mDragDrop;
|
||||
|
||||
bool mInvertY;
|
||||
|
||||
float mCameraSensitivity;
|
||||
float mUISensitivity;
|
||||
float mCameraYMultiplier;
|
||||
float mUIYMultiplier;
|
||||
float mPreviewPOVDelay;
|
||||
float mTimeIdle;
|
||||
|
||||
bool mMouseLookEnabled;
|
||||
bool mGuiCursorEnabled;
|
||||
|
||||
float mMouseX;
|
||||
float mMouseY;
|
||||
|
||||
std::map<std::string, bool> mControlSwitch;
|
||||
|
||||
private:
|
||||
void adjustMouseRegion(int width, int height);
|
||||
|
||||
void resetIdleTime();
|
||||
void updateIdleTime(float dt);
|
||||
|
||||
private:
|
||||
void toggleMainMenu();
|
||||
void toggleSpell();
|
||||
void toggleWeapon();
|
||||
void toggleInventory();
|
||||
void toggleConsole();
|
||||
void screenshot();
|
||||
void toggleJournal();
|
||||
void activate();
|
||||
void toggleWalking();
|
||||
void toggleAutoMove();
|
||||
void exitNow();
|
||||
|
||||
void quickKey (int index);
|
||||
void showQuickKeysMenu();
|
||||
|
||||
bool actionIsActive (int id);
|
||||
|
||||
void loadKeyDefaults(bool force = false);
|
||||
|
||||
private:
|
||||
enum Actions
|
||||
{
|
||||
// please add new actions at the bottom, in order to preserve the channel IDs in the key configuration files
|
||||
|
||||
A_GameMenu,
|
||||
|
||||
A_Quit, // Exit the program
|
||||
|
||||
A_Screenshot, // Take a screenshot
|
||||
|
||||
A_Inventory, // Toggle inventory screen
|
||||
|
||||
A_Console, // Toggle console screen
|
||||
|
||||
A_MoveLeft, // Move player left / right
|
||||
A_MoveRight,
|
||||
A_MoveForward, // Forward / Backward
|
||||
A_MoveBackward,
|
||||
|
||||
A_Activate,
|
||||
|
||||
A_Use, //Use weapon, spell, etc.
|
||||
A_Jump,
|
||||
A_AutoMove, //Toggle Auto-move forward
|
||||
A_Rest, //Rest
|
||||
A_Journal, //Journal
|
||||
A_Weapon, //Draw/Sheath weapon
|
||||
A_Spell, //Ready/Unready Casting
|
||||
A_AlwaysRun, //Toggle Always Run
|
||||
A_CycleSpellLeft, //cycling through spells
|
||||
A_CycleSpellRight,
|
||||
A_CycleWeaponLeft,//Cycling through weapons
|
||||
A_CycleWeaponRight,
|
||||
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
||||
A_ToggleWalk, //Toggle Walking/Running
|
||||
A_Crouch,
|
||||
|
||||
A_QuickSave,
|
||||
A_QuickLoad,
|
||||
A_QuickMenu,
|
||||
A_ToggleWeapon,
|
||||
A_ToggleSpell,
|
||||
|
||||
A_TogglePOV,
|
||||
|
||||
A_QuickKey1,
|
||||
A_QuickKey2,
|
||||
A_QuickKey3,
|
||||
A_QuickKey4,
|
||||
A_QuickKey5,
|
||||
A_QuickKey6,
|
||||
A_QuickKey7,
|
||||
A_QuickKey8,
|
||||
A_QuickKey9,
|
||||
A_QuickKey10,
|
||||
|
||||
A_QuickKeysMenu,
|
||||
|
||||
A_ToggleHUD,
|
||||
|
||||
A_Last // Marker for the last item
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#include "mouselookevent.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include <OIS/OIS.h>
|
||||
#include <OgreCamera.h>
|
||||
#include <OgreSceneNode.h>
|
||||
|
||||
using namespace OIS;
|
||||
using namespace MWInput;
|
||||
|
||||
void MouseLookEvent::event(Type type, int index, const void *p)
|
||||
{
|
||||
if (type != EV_MouseMove || mDisabled) {
|
||||
return;
|
||||
}
|
||||
MWBase::Environment::get().getInputManager()->resetIdleTime();
|
||||
|
||||
MouseEvent *arg = (MouseEvent*)(p);
|
||||
|
||||
float x = arg->state.X.rel * sensX;
|
||||
float y = arg->state.Y.rel * sensY;
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true);
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
#ifndef _MWINPUT_MOUSELOOKEVENT_H
|
||||
#define _MWINPUT_MOUSELOOKEVENT_H
|
||||
|
||||
/*
|
||||
A mouse-look class for Ogre. Accepts input events from Mangle::Input
|
||||
and translates them.
|
||||
|
||||
You can adjust the mouse sensibility and switch to a different
|
||||
camera. The mouselook class also has an optional wrap protection
|
||||
that keeps the camera from flipping upside down.
|
||||
|
||||
You can disable the mouse looker at any time by calling
|
||||
setCamera(NULL), and reenable it by setting the camera back.
|
||||
|
||||
NOTE: The current implementation will ONLY work for native OIS
|
||||
events.
|
||||
*/
|
||||
|
||||
#include <mangle/input/event.hpp>
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
class MouseLookEvent : public Mangle::Input::Event
|
||||
{
|
||||
float sensX, sensY; // Mouse sensibility
|
||||
bool flipProt; // Flip protection
|
||||
bool mDisabled;
|
||||
|
||||
public:
|
||||
MouseLookEvent(float sX = 0.2, float sY = 0.2, bool prot=true)
|
||||
: sensX(sX), sensY(sY), flipProt(prot)
|
||||
{}
|
||||
|
||||
void setSens(float sX, float sY) {
|
||||
sensX = sX;
|
||||
sensY = sY;
|
||||
}
|
||||
|
||||
void setProt(bool p) {
|
||||
flipProt = p;
|
||||
}
|
||||
|
||||
void disable() {
|
||||
mDisabled = true;
|
||||
}
|
||||
|
||||
void enable() {
|
||||
mDisabled = false;
|
||||
}
|
||||
|
||||
void event(Type type, int index, const void *p);
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<MouseLookEvent> MouseLookEventPtr;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -20,6 +20,10 @@ namespace MWMechanics
|
|||
adjustMagicEffects (ptr);
|
||||
calculateCreatureStatModifiers (ptr);
|
||||
calculateDynamicStats (ptr);
|
||||
|
||||
// AI
|
||||
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
creatureStats.getAiSequence().execute (ptr);
|
||||
}
|
||||
|
||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||
|
|
4
apps/openmw/mwmechanics/aipackage.cpp
Normal file
4
apps/openmw/mwmechanics/aipackage.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
#include "aipackage.hpp"
|
||||
|
||||
MWMechanics::AiPackage::~AiPackage() {}
|
29
apps/openmw/mwmechanics/aipackage.hpp
Normal file
29
apps/openmw/mwmechanics/aipackage.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef GAME_MWMECHANICS_AIPACKAGE_H
|
||||
#define GAME_MWMECHANICS_AIPACKAGE_H
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief Base class for AI packages
|
||||
class AiPackage
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~AiPackage();
|
||||
|
||||
virtual AiPackage *clone() const = 0;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor) = 0;
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const = 0;
|
||||
///< 0: Wanter, 1 Travel, 2 Escort, 3 Follow, 4 Activate
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
79
apps/openmw/mwmechanics/aisequence.cpp
Normal file
79
apps/openmw/mwmechanics/aisequence.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
#include "aisequence.hpp"
|
||||
|
||||
#include "aipackage.hpp"
|
||||
|
||||
void MWMechanics::AiSequence::copy (const AiSequence& sequence)
|
||||
{
|
||||
for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
|
||||
iter!=sequence.mPackages.end(); ++iter)
|
||||
mPackages.push_back ((*iter)->clone());
|
||||
}
|
||||
|
||||
MWMechanics::AiSequence::AiSequence() : mDone (false) {}
|
||||
|
||||
MWMechanics::AiSequence::AiSequence (const AiSequence& sequence) : mDone (false)
|
||||
{
|
||||
copy (sequence);
|
||||
}
|
||||
|
||||
MWMechanics::AiSequence& MWMechanics::AiSequence::operator= (const AiSequence& sequence)
|
||||
{
|
||||
if (this!=&sequence)
|
||||
{
|
||||
clear();
|
||||
copy (sequence);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
MWMechanics::AiSequence::~AiSequence()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
int MWMechanics::AiSequence::getTypeId() const
|
||||
{
|
||||
if (mPackages.empty())
|
||||
return -1;
|
||||
|
||||
return mPackages.front()->getTypeId();
|
||||
}
|
||||
|
||||
bool MWMechanics::AiSequence::isPackageDone() const
|
||||
{
|
||||
return mDone;
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
if (!mPackages.empty())
|
||||
{
|
||||
if (mPackages.front()->execute (actor))
|
||||
{
|
||||
mPackages.erase (mPackages.begin());
|
||||
mDone = true;
|
||||
}
|
||||
else
|
||||
mDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::clear()
|
||||
{
|
||||
for (std::list<AiPackage *>::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter)
|
||||
delete *iter;
|
||||
|
||||
mPackages.clear();
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::stack (const AiPackage& package)
|
||||
{
|
||||
mPackages.push_front (package.clone());
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::queue (const AiPackage& package)
|
||||
{
|
||||
mPackages.push_back (package.clone());
|
||||
}
|
54
apps/openmw/mwmechanics/aisequence.hpp
Normal file
54
apps/openmw/mwmechanics/aisequence.hpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#ifndef GAME_MWMECHANICS_AISEQUENCE_H
|
||||
#define GAME_MWMECHANICS_AISEQUENCE_H
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class AiPackage;
|
||||
|
||||
/// \brief Sequence of AI-packages for a single actor
|
||||
class AiSequence
|
||||
{
|
||||
std::list<AiPackage *> mPackages;
|
||||
bool mDone;
|
||||
|
||||
void copy (const AiSequence& sequence);
|
||||
|
||||
public:
|
||||
|
||||
AiSequence();
|
||||
|
||||
AiSequence (const AiSequence& sequence);
|
||||
|
||||
AiSequence& operator= (const AiSequence& sequence);
|
||||
|
||||
virtual ~AiSequence();
|
||||
|
||||
int getTypeId() const;
|
||||
///< -1: None, 0: Wanter, 1 Travel, 2 Escort, 3 Follow, 4 Activate
|
||||
|
||||
bool isPackageDone() const;
|
||||
///< Has a package been completed during the last update?
|
||||
|
||||
void execute (const MWWorld::Ptr& actor);
|
||||
///< Execute package.
|
||||
|
||||
void clear();
|
||||
///< Remove all packages.
|
||||
|
||||
void stack (const AiPackage& package);
|
||||
///< Add \a package to the front of the sequence (suspends current package)
|
||||
|
||||
void queue (const AiPackage& package);
|
||||
///< Add \a package to the end of the sequence (executed after all other packages have been
|
||||
/// completed)
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -45,4 +45,14 @@ namespace MWMechanics
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const AiSequence& CreatureStats::getAiSequence() const
|
||||
{
|
||||
return mAiSequence;
|
||||
}
|
||||
|
||||
AiSequence& CreatureStats::getAiSequence()
|
||||
{
|
||||
return mAiSequence;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "magiceffects.hpp"
|
||||
#include "spells.hpp"
|
||||
#include "activespells.hpp"
|
||||
#include "aisequence.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
@ -27,6 +28,7 @@ namespace MWMechanics
|
|||
int mFight;
|
||||
int mFlee;
|
||||
int mAlarm;
|
||||
AiSequence mAiSequence;
|
||||
|
||||
public:
|
||||
CreatureStats();
|
||||
|
@ -100,6 +102,10 @@ namespace MWMechanics
|
|||
void setFlee(int value);
|
||||
|
||||
void setAlarm(int value);
|
||||
|
||||
const AiSequence& getAiSequence() const;
|
||||
|
||||
AiSequence& getAiSequence();
|
||||
};
|
||||
|
||||
// Inline const getters
|
||||
|
|
|
@ -66,15 +66,18 @@ namespace MWMechanics
|
|||
static_cast<int> (male ? attribute->male : attribute->female));
|
||||
}
|
||||
|
||||
for (int i=0; i<7; ++i)
|
||||
for (int i=0; i<27; ++i)
|
||||
{
|
||||
int index = race->data.bonus[i].skill;
|
||||
|
||||
if (index>=0 && index<27)
|
||||
{
|
||||
npcStats.getSkill (index).setBase (
|
||||
npcStats.getSkill (index).getBase() + race->data.bonus[i].bonus);
|
||||
}
|
||||
int bonus = 0;
|
||||
|
||||
for (int i2=0; i2<7; ++i2)
|
||||
if (race->data.bonus[i2].skill==i)
|
||||
{
|
||||
bonus = race->data.bonus[i2].bonus;
|
||||
break;
|
||||
}
|
||||
|
||||
npcStats.getSkill (i).setBase (5 + bonus);
|
||||
}
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter (race->powers.list.begin());
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "../mwworld/class.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "npcstats.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
|
|
|
@ -270,6 +270,34 @@ void LocalMap::render(const float x, const float y,
|
|||
mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, fStart, fEnd);
|
||||
}
|
||||
|
||||
void LocalMap::getInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y)
|
||||
{
|
||||
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().z), mAngle);
|
||||
|
||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
||||
|
||||
x = std::ceil((pos.x - min.x)/sSize)-1;
|
||||
y = std::ceil((pos.y - min.y)/sSize)-1;
|
||||
|
||||
nX = (pos.x - min.x - sSize*x)/sSize;
|
||||
nY = (pos.y - min.y - sSize*y)/sSize;
|
||||
}
|
||||
|
||||
bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interior)
|
||||
{
|
||||
std::string texName = (interior ? mInteriorName + "_" : "Cell_") + coordStr(x, y);
|
||||
|
||||
if (mBuffers.find(texName) == mBuffers.end())
|
||||
return false;
|
||||
|
||||
int texU = (sFogOfWarResolution-1) * nX;
|
||||
int texV = (sFogOfWarResolution-1) * nY;
|
||||
|
||||
Ogre::uint32 clr = mBuffers[texName][texV * sFogOfWarResolution + texU];
|
||||
uint8 alpha = (clr >> 24);
|
||||
return alpha < 200;
|
||||
}
|
||||
|
||||
void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation)
|
||||
{
|
||||
if (sFogOfWarSkip != 0)
|
||||
|
@ -281,14 +309,12 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
|||
|
||||
// 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);
|
||||
float u,v;
|
||||
|
||||
Vector2 pos(position.x, position.z);
|
||||
|
||||
if (mInterior)
|
||||
{
|
||||
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().z), mAngle);
|
||||
}
|
||||
|
||||
getInteriorMapPosition(pos, u,v, x,y);
|
||||
|
||||
Vector3 playerdirection = mCameraRotNode->convertWorldToLocalOrientation(orientation).zAxis();
|
||||
|
||||
|
@ -303,14 +329,10 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
|||
}
|
||||
else
|
||||
{
|
||||
x = std::ceil((pos.x - min.x)/sSize)-1;
|
||||
y = std::ceil((pos.y - min.y)/sSize)-1;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setInteriorMapTexture(x,y);
|
||||
}
|
||||
|
||||
// convert from world coordinates to texture UV coordinates
|
||||
float u,v;
|
||||
std::string texBaseName;
|
||||
if (!mInterior)
|
||||
{
|
||||
|
@ -320,9 +342,6 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
|||
}
|
||||
else
|
||||
{
|
||||
u = (pos.x - min.x - sSize*x)/sSize;
|
||||
v = (pos.y - min.y - sSize*y)/sSize;
|
||||
|
||||
texBaseName = mInteriorName + "_";
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,18 @@ namespace MWRender
|
|||
*/
|
||||
void saveFogOfWar(MWWorld::CellStore* cell);
|
||||
|
||||
|
||||
/**
|
||||
* Get the interior map texture index and normalized position
|
||||
* on this texture, given a world position (in ogre coordinates)
|
||||
*/
|
||||
void getInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y);
|
||||
|
||||
/**
|
||||
* Check if a given position is explored by the player (i.e. not obscured by fog of war)
|
||||
*/
|
||||
bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
|
||||
|
||||
private:
|
||||
OEngine::Render::OgreRenderer* mRendering;
|
||||
MWRender::RenderingManager* mRenderingManager;
|
||||
|
|
|
@ -106,7 +106,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
|
|||
extents *= insert->getScale();
|
||||
float size = std::max(std::max(extents.x, extents.y), extents.z);
|
||||
|
||||
bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && Settings::Manager::getBool("limit small object distance", "Objects");
|
||||
bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && Settings::Manager::getBool("limit small object distance", "Viewing distance");
|
||||
|
||||
// do not fade out doors. that will cause holes and look stupid
|
||||
if (ptr.getTypeName().find("Door") != std::string::npos)
|
||||
|
|
|
@ -116,9 +116,18 @@ namespace MWRender
|
|||
|
||||
void Player::update(float duration)
|
||||
{
|
||||
// only show the crosshair in game mode and in first person mode.
|
||||
MWBase::Environment::get().getWindowManager ()->showCrosshair
|
||||
(!MWBase::Environment::get().getWindowManager ()->isGuiMode () && (mFirstPersonView && !mVanity.enabled && !mPreviewMode));
|
||||
|
||||
if (mAnimation) {
|
||||
mAnimation->runAnimation(duration);
|
||||
}
|
||||
mPlayerNode->setVisible(
|
||||
mVanity.enabled || mPreviewMode || !mFirstPersonView,
|
||||
false
|
||||
);
|
||||
|
||||
if (mFirstPersonView && !mVanity.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -139,7 +148,6 @@ namespace MWRender
|
|||
mCamera->setPosition(0.f, 0.f, mCameraDistance);
|
||||
setLowHeight(true);
|
||||
}
|
||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||
}
|
||||
|
||||
void Player::allowVanityMode(bool allow)
|
||||
|
@ -168,13 +176,11 @@ namespace MWRender
|
|||
rot.x = Ogre::Degree(-30.f).valueRadians();
|
||||
mMainCam.offset = mCamera->getPosition().z;
|
||||
|
||||
mPlayerNode->setVisible(true, false);
|
||||
setLowHeight(true);
|
||||
} else {
|
||||
rot.x = getPitch();
|
||||
offset = mMainCam.offset;
|
||||
|
||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||
setLowHeight(!mFirstPersonView);
|
||||
}
|
||||
rot.z = getYaw();
|
||||
|
@ -195,13 +201,11 @@ namespace MWRender
|
|||
mMainCam.offset = offset;
|
||||
offset = mPreviewCam.offset;
|
||||
|
||||
mPlayerNode->setVisible(true, false);
|
||||
setLowHeight(true);
|
||||
} else {
|
||||
mPreviewCam.offset = offset;
|
||||
offset = mMainCam.offset;
|
||||
|
||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||
setLowHeight(!mFirstPersonView);
|
||||
}
|
||||
mCamera->setPosition(0.f, 0.f, offset);
|
||||
|
@ -298,7 +302,6 @@ namespace MWRender
|
|||
void Player::setAnimation(NpcAnimation *anim)
|
||||
{
|
||||
mAnimation = anim;
|
||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||
}
|
||||
|
||||
void Player::setHeight(float height)
|
||||
|
|
|
@ -40,7 +40,8 @@ using namespace Ogre;
|
|||
|
||||
namespace MWRender {
|
||||
|
||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine)
|
||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
||||
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine)
|
||||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0), mPhysicsEngine(engine)
|
||||
{
|
||||
// select best shader mode
|
||||
|
@ -63,7 +64,9 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
|
||||
// material system
|
||||
sh::OgrePlatform* platform = new sh::OgrePlatform("General", (resDir / "materials").string());
|
||||
platform->setCacheFolder ("./");
|
||||
if (!boost::filesystem::exists (cacheDir))
|
||||
boost::filesystem::create_directory (cacheDir);
|
||||
platform->setCacheFolder (cacheDir.string());
|
||||
mFactory = new sh::Factory(platform);
|
||||
|
||||
sh::Language lang;
|
||||
|
@ -75,6 +78,11 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
else
|
||||
lang = sh::Language_CG;
|
||||
mFactory->setCurrentLanguage (lang);
|
||||
mFactory->setWriteSourceCache (true);
|
||||
mFactory->setReadSourceCache (true);
|
||||
mFactory->setReadMicrocodeCache (true);
|
||||
mFactory->setWriteMicrocodeCache (true);
|
||||
|
||||
mFactory->loadAllFiles();
|
||||
|
||||
// Set default mipmap level (NB some APIs ignore this)
|
||||
|
@ -863,4 +871,14 @@ void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float
|
|||
mPlayer->getSightAngles(pitch, yaw);
|
||||
}
|
||||
|
||||
void RenderingManager::getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y)
|
||||
{
|
||||
return mLocalMap->getInteriorMapPosition (position, nX, nY, x, y);
|
||||
}
|
||||
|
||||
bool RenderingManager::isPositionExplored (float nX, float nY, int x, int y, bool interior)
|
||||
{
|
||||
return mLocalMap->isPositionExplored(nX, nY, x, y, interior);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -53,7 +53,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
virtual MWRender::Actors& getActors();
|
||||
|
||||
public:
|
||||
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine);
|
||||
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
||||
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine);
|
||||
virtual ~RenderingManager();
|
||||
|
||||
void togglePOV() {
|
||||
|
@ -184,6 +185,12 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
|
||||
static bool waterShaderSupported();
|
||||
|
||||
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
|
||||
///< see MWRender::LocalMap::getInteriorMapPosition
|
||||
|
||||
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
|
||||
///< see MWRender::LocalMap::isPositionExplored
|
||||
|
||||
protected:
|
||||
virtual void windowResized(Ogre::RenderWindow* rw);
|
||||
virtual void windowClosed(Ogre::RenderWindow* rw);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
@ -37,7 +38,9 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->say (ptr, file);
|
||||
context.messageBox (text);
|
||||
|
||||
if (MWBase::Environment::get().getWindowManager ()->getSubtitlesEnabled())
|
||||
context.messageBox (text);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace MWSound
|
|||
// The range values are not tested
|
||||
float basevol = mMasterVolume * mVoiceVolume;
|
||||
std::string filePath = "Sound/"+filename;
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
||||
MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, basevol, 1.0f,
|
||||
|
@ -313,7 +313,7 @@ namespace MWSound
|
|||
float basevol = mMasterVolume * mSFXVolume;
|
||||
float min, max;
|
||||
std::string file = lookup(soundId, basevol, min, max);
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();;
|
||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
||||
sound = mOutput->playSound3D(file, objpos, volume*basevol, pitch, min, max, mode);
|
||||
|
@ -406,7 +406,7 @@ namespace MWSound
|
|||
|
||||
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
||||
{
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();;
|
||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
|
|
|
@ -2,17 +2,39 @@
|
|||
#include "action.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
||||
MWWorld::Action::Action() {}
|
||||
const MWWorld::Ptr& MWWorld::Action::getTarget() const
|
||||
{
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target)
|
||||
{}
|
||||
|
||||
MWWorld::Action::~Action() {}
|
||||
|
||||
void MWWorld::Action::execute (const Ptr& actor)
|
||||
{
|
||||
if (!mSoundId.empty())
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0,
|
||||
MWBase::SoundManager::Play_NoTrack);
|
||||
{
|
||||
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
||||
{
|
||||
// sound moves with player when teleporting
|
||||
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
||||
MWBase::SoundManager::Play_NoTrack);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget,
|
||||
mSoundId, 1.0, 1.0,
|
||||
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
executeImp (actor);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
|
||||
/// \brief Abstract base for actions
|
||||
class Action
|
||||
{
|
||||
std::string mSoundId;
|
||||
bool mKeepSound;
|
||||
Ptr mTarget;
|
||||
|
||||
// not implemented
|
||||
Action (const Action& action);
|
||||
|
@ -18,9 +20,14 @@ namespace MWWorld
|
|||
|
||||
virtual void executeImp (const Ptr& actor) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
const Ptr& getTarget() const;
|
||||
|
||||
public:
|
||||
|
||||
Action();
|
||||
Action (bool keepSound = false, const Ptr& target = Ptr());
|
||||
///< \param keepSound Keep playing the sound even if the object the sound is played on is removed.
|
||||
|
||||
virtual ~Action();
|
||||
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
namespace MWWorld
|
||||
{
|
||||
ActionApply::ActionApply (const Ptr& target, const std::string& id)
|
||||
: mTarget (target), mId (id)
|
||||
: Action (false, target), mId (id)
|
||||
{}
|
||||
|
||||
void ActionApply::executeImp (const Ptr& actor)
|
||||
{
|
||||
MWWorld::Class::get (mTarget).apply (mTarget, mId, actor);
|
||||
MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor);
|
||||
}
|
||||
|
||||
|
||||
ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& target, const std::string& id,
|
||||
int skillIndex, int usageType)
|
||||
: mTarget (target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
|
||||
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
|
||||
{}
|
||||
|
||||
void ActionApplyWithSkill::executeImp (const Ptr& actor)
|
||||
{
|
||||
if (MWWorld::Class::get (mTarget).apply (mTarget, mId, actor) && mUsageType!=-1)
|
||||
MWWorld::Class::get (mTarget).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
||||
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
|
||||
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionApply : public Action
|
||||
{
|
||||
Ptr mTarget;
|
||||
std::string mId;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
|
@ -23,7 +22,6 @@ namespace MWWorld
|
|||
|
||||
class ActionApplyWithSkill : public Action
|
||||
{
|
||||
Ptr mTarget;
|
||||
std::string mId;
|
||||
int mSkillIndex;
|
||||
int mUsageType;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionEquip::ActionEquip (const MWWorld::Ptr& object) : mObject (object)
|
||||
ActionEquip::ActionEquip (const MWWorld::Ptr& object) : Action (false, object)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ namespace MWWorld
|
|||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
||||
|
||||
// slots that this item can be equipped in
|
||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(mObject).getEquipmentSlots(mObject);
|
||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(getTarget()).getEquipmentSlots(getTarget());
|
||||
|
||||
// retrieve ContainerStoreIterator to the item
|
||||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||
for (; it != invStore.end(); ++it)
|
||||
{
|
||||
if (*it == mObject)
|
||||
if (*it == getTarget())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionEquip : public Action
|
||||
{
|
||||
Ptr mObject;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionOpen::ActionOpen (const MWWorld::Ptr& container) : mContainer (container) {
|
||||
mContainer = container;
|
||||
ActionOpen::ActionOpen (const MWWorld::Ptr& container) : Action (false, container)
|
||||
{
|
||||
}
|
||||
|
||||
void ActionOpen::executeImp (const MWWorld::Ptr& actor)
|
||||
|
@ -20,6 +20,6 @@ namespace MWWorld
|
|||
return;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
|
||||
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(mContainer);
|
||||
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionOpen : public Action
|
||||
{
|
||||
Ptr mContainer;
|
||||
|
||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionRead::ActionRead (const MWWorld::Ptr& object) : mObject (object)
|
||||
ActionRead::ActionRead (const MWWorld::Ptr& object) : Action (false, object)
|
||||
{
|
||||
}
|
||||
|
||||
void ActionRead::executeImp (const MWWorld::Ptr& actor)
|
||||
{
|
||||
LiveCellRef<ESM::Book> *ref = mObject.get<ESM::Book>();
|
||||
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
|
||||
|
||||
if (ref->base->data.isScroll)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll);
|
||||
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(mObject);
|
||||
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget());
|
||||
}
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book);
|
||||
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(mObject);
|
||||
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionRead : public Action
|
||||
{
|
||||
Ptr mObject; // book or scroll to read
|
||||
|
||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
|
||||
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
|
||||
|
||||
void ActionTake::executeImp (const Ptr& actor)
|
||||
{
|
||||
|
@ -20,10 +20,8 @@ namespace MWWorld
|
|||
// insert into player's inventory
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
||||
|
||||
MWWorld::Class::get (player).getContainerStore (player).add (mObject);
|
||||
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
|
||||
|
||||
// remove from world, if the item is currently in the world (it could also be in a container)
|
||||
if (mObject.isInCell())
|
||||
MWBase::Environment::get().getWorld()->deleteObject (mObject);
|
||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionTake : public Action
|
||||
{
|
||||
MWWorld::Ptr mObject;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionTalk::ActionTalk (const Ptr& actor) : mActor (actor) {}
|
||||
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
|
||||
|
||||
void ActionTalk::executeImp (const Ptr& actor)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->startDialogue (mActor);
|
||||
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace MWWorld
|
|||
{
|
||||
class ActionTalk : public Action
|
||||
{
|
||||
Ptr mActor;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -8,8 +8,9 @@ namespace MWWorld
|
|||
{
|
||||
ActionTeleport::ActionTeleport (const std::string& cellName,
|
||||
const ESM::Position& position)
|
||||
: mCellName (cellName), mPosition (position)
|
||||
{}
|
||||
: Action (true), mCellName (cellName), mPosition (position)
|
||||
{
|
||||
}
|
||||
|
||||
void ActionTeleport::executeImp (const Ptr& actor)
|
||||
{
|
||||
|
|
|
@ -75,6 +75,9 @@ namespace MWWorld
|
|||
|
||||
std::string RefData::getHandle()
|
||||
{
|
||||
if (!mBaseNode)
|
||||
return "";
|
||||
|
||||
return mBaseNode->getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace MWWorld
|
|||
|
||||
World::World (OEngine::Render::OgreRenderer& renderer,
|
||||
const Files::Collections& fileCollections,
|
||||
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
|
||||
const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
|
||||
const std::string& encoding, std::map<std::string,std::string> fallbackMap)
|
||||
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
|
||||
mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm),
|
||||
|
@ -173,7 +173,7 @@ namespace MWWorld
|
|||
mPhysics = new PhysicsSystem(renderer);
|
||||
mPhysEngine = mPhysics->getEngine();
|
||||
|
||||
mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine);
|
||||
mRendering = new MWRender::RenderingManager(renderer, resDir, cacheDir, mPhysEngine);
|
||||
|
||||
mWeatherManager = new MWWorld::WeatherManager(mRendering);
|
||||
|
||||
|
@ -745,8 +745,11 @@ namespace MWWorld
|
|||
std::ostringstream stream;
|
||||
stream << "$dynamic" << mNextDynamicRecord++;
|
||||
|
||||
ESM::Potion record2 (record);
|
||||
record2.mId = stream.str();
|
||||
|
||||
const ESM::Potion *created =
|
||||
&mStore.potions.list.insert (std::make_pair (stream.str(), record)).first->second;
|
||||
&mStore.potions.list.insert (std::make_pair (stream.str(), record2)).first->second;
|
||||
|
||||
mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH));
|
||||
|
||||
|
@ -1018,7 +1021,7 @@ namespace MWWorld
|
|||
|
||||
Ogre::Vector2 World::getNorthVector (CellStore* cell)
|
||||
{
|
||||
MWWorld::CellRefList<ESM::Static> statics = cell->statics;
|
||||
MWWorld::CellRefList<ESM::Static>& statics = cell->statics;
|
||||
MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker");
|
||||
if (!ref)
|
||||
return Vector2(0, 1);
|
||||
|
@ -1028,6 +1031,64 @@ namespace MWWorld
|
|||
return d;
|
||||
}
|
||||
|
||||
std::vector<World::DoorMarker> World::getDoorMarkers (CellStore* cell)
|
||||
{
|
||||
std::vector<World::DoorMarker> result;
|
||||
|
||||
MWWorld::CellRefList<ESM::Door>& doors = cell->doors;
|
||||
std::list< MWWorld::LiveCellRef<ESM::Door> >& refList = doors.list;
|
||||
for (std::list< MWWorld::LiveCellRef<ESM::Door> >::iterator it = refList.begin(); it != refList.end(); ++it)
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
||||
|
||||
if (ref.ref.teleport)
|
||||
{
|
||||
World::DoorMarker newMarker;
|
||||
|
||||
std::string dest;
|
||||
if (ref.ref.destCell != "")
|
||||
{
|
||||
// door leads to an interior, use interior name
|
||||
dest = ref.ref.destCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
// door leads to exterior, use cell name (if any), otherwise translated region name
|
||||
int x,y;
|
||||
positionToIndex (ref.ref.doorDest.pos[0], ref.ref.doorDest.pos[1], x, y);
|
||||
const ESM::Cell* cell = mStore.cells.findExt(x,y);
|
||||
if (cell->name != "")
|
||||
dest = cell->name;
|
||||
else
|
||||
{
|
||||
const ESM::Region* region = mStore.regions.search(cell->region);
|
||||
dest = region->name;
|
||||
}
|
||||
}
|
||||
|
||||
newMarker.name = dest;
|
||||
|
||||
ESM::Position pos = ref.mData.getPosition ();
|
||||
|
||||
newMarker.x = pos.pos[0];
|
||||
newMarker.y = pos.pos[1];
|
||||
result.push_back(newMarker);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void World::getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y)
|
||||
{
|
||||
mRendering->getInteriorMapPosition(position, nX, nY, x, y);
|
||||
}
|
||||
|
||||
bool World::isPositionExplored (float nX, float nY, int x, int y, bool interior)
|
||||
{
|
||||
return mRendering->isPositionExplored(nX, nY, x, y, interior);
|
||||
}
|
||||
|
||||
void World::setWaterHeight(const float height)
|
||||
{
|
||||
mRendering->setWaterHeight(height);
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace MWWorld
|
|||
|
||||
World (OEngine::Render::OgreRenderer& renderer,
|
||||
const Files::Collections& fileCollections,
|
||||
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
|
||||
const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
|
||||
const std::string& encoding, std::map<std::string,std::string> fallbackMap);
|
||||
|
||||
virtual ~World();
|
||||
|
@ -140,6 +140,15 @@ namespace MWWorld
|
|||
virtual Ogre::Vector2 getNorthVector (CellStore* cell);
|
||||
///< get north vector (OGRE coordinates) for given interior cell
|
||||
|
||||
virtual std::vector<DoorMarker> getDoorMarkers (MWWorld::CellStore* cell);
|
||||
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
||||
|
||||
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
|
||||
///< see MWRender::LocalMap::getInteriorMapPosition
|
||||
|
||||
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
|
||||
///< see MWRender::LocalMap::isPositionExplored
|
||||
|
||||
virtual Globals::Data& getGlobalVariable (const std::string& name);
|
||||
|
||||
virtual Globals::Data getGlobalVariable (const std::string& name) const;
|
||||
|
|
|
@ -43,7 +43,7 @@ add_component_dir (esm
|
|||
loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst
|
||||
loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc
|
||||
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
|
||||
loadweap records
|
||||
loadweap records aipackage
|
||||
)
|
||||
|
||||
add_component_dir (misc
|
||||
|
|
37
components/esm/aipackage.cpp
Normal file
37
components/esm/aipackage.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "aipackage.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
void AIPackageList::load(ESMReader &esm)
|
||||
{
|
||||
while (esm.hasMoreSubs()) {
|
||||
// initialize every iteration
|
||||
AIPackage pack;
|
||||
esm.getSubName();
|
||||
if (esm.retSubName() == 0x54444e43) { // CNDT
|
||||
mList.back().mCellName = esm.getHString();
|
||||
} else if (esm.retSubName() == AI_Wander) {
|
||||
pack.mType = AI_Wander;
|
||||
esm.getHExact(&pack.mWander, 14);
|
||||
mList.push_back(pack);
|
||||
} else if (esm.retSubName() == AI_Travel) {
|
||||
pack.mType = AI_Travel;
|
||||
esm.getHExact(&pack.mTravel, 16);
|
||||
mList.push_back(pack);
|
||||
} else if (esm.retSubName() == AI_Escort ||
|
||||
esm.retSubName() == AI_Follow)
|
||||
{
|
||||
pack.mType =
|
||||
(esm.retSubName() == AI_Escort) ? AI_Escort : AI_Follow;
|
||||
esm.getHExact(&pack.mTarget, 48);
|
||||
mList.push_back(pack);
|
||||
} else if (esm.retSubName() == AI_Activate) {
|
||||
pack.mType = AI_Activate;
|
||||
esm.getHExact(&pack.mActivate, 33);
|
||||
mList.push_back(pack);
|
||||
} else { // not AI package related data, so leave
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
95
components/esm/aipackage.hpp
Normal file
95
components/esm/aipackage.hpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
#ifndef OPENMW_ESM_AIPACKAGE_H
|
||||
#define OPENMW_ESM_AIPACKAGE_H
|
||||
|
||||
#include "esm_reader.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
struct AIData
|
||||
{
|
||||
// These are probabilities
|
||||
char mHello, mU1, mFight, mFlee, mAlarm, mU2, mU3, mU4;
|
||||
// The last u's might be the skills that this NPC can train you
|
||||
// in?
|
||||
int mServices; // See the Services enum
|
||||
}; // 12 bytes
|
||||
|
||||
struct AIWander
|
||||
{
|
||||
short mDistance;
|
||||
short mDuration;
|
||||
unsigned char mTimeOfDay;
|
||||
unsigned char mIdle[8];
|
||||
unsigned char mUnk;
|
||||
};
|
||||
|
||||
struct AITravel
|
||||
{
|
||||
float mX, mY, mZ;
|
||||
long mUnk;
|
||||
};
|
||||
|
||||
struct AITarget
|
||||
{
|
||||
float mX, mY, mZ;
|
||||
short mDuration;
|
||||
NAME32 mId;
|
||||
short mUnk;
|
||||
};
|
||||
|
||||
struct AIActivate
|
||||
{
|
||||
NAME32 mName;
|
||||
unsigned char mUnk;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
enum
|
||||
{
|
||||
AI_Wander = 0x575f4941,
|
||||
AI_Travel = 0x545f4941,
|
||||
AI_Follow = 0x465f4941,
|
||||
AI_Escort = 0x455f4941,
|
||||
AI_Activate = 0x415f4941,
|
||||
};
|
||||
|
||||
/// \note Used for storaging packages in a single container
|
||||
/// w/o manual memory allocation accordingly to policy standards
|
||||
struct AIPackage
|
||||
{
|
||||
int mType;
|
||||
|
||||
// Anonymous union
|
||||
union
|
||||
{
|
||||
AIWander mWander;
|
||||
AITravel mTravel;
|
||||
AITarget mTarget;
|
||||
AIActivate mActivate;
|
||||
};
|
||||
|
||||
/// \note for AITarget only, placed here to stick with union,
|
||||
/// overhead should be not so awful
|
||||
std::string mCellName;
|
||||
};
|
||||
|
||||
struct AIPackageList
|
||||
{
|
||||
std::vector<AIPackage> mList;
|
||||
|
||||
/// \note This breaks consistency of subrecords reading:
|
||||
/// after calling it subrecord name is already read, so
|
||||
/// it needs to use retSubName() if needed. But, hey, there
|
||||
/// is only one field left (XSCL) and only two records uses AI
|
||||
void load(ESMReader &esm);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue