Finally merged in master

actorid
Jason Hooks 13 years ago
commit 0697c7f7f4

@ -15,7 +15,7 @@ include (OpenMWMacros)
# Version # Version
set (OPENMW_VERSION_MAJOR 0) set (OPENMW_VERSION_MAJOR 0)
set (OPENMW_VERSION_MINOR 16) set (OPENMW_VERSION_MINOR 17)
set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION_RELEASE 0)
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
@ -96,19 +96,13 @@ ENDIF()
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs) 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 set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/renderer.cpp ${LIBDIR}/openengine/ogre/renderer.cpp
${LIBDIR}/openengine/ogre/mouselook.cpp
${LIBDIR}/openengine/ogre/fader.cpp ${LIBDIR}/openengine/ogre/fader.cpp
${LIBDIR}/openengine/ogre/imagerotate.cpp ${LIBDIR}/openengine/ogre/imagerotate.cpp
${LIBDIR}/openengine/ogre/atlas.cpp ${LIBDIR}/openengine/ogre/atlas.cpp
) )
set(OENGINE_GUI set(OENGINE_GUI
${LIBDIR}/openengine/gui/events.cpp
${LIBDIR}/openengine/gui/manager.cpp ${LIBDIR}/openengine/gui/manager.cpp
) )
@ -135,7 +129,7 @@ set(OENGINE_BULLET
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET}) set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
source_group(libs\\openengine FILES ${OENGINE_ALL}) source_group(libs\\openengine FILES ${OENGINE_ALL})
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL}) set(OPENMW_LIBS ${OENGINE_ALL})
set(OPENMW_LIBS_HEADER) set(OPENMW_LIBS_HEADER)
# Sound setup # Sound setup
@ -257,13 +251,15 @@ if (APPLE)
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE) endif (APPLE)
# Set up DEBUG define
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG DEBUG=1)
# Set up Ogre plugin folder & debug suffix # Set up Ogre plugin folder & debug suffix
if (APPLE)
# Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt) # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt)
if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE)
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
else()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
else ()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
endif() endif()
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
@ -443,6 +439,7 @@ endif(WIN32)
# Extern # Extern
add_subdirectory (extern/shiny) add_subdirectory (extern/shiny)
add_subdirectory (extern/oics)
# Components # Components
add_subdirectory (components) add_subdirectory (components)

@ -20,30 +20,31 @@ add_openmw_dir (mwrender
) )
add_openmw_dir (mwinput add_openmw_dir (mwinput
inputmanager inputmanagerimp
) )
add_openmw_dir (mwgui add_openmw_dir (mwgui
text_input widgets race class birth review window_manager console dialogue text_input widgets race class birth review windowmanagerimp console dialogue
dialogue_history window_base stats_window messagebox journalwindow charactercreation dialogue_history window_base stats_window messagebox journalwindow charactercreation
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
formatting inventorywindow container hud countdialog tradewindow settingswindow formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue
dialoguemanager journal journalentry quest topic dialoguemanagerimp journalimp journalentry quest topic
) )
add_openmw_dir (mwscript add_openmw_dir (mwscript
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions locals scriptmanagerimp compilercontext interpretercontext cellextensions miscextensions
guiextensions soundextensions skyextensions statsextensions containerextensions guiextensions soundextensions skyextensions statsextensions containerextensions
aiextensions controlextensions extensions globalscripts ref dialogueextensions aiextensions controlextensions extensions globalscripts ref dialogueextensions
animationextensions transformationextensions consoleextensions userextensions animationextensions transformationextensions consoleextensions userextensions
) )
add_openmw_dir (mwsound add_openmw_dir (mwsound
soundmanager openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder soundmanagerimp openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder
) )
add_openmw_dir (mwworld add_openmw_dir (mwworld
@ -59,12 +60,13 @@ add_openmw_dir (mwclass
) )
add_openmw_dir (mwmechanics add_openmw_dir (mwmechanics
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells
activespells npcstats activespells npcstats
) )
add_openmw_dir (mwbase add_openmw_dir (mwbase
environment world environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager
inputmanager windowmanager
) )
# Main executable # Main executable
@ -102,6 +104,7 @@ target_link_libraries(openmw
${MYGUI_PLATFORM_LIBRARIES} ${MYGUI_PLATFORM_LIBRARIES}
"shiny" "shiny"
"shiny.OgrePlatform" "shiny.OgrePlatform"
"oics"
components components
) )
@ -112,7 +115,9 @@ endif()
if(APPLE) if(APPLE)
find_library(CARBON_FRAMEWORK Carbon) 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) endif(APPLE)
if(DPKG_PROGRAM) if(DPKG_PROGRAM)

@ -13,15 +13,15 @@
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bullet_nif_loader.hpp>
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogre_nif_loader.hpp>
#include "mwinput/inputmanager.hpp" #include "mwinput/inputmanagerimp.hpp"
#include "mwgui/window_manager.hpp" #include "mwgui/windowmanagerimp.hpp"
#include "mwgui/cursorreplace.hpp" #include "mwgui/cursorreplace.hpp"
#include "mwscript/scriptmanager.hpp" #include "mwscript/scriptmanagerimp.hpp"
#include "mwscript/extensions.hpp" #include "mwscript/extensions.hpp"
#include "mwsound/soundmanager.hpp" #include "mwsound/soundmanagerimp.hpp"
#include "mwworld/class.hpp" #include "mwworld/class.hpp"
#include "mwworld/player.hpp" #include "mwworld/player.hpp"
@ -29,10 +29,10 @@
#include "mwclass/classes.hpp" #include "mwclass/classes.hpp"
#include "mwdialogue/dialoguemanager.hpp" #include "mwdialogue/dialoguemanagerimp.hpp"
#include "mwdialogue/journal.hpp" #include "mwdialogue/journalimp.hpp"
#include "mwmechanics/mechanicsmanager.hpp" #include "mwmechanics/mechanicsmanagerimp.hpp"
void OMW::Engine::executeLocalScripts() void OMW::Engine::executeLocalScripts()
@ -67,7 +67,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
mEnvironment.setFrameDuration (evt.timeSinceLastFrame); mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
// update input // update input
MWBase::Environment::get().getInputManager()->update(); MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame);
// sound // sound
if (mUseSound) if (mUseSound)
@ -270,6 +270,10 @@ void OMW::Engine::go()
else if (boost::filesystem::exists(globaldefault)) else if (boost::filesystem::exists(globaldefault))
settings.loadUser(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"); mFpsLevel = settings.getInt("fps", "HUD");
// load nif overrides // load nif overrides
@ -352,6 +356,8 @@ void OMW::Engine::go()
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
pos.pos[2] = 0; pos.pos[2] = 0;
mEnvironment.getWorld()->renderPlayer();
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
{ {
MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY,
@ -366,9 +372,9 @@ void OMW::Engine::go()
// Sets up the input system // 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().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"; std::cout << "\nPress Q/ESC or close window to exit.\n";

@ -0,0 +1,46 @@
#ifndef GAME_MWBASE_DIALOGUEMANAGER_H
#define GAME_MWBASE_DIALOGUEMANAGER_H
#include <string>
namespace MWWorld
{
class Ptr;
}
namespace MWBase
{
/// \brief Interface for dialogue manager (implemented in MWDialogue)
class DialogueManager
{
DialogueManager (const DialogueManager&);
///< not implemented
DialogueManager& operator= (const DialogueManager&);
///< not implemented
public:
DialogueManager() {}
virtual ~DialogueManager() {}
virtual void startDialogue (const MWWorld::Ptr& actor) = 0;
virtual void addTopic (const std::string& topic) = 0;
virtual void askQuestion (const std::string& question,int choice) = 0;
virtual void goodbye() = 0;
///get the faction of the actor you are talking with
virtual std::string getFaction() const = 0;
//calbacks for the GUI
virtual void keywordSelected (const std::string& keyword) = 0;
virtual void goodbyeSelected() = 0;
virtual void questionAnswered (const std::string& answer) = 0;
};
}
#endif

@ -3,18 +3,14 @@
#include <cassert> #include <cassert>
#include "../mwinput/inputmanager.hpp"
#include "../mwscript/scriptmanager.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "world.hpp" #include "world.hpp"
#include "scriptmanager.hpp"
#include "dialoguemanager.hpp"
#include "journal.hpp"
#include "soundmanager.hpp"
#include "mechanicsmanager.hpp"
#include "inputmanager.hpp"
#include "windowmanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment *MWBase::Environment::sThis = 0;
@ -37,37 +33,37 @@ void MWBase::Environment::setWorld (World *world)
mWorld = world; mWorld = world;
} }
void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager) void MWBase::Environment::setSoundManager (SoundManager *soundManager)
{ {
mSoundManager = soundManager; mSoundManager = soundManager;
} }
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager) void MWBase::Environment::setScriptManager (ScriptManager *scriptManager)
{ {
mScriptManager = scriptManager; mScriptManager = scriptManager;
} }
void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager) void MWBase::Environment::setWindowManager (WindowManager *windowManager)
{ {
mWindowManager = windowManager; mWindowManager = windowManager;
} }
void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager) void MWBase::Environment::setMechanicsManager (MechanicsManager *mechanicsManager)
{ {
mMechanicsManager = mechanicsManager; mMechanicsManager = mechanicsManager;
} }
void MWBase::Environment::setDialogueManager (MWDialogue::DialogueManager *dialogueManager) void MWBase::Environment::setDialogueManager (DialogueManager *dialogueManager)
{ {
mDialogueManager = dialogueManager; mDialogueManager = dialogueManager;
} }
void MWBase::Environment::setJournal (MWDialogue::Journal *journal) void MWBase::Environment::setJournal (Journal *journal)
{ {
mJournal = journal; mJournal = journal;
} }
void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager) void MWBase::Environment::setInputManager (InputManager *inputManager)
{ {
mInputManager = inputManager; mInputManager = inputManager;
} }
@ -83,43 +79,43 @@ MWBase::World *MWBase::Environment::getWorld() const
return mWorld; return mWorld;
} }
MWSound::SoundManager *MWBase::Environment::getSoundManager() const MWBase::SoundManager *MWBase::Environment::getSoundManager() const
{ {
assert (mSoundManager); assert (mSoundManager);
return mSoundManager; return mSoundManager;
} }
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const MWBase::ScriptManager *MWBase::Environment::getScriptManager() const
{ {
assert (mScriptManager); assert (mScriptManager);
return mScriptManager; return mScriptManager;
} }
MWGui::WindowManager *MWBase::Environment::getWindowManager() const MWBase::WindowManager *MWBase::Environment::getWindowManager() const
{ {
assert (mWindowManager); assert (mWindowManager);
return mWindowManager; return mWindowManager;
} }
MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const
{ {
assert (mMechanicsManager); assert (mMechanicsManager);
return mMechanicsManager; return mMechanicsManager;
} }
MWDialogue::DialogueManager *MWBase::Environment::getDialogueManager() const MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const
{ {
assert (mDialogueManager); assert (mDialogueManager);
return mDialogueManager; return mDialogueManager;
} }
MWDialogue::Journal *MWBase::Environment::getJournal() const MWBase::Journal *MWBase::Environment::getJournal() const
{ {
assert (mJournal); assert (mJournal);
return mJournal; return mJournal;
} }
MWInput::MWInputManager *MWBase::Environment::getInputManager() const MWBase::InputManager *MWBase::Environment::getInputManager() const
{ {
assert (mInputManager); assert (mInputManager);
return mInputManager; return mInputManager;
@ -150,6 +146,9 @@ void MWBase::Environment::cleanup()
delete mScriptManager; delete mScriptManager;
mScriptManager = 0; mScriptManager = 0;
delete mWindowManager;
mWindowManager = 0;
delete mWorld; delete mWorld;
mWorld = 0; mWorld = 0;
} }

@ -1,40 +1,16 @@
#ifndef GAME_BASE_INVIRONMENT_H #ifndef GAME_BASE_INVIRONMENT_H
#define GAME_BASE_INVIRONMENT_H #define GAME_BASE_INVIRONMENT_H
namespace MWSound namespace MWBase
{
class SoundManager;
}
namespace MWScript
{ {
class World;
class ScriptManager; class ScriptManager;
}
namespace MWGui
{
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace MWDialogue
{
class DialogueManager; class DialogueManager;
class Journal; class Journal;
} class SoundManager;
class MechanicsManager;
namespace MWInput class InputManager;
{ class WindowManager;
struct MWInputManager;
}
namespace MWBase
{
class World;
/// \brief Central hub for mw-subsystems /// \brief Central hub for mw-subsystems
/// ///
@ -47,13 +23,13 @@ namespace MWBase
static Environment *sThis; static Environment *sThis;
World *mWorld; World *mWorld;
MWSound::SoundManager *mSoundManager; SoundManager *mSoundManager;
MWScript::ScriptManager *mScriptManager; ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager; WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager; MechanicsManager *mMechanicsManager;
MWDialogue::DialogueManager *mDialogueManager; DialogueManager *mDialogueManager;
MWDialogue::Journal *mJournal; Journal *mJournal;
MWInput::MWInputManager *mInputManager; InputManager *mInputManager;
float mFrameDuration; float mFrameDuration;
Environment (const Environment&); Environment (const Environment&);
@ -70,38 +46,38 @@ namespace MWBase
void setWorld (World *world); void setWorld (World *world);
void setSoundManager (MWSound::SoundManager *soundManager); void setSoundManager (SoundManager *soundManager);
void setScriptManager (MWScript::ScriptManager *scriptManager); void setScriptManager (MWBase::ScriptManager *scriptManager);
void setWindowManager (MWGui::WindowManager *windowManager); void setWindowManager (WindowManager *windowManager);
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager); void setMechanicsManager (MechanicsManager *mechanicsManager);
void setDialogueManager (MWDialogue::DialogueManager *dialogueManager); void setDialogueManager (DialogueManager *dialogueManager);
void setJournal (MWDialogue::Journal *journal); void setJournal (Journal *journal);
void setInputManager (MWInput::MWInputManager *inputManager); void setInputManager (InputManager *inputManager);
void setFrameDuration (float duration); void setFrameDuration (float duration);
///< Set length of current frame in seconds. ///< Set length of current frame in seconds.
World *getWorld() const; World *getWorld() const;
MWSound::SoundManager *getSoundManager() const; SoundManager *getSoundManager() const;
MWScript::ScriptManager *getScriptManager() const; ScriptManager *getScriptManager() const;
MWGui::WindowManager *getWindowManager() const; WindowManager *getWindowManager() const;
MWMechanics::MechanicsManager *getMechanicsManager() const; MechanicsManager *getMechanicsManager() const;
MWDialogue::DialogueManager *getDialogueManager() const; DialogueManager *getDialogueManager() const;
MWDialogue::Journal *getJournal() const; Journal *getJournal() const;
MWInput::MWInputManager *getInputManager() const; InputManager *getInputManager() const;
float getFrameDuration() const; float getFrameDuration() const;

@ -0,0 +1,44 @@
#ifndef GAME_MWBASE_INPUTMANAGER_H
#define GAME_MWBASE_INPUTMANAGER_H
#include <string>
#include <components/settings/settings.hpp>
namespace MWBase
{
/// \brief Interface for input manager (implemented in MWInput)
class InputManager
{
InputManager (const InputManager&);
///< not implemented
InputManager& operator= (const InputManager&);
///< not implemented
public:
InputManager() {}
virtual ~InputManager() {}
virtual void update(float dt) = 0;
virtual void changeInputMode(bool guiMode) = 0;
virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0;
virtual void setDragDrop(bool dragDrop) = 0;
virtual void toggleControlSwitch (const std::string& sw, bool value) = 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;
};
}
#endif

@ -0,0 +1,73 @@
#ifndef GAME_MWBASE_JOURNAL_H
#define GAME_MWBASE_JOURNAL_H
#include <string>
#include <deque>
#include <map>
#include "../mwdialogue/journalentry.hpp"
#include "../mwdialogue/topic.hpp"
#include "../mwdialogue/quest.hpp"
namespace MWBase
{
/// \brief Interface for the player's journal (implemented in MWDialogue)
class Journal
{
Journal (const Journal&);
///< not implemented
Journal& operator= (const Journal&);
///< not implemented
public:
typedef std::deque<MWDialogue::StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topc, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, MWDialogue::Topic> TTopicContainer; // topic-id, topic-content
typedef TTopicContainer::const_iterator TTopicIter;
public:
Journal() {}
virtual ~Journal() {}
virtual void addEntry (const std::string& id, int index) = 0;
///< Add a journal entry.
virtual void setJournalIndex (const std::string& id, int index) = 0;
///< Set the journal index without adding an entry.
virtual int getJournalIndex (const std::string& id) const = 0;
///< Get the journal index.
virtual void addTopic (const std::string& topicId, const std::string& infoId) = 0;
virtual TEntryIter begin() const = 0;
///< Iterator pointing to the begin of the main journal.
///
/// \note Iterators to main journal entries will never become invalid.
virtual TEntryIter end() const = 0;
///< Iterator pointing past the end of the main journal.
virtual TQuestIter questBegin() const = 0;
///< Iterator pointing to the first quest (sorted by topic ID)
virtual TQuestIter questEnd() const = 0;
///< Iterator pointing past the last quest.
virtual TTopicIter topicBegin() const = 0;
///< Iterator pointing to the first topic (sorted by topic ID)
///
/// \note The topic ID is identical with the user-visible topic string.
virtual TTopicIter topicEnd() const = 0;
///< Iterator pointing past the last topic.
};
}
#endif

@ -0,0 +1,77 @@
#ifndef GAME_MWBASE_MECHANICSMANAGER_H
#define GAME_MWBASE_MECHANICSMANAGER_H
#include <string>
#include <vector>
namespace Ogre
{
class Vector3;
}
namespace ESM
{
struct Class;
}
namespace MWWorld
{
class Ptr;
class CellStore;
}
namespace MWBase
{
/// \brief Interface for game mechanics manager (implemented in MWMechanics)
class MechanicsManager
{
MechanicsManager (const MechanicsManager&);
///< not implemented
MechanicsManager& operator= (const MechanicsManager&);
///< not implemented
public:
MechanicsManager() {}
virtual ~MechanicsManager() {}
virtual void addActor (const MWWorld::Ptr& ptr) = 0;
///< Register an actor for stats management
virtual void removeActor (const MWWorld::Ptr& ptr) = 0;
///< Deregister an actor for stats management
virtual void dropActors (const MWWorld::CellStore *cellStore) = 0;
///< Deregister all actors in the given cell.
virtual void watchActor (const MWWorld::Ptr& ptr) = 0;
///< On each update look for changes in a previously registered actor and update the
/// GUI accordingly.
virtual void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
float duration, bool paused) = 0;
///< Update actor stats and store desired velocity vectors in \a movement
///
/// \param paused In game type does not currently advance (this usually means some GUI
/// component is up).
virtual void setPlayerName (const std::string& name) = 0;
///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male) = 0;
///< Set player race.
virtual void setPlayerBirthsign (const std::string& id) = 0;
///< Set player birthsign.
virtual void setPlayerClass (const std::string& id) = 0;
///< Set player class to stock class.
virtual void setPlayerClass (const ESM::Class& class_) = 0;
///< Set player class to custom class.
};
}
#endif

@ -0,0 +1,62 @@
#ifndef GAME_MWBASE_SCRIPTMANAGER_H
#define GAME_MWBASE_SCRIPTMANAGER_H
#include <string>
namespace Interpreter
{
class Context;
}
namespace Compiler
{
class Locals;
}
namespace MWScript
{
class GlobalScripts;
}
namespace MWBase
{
/// \brief Interface for script manager (implemented in MWScript)
class ScriptManager
{
ScriptManager (const ScriptManager&);
///< not implemented
ScriptManager& operator= (const ScriptManager&);
///< not implemented
public:
ScriptManager() {}
virtual ~ScriptManager() {}
virtual void run (const std::string& name, Interpreter::Context& interpreterContext) = 0;
///< Run the script with the given name (compile first, if not compiled yet)
virtual bool compile (const std::string& name) = 0;
///< Compile script with the given namen
/// \return Success?
virtual std::pair<int, int> compileAll() = 0;
///< Compile all scripts
/// \return count, success
virtual Compiler::Locals& getLocals (const std::string& name) = 0;
///< Return locals for script \a name.
virtual MWScript::GlobalScripts& getGlobalScripts() = 0;
virtual int getLocalIndex (const std::string& scriptId, const std::string& variable,
char type) = 0;
///< Return index of the variable of the given name and type in the given script. Will
/// throw an exception, if there is no such script or variable or the type does not match.
};
}
#endif

@ -0,0 +1,129 @@
#ifndef GAME_MWBASE_SOUNDMANAGER_H
#define GAME_MWBASE_SOUNDMANAGER_H
#include <string>
#include <boost/shared_ptr.hpp>
#include <components/settings/settings.hpp>
#include "../mwworld/ptr.hpp"
namespace Ogre
{
class Vector3;
}
namespace MWWorld
{
class CellStore;
}
namespace MWSound
{
class Sound;
}
namespace MWBase
{
typedef boost::shared_ptr<MWSound::Sound> SoundPtr;
/// \brief Interface for sound manager (implemented in MWSound)
class SoundManager
{
public:
enum PlayMode {
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
* but do not keep it updated (the sound will not move with
* the object and will not stop when the object is deleted. */
};
private:
SoundManager (const SoundManager&);
///< not implemented
SoundManager& operator= (const SoundManager&);
///< not implemented
public:
SoundManager() {}
virtual ~SoundManager() {}
virtual void processChangedSettings(const Settings::CategorySettingVector& settings) = 0;
virtual void stopMusic() = 0;
///< Stops music if it's playing
virtual void streamMusic(const std::string& filename) = 0;
///< Play a soundifle
/// \param filename name of a sound file in "Music/" in the data directory.
virtual void startRandomTitle() = 0;
///< Starts a random track from the current playlist
virtual bool isMusicPlaying() = 0;
///< Returns true if music is playing
virtual void playPlaylist(const std::string &playlist) = 0;
///< Start playing music from the selected folder
/// \param name of the folder that contains the playlist
virtual void say(MWWorld::Ptr reference, const std::string& filename) = 0;
///< Make an actor say some text.
/// \param filename name of a sound file in "Sound/" in the data directory.
virtual void say(const std::string& filename) = 0;
///< Say some text, without an actor ref
/// \param filename name of a sound file in "Sound/" in the data directory.
virtual bool sayDone(MWWorld::Ptr reference=MWWorld::Ptr()) const = 0;
///< Is actor not speaking?
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()) = 0;
///< Stop an actor speaking
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
int mode=Play_Normal) = 0;
///< Play a sound, independently of 3D-position
virtual SoundPtr playSound3D(MWWorld::Ptr reference, const std::string& soundId,
float volume, float pitch, int mode=Play_Normal) = 0;
///< Play a sound from an object
virtual void stopSound3D(MWWorld::Ptr reference, const std::string& soundId) = 0;
///< Stop the given object from playing the given sound,
virtual void stopSound3D(MWWorld::Ptr reference) = 0;
///< Stop the given object from playing all sounds.
virtual void stopSound(const MWWorld::CellStore *cell) = 0;
///< Stop all sounds for the given cell.
virtual void stopSound(const std::string& soundId) = 0;
///< Stop a non-3d looping sound
virtual bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const = 0;
///< Is the given sound currently playing on the given object?
virtual void updateObject(MWWorld::Ptr reference) = 0;
///< Update the position of all sounds connected to the given object.
virtual void update(float duration) = 0;
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir) = 0;
};
inline int operator|(SoundManager::PlayMode a, SoundManager::PlayMode b)
{ return static_cast<int> (a) | static_cast<int> (b); }
inline int operator&(SoundManager::PlayMode a, SoundManager::PlayMode b)
{ return static_cast<int> (a) & static_cast<int> (b); }
}
#endif

@ -0,0 +1,220 @@
#ifndef GAME_MWBASE_WINDOWMANAGER_H
#define GAME_MWBASE_WINDOWMANAGER_H
#include <string>
#include <vector>
#include <map>
#include <components/settings/settings.hpp>
#include "../mwmechanics/stat.hpp"
#include "../mwgui/mode.hpp"
namespace MyGUI
{
class Gui;
class Widget;
class UString;
}
namespace OEngine
{
namespace GUI
{
class Layout;
}
}
namespace ESM
{
struct Class;
}
namespace MWWorld
{
class CellStore;
class Ptr;
}
namespace MWGui
{
class Console;
class SpellWindow;
class TradeWindow;
class ConfirmationDialog;
class CountDialog;
class ScrollWindow;
class BookWindow;
class InventoryWindow;
class ContainerWindow;
class DialogueWindow;
}
namespace MWBase
{
/// \brief Interface for widnow manager (implemented in MWGui)
class WindowManager
{
WindowManager (const WindowManager&);
///< not implemented
WindowManager& operator= (const WindowManager&);
///< not implemented
public:
typedef std::vector<int> SkillList;
WindowManager() {}
virtual ~WindowManager() {}
/**
* Should be called each frame to update windows/gui elements.
* This could mean updating sizes of gui elements or opening
* new dialogs.
*/
virtual void update() = 0;
virtual void pushGuiMode (MWGui::GuiMode mode) = 0;
virtual void popGuiMode() = 0;
virtual void removeGuiMode (MWGui::GuiMode mode) = 0;
///< can be anywhere in the stack
virtual MWGui::GuiMode getMode() const = 0;
virtual bool isGuiMode() const = 0;
virtual void toggleVisible (MWGui::GuiWindow wnd) = 0;
/// Disallow all inventory mode windows
virtual void disallowAll() = 0;
/// Allow one or more windows
virtual void allow (MWGui::GuiWindow wnd) = 0;
virtual bool isAllowed (MWGui::GuiWindow wnd) const = 0;
/// \todo investigate, if we really need to expose every single lousy UI element to the outside world
virtual MWGui::DialogueWindow* getDialogueWindow() = 0;
virtual MWGui::ContainerWindow* getContainerWindow() = 0;
virtual MWGui::InventoryWindow* getInventoryWindow() = 0;
virtual MWGui::BookWindow* getBookWindow() = 0;
virtual MWGui::ScrollWindow* getScrollWindow() = 0;
virtual MWGui::CountDialog* getCountDialog() = 0;
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
virtual MWGui::TradeWindow* getTradeWindow() = 0;
virtual MWGui::SpellWindow* getSpellWindow() = 0;
virtual MWGui::Console* getConsole() = 0;
virtual MyGUI::Gui* getGui() const = 0;
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) = 0;
/// Set value for the given ID.
virtual void setValue (const std::string& id, const MWMechanics::Stat<int>& value) = 0;
virtual void setValue (int parSkill, const MWMechanics::Stat<float>& value) = 0;
virtual void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value) = 0;
virtual void setValue (const std::string& id, const std::string& value) = 0;
virtual void setValue (const std::string& id, int value) = 0;
virtual void setPlayerClass (const ESM::Class &class_) = 0;
///< set current class of player
virtual void configureSkills (const SkillList& major, const SkillList& minor) = 0;
///< configure skill groups, each set contains the skill ID for that group.
virtual void setReputation (int reputation) = 0;
///< set the current reputation value
virtual void setBounty (int bounty) = 0;
///< set the current bounty value
virtual void updateSkillArea() = 0;
///< update display of skills, factions, birth sign, reputation and bounty
virtual void changeCell(MWWorld::CellStore* cell) = 0;
///< change the active cell
virtual void setPlayerPos(const float x, const float y) = 0;
///< set player position in map space
virtual void setPlayerDir(const float x, const float y) = 0;
///< set player view direction in map space
virtual void setFocusObject(const MWWorld::Ptr& focus) = 0;
virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) = 0;
virtual void setMouseVisible(bool visible) = 0;
virtual void getMousePosition(int &x, int &y) = 0;
virtual void getMousePosition(float &x, float &y) = 0;
virtual void setDragDrop(bool dragDrop) = 0;
virtual bool getWorldMouseOver() = 0;
virtual void toggleFogOfWar() = 0;
virtual void toggleFullHelp() = 0;
///< show extra info in item tooltips (owner, script)
virtual bool getFullHelp() const = 0;
virtual void setInteriorMapTexture(const int x, const int y) = 0;
///< set the index of the map texture that should be used (for interiors)
/// sets the visibility of the hud health/magicka/stamina bars
virtual void setHMSVisibility(bool visible) = 0;
/// sets the visibility of the hud minimap
virtual void setMinimapVisibility(bool visible) = 0;
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.
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons) = 0;
virtual int readPressedButton() = 0;
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
virtual void onFrame (float frameDuration) = 0;
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
virtual std::map<int, MWMechanics::Stat<float> > getPlayerSkillValues() = 0;
virtual std::map<int, MWMechanics::Stat<int> > getPlayerAttributeValues() = 0;
virtual SkillList getPlayerMinorSkills() = 0;
virtual SkillList getPlayerMajorSkills() = 0;
/**
* Fetches a GMST string from the store, if there is no setting with the given
* ID or it is not a string the default string is returned.
*
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
virtual const std::string &getGameSettingString(const std::string &id, const std::string &default_) = 0;
virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0;
virtual void executeInConsole (const std::string& path) = 0;
};
}
#endif

@ -46,6 +46,7 @@ namespace MWWorld
namespace MWBase namespace MWBase
{ {
/// \brief Interface for the World (implemented in MWWorld)
class World class World
{ {
World (const World&); World (const World&);
@ -54,14 +55,6 @@ namespace MWBase
World& operator= (const World&); World& operator= (const World&);
///< not implemented ///< not implemented
protected:
virtual void
placeObject(
const MWWorld::Ptr &ptr,
MWWorld::CellStore &cell,
const ESM::Position &pos) = 0;
public: public:
enum RenderMode enum RenderMode
@ -72,6 +65,12 @@ namespace MWBase
Render_Compositors Render_Compositors
}; };
struct DoorMarker
{
std::string name;
float x, y; // world position
};
World() {} World() {}
virtual ~World() {} virtual ~World() {}
@ -115,6 +114,15 @@ namespace MWBase
virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0; virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0;
///< get north vector (OGRE coordinates) for given interior cell ///< 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) = 0;
virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0; virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0;
@ -184,9 +192,12 @@ namespace MWBase
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0; virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
virtual void
moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore &newCell, float x, float y, float z) = 0;
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0; virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z) = 0; virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const = 0; const = 0;
@ -252,6 +263,14 @@ namespace MWBase
virtual bool isSwimming(const MWWorld::Ptr &object) = 0; virtual bool isSwimming(const MWWorld::Ptr &object) = 0;
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) = 0; virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) = 0;
virtual void togglePOV() = 0;
virtual void togglePreviewMode(bool enable) = 0;
virtual bool toggleVanityMode(bool enable, bool force) = 0;
virtual void allowVanityMode(bool allow) = 0;
virtual void togglePlayerLooking(bool enable) = 0;
virtual void renderPlayer() = 0;
}; };
} }

@ -4,6 +4,7 @@
#include <components/esm/loadacti.hpp> #include <components/esm/loadacti.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld//cellstore.hpp" #include "../mwworld//cellstore.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -12,7 +13,6 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
namespace MWClass namespace MWClass
@ -104,4 +104,3 @@ namespace MWClass
return MWWorld::Ptr(&cell.activators.insert(*ref), &cell); return MWWorld::Ptr(&cell.activators.insert(*ref), &cell);
} }
} }

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -15,11 +16,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -64,10 +62,12 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Apparatus::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
} }
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const

@ -7,6 +7,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -18,11 +19,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -67,10 +65,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Armor::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
@ -272,9 +271,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const 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));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return action;
} }
MWWorld::Ptr MWWorld::Ptr

@ -5,6 +5,8 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actionread.hpp" #include "../mwworld/actionread.hpp"
@ -14,11 +16,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -14,13 +15,10 @@
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -65,10 +63,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr, 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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
@ -223,9 +222,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const 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));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return action;
} }
MWWorld::Ptr MWWorld::Ptr

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp" #include "../mwworld/nullaction.hpp"
@ -14,14 +15,11 @@
#include "../mwworld/actionopen.hpp" #include "../mwworld/actionopen.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace namespace
{ {
struct CustomData : public MWWorld::CustomData struct CustomData : public MWWorld::CustomData
@ -94,8 +92,9 @@ namespace MWClass
{ {
// TODO check for key // TODO check for key
std::cout << "Locked container" << std::endl; std::cout << "Locked container" << std::endl;
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0); boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); action->setSound(lockedSound);
return action;
} }
else else
{ {
@ -110,9 +109,10 @@ namespace MWClass
{ {
// Trap activation goes here // Trap activation goes here
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; 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 = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return action;
} }
} }
} }

@ -4,10 +4,11 @@
#include <components/esm/loadcrea.hpp> #include <components/esm/loadcrea.hpp>
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/magiceffects.hpp" #include "../mwmechanics/magiceffects.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp" #include "../mwworld/actiontalk.hpp"
@ -17,7 +18,6 @@
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
namespace namespace
@ -61,10 +61,10 @@ namespace MWClass
data->mCreatureStats.setLevel(ref->base->data.level); data->mCreatureStats.setLevel(ref->base->data.level);
data->mCreatureStats.setHello(ref->base->AI.hello); data->mCreatureStats.setHello(ref->base->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->AI.fight); data->mCreatureStats.setFight(ref->base->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->AI.flee); data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->AI.alarm); data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
// store // store
ptr.getRefData().setCustomData (data.release()); ptr.getRefData().setCustomData (data.release());

@ -59,6 +59,11 @@ namespace MWClass
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual bool
isActor() const {
return true;
}
}; };
} }

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -13,14 +14,11 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -81,17 +79,25 @@ namespace MWClass
// TODO check for key // TODO check for key
// TODO report failure to player (message, sound?). Look up behaviour of original MW. // TODO report failure to player (message, sound?). Look up behaviour of original MW.
std::cout << "Locked!" << std::endl; 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()) if(!ptr.getCellRef().trap.empty())
{ {
// Trap activation // Trap activation
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; 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 = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
return action;
} }
if (ref->ref.teleport) if (ref->ref.teleport)
@ -100,11 +106,11 @@ namespace MWClass
/// \todo remove this if clause once ActionTeleport can also support other actors /// \todo remove this if clause once ActionTeleport can also support other actors
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
{ {
// the player is using the door boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
// 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); action->setSound(openSound);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest)); return action;
} }
else else
{ {
@ -118,8 +124,11 @@ namespace MWClass
// TODO return action for rotating the door // TODO return action for rotating the door
// This is a little pointless, but helps with testing // This is a little pointless, but helps with testing
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0); boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
action->setSound(openSound);
return action;
} }
} }

@ -5,20 +5,18 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -63,10 +61,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Ingredient::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const

@ -5,6 +5,8 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -14,11 +16,8 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
@ -58,7 +57,7 @@ namespace MWClass
physics.insertObjectPhysics(ptr, "meshes\\" + model); physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
if (!ref->base->sound.empty()) { if (!ref->base->sound.empty()) {
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->sound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
} }
} }
@ -95,10 +94,11 @@ namespace MWClass
if (!(ref->base->data.flags & ESM::Light::Carry)) if (!(ref->base->data.flags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Light::getScript (const MWWorld::Ptr& ptr) const std::string Light::getScript (const MWWorld::Ptr& ptr) const
@ -192,9 +192,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr) const 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));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return action;
} }
MWWorld::Ptr MWWorld::Ptr

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -13,14 +14,11 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -65,10 +63,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Lockpick::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
@ -161,9 +160,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const 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));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return action;
} }
MWWorld::Ptr MWWorld::Ptr

@ -7,6 +7,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -14,14 +15,11 @@
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
namespace MWClass namespace MWClass
@ -68,10 +66,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Miscellaneous::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const

@ -11,11 +11,12 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/movement.hpp" #include "../mwmechanics/movement.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp" #include "../mwworld/actiontalk.hpp"
@ -26,7 +27,6 @@
#include "../mwrender/actors.hpp" #include "../mwrender/actors.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
namespace namespace
@ -100,10 +100,10 @@ namespace MWClass
/// \todo do something with npdt12 maybe:p /// \todo do something with npdt12 maybe:p
} }
data->mCreatureStats.setHello(ref->base->AI.hello); data->mCreatureStats.setHello(ref->base->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->AI.fight); data->mCreatureStats.setFight(ref->base->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->AI.flee); data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->AI.alarm); data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
// store // store
ptr.getRefData().setCustomData (data.release()); ptr.getRefData().setCustomData (data.release());

@ -93,6 +93,11 @@ namespace MWClass
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual bool
isActor() const {
return true;
}
}; };
} }

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -13,14 +14,11 @@
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -65,10 +63,12 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Potion::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
action->setSound (getUpSoundId(ptr));
return action;
} }
std::string Potion::getScript (const MWWorld::Ptr& ptr) const std::string Potion::getScript (const MWWorld::Ptr& ptr) const

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -13,14 +14,11 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -64,10 +62,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Probe::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Probe::getScript (const MWWorld::Ptr& ptr) const std::string Probe::getScript (const MWWorld::Ptr& ptr) const
@ -160,9 +159,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr) const 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 MWWorld::Ptr
@ -174,4 +175,3 @@ namespace MWClass
return MWWorld::Ptr(&cell.probes.insert(*ref), &cell); return MWWorld::Ptr(&cell.probes.insert(*ref), &cell);
} }
} }

@ -5,20 +5,18 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -63,10 +61,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Repair::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
std::string Repair::getScript (const MWWorld::Ptr& ptr) const std::string Repair::getScript (const MWWorld::Ptr& ptr) const

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
@ -13,14 +14,11 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp" #include "../mwworld/physicssystem.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -65,10 +63,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Weapon::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, MWSound::Play_NoTrack); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action> ( return action;
new MWWorld::ActionTake (ptr));
} }
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
@ -361,9 +360,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const 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));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr)); return action;
} }
MWWorld::Ptr MWWorld::Ptr

@ -1,5 +1,5 @@
#include "dialoguemanager.hpp" #include "dialoguemanagerimp.hpp"
#include <cctype> #include <cctype>
#include <algorithm> #include <algorithm>
@ -11,33 +11,30 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/scriptmanager.hpp"
#include "../mwbase/journal.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwgui/dialogue.hpp" #include "../mwgui/dialogue.hpp"
#include "../mwgui/window_manager.hpp"
#include "journal.hpp"
#include <iostream> #include <iostream>
#include "../mwscript/extensions.hpp"
#include "../mwscript/scriptmanager.hpp"
#include <components/compiler/exception.hpp> #include <components/compiler/exception.hpp>
#include <components/compiler/errorhandler.hpp> #include <components/compiler/errorhandler.hpp>
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
#include <components/compiler/output.hpp> #include <components/compiler/output.hpp>
#include <components/compiler/scriptparser.hpp>
#include <components/interpreter/interpreter.hpp> #include <components/interpreter/interpreter.hpp>
#include "../mwscript/compilercontext.hpp" #include "../mwscript/compilercontext.hpp"
#include "../mwscript/interpretercontext.hpp" #include "../mwscript/interpretercontext.hpp"
#include <components/compiler/scriptparser.hpp> #include "../mwscript/extensions.hpp"
#include "../mwclass/npc.hpp" #include "../mwclass/npc.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
@ -599,7 +596,7 @@ namespace MWDialogue
} }
} }
void DialogueManager::addTopic(std::string topic) void DialogueManager::addTopic (const std::string& topic)
{ {
mKnownTopics[toLower(topic)] = true; mKnownTopics[toLower(topic)] = true;
} }
@ -772,14 +769,14 @@ namespace MWDialogue
if (mActor.getTypeName() == typeid(ESM::NPC).name()) if (mActor.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>();
if (ref->base->hasAI) if (ref->base->mHasAI)
services = ref->base->AI.services; services = ref->base->mAiData.mServices;
} }
else if (mActor.getTypeName() == typeid(ESM::Creature).name()) else if (mActor.getTypeName() == typeid(ESM::Creature).name())
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>();
if (ref->base->hasAI) if (ref->base->mHasAI)
services = ref->base->AI.services; services = ref->base->mAiData.mServices;
} }
if (services & ESM::NPC::Weapon if (services & ESM::NPC::Weapon
@ -804,7 +801,7 @@ namespace MWDialogue
mChoice = choice; mChoice = choice;
} }
void DialogueManager::keywordSelected(std::string keyword) void DialogueManager::keywordSelected (const std::string& keyword)
{ {
if(!mIsInChoice) if(!mIsInChoice)
{ {
@ -846,11 +843,11 @@ namespace MWDialogue
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
} }
void DialogueManager::questionAnswered(std::string answere) void DialogueManager::questionAnswered (const std::string& answer)
{ {
if(mChoiceMap.find(answere) != mChoiceMap.end()) if(mChoiceMap.find(answer) != mChoiceMap.end())
{ {
mChoice = mChoiceMap[answere]; mChoice = mChoiceMap[answer];
std::vector<ESM::DialInfo>::const_iterator iter; std::vector<ESM::DialInfo>::const_iterator iter;
if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) if(mDialogueMap.find(mLastTopic) != mDialogueMap.end())
@ -888,7 +885,7 @@ namespace MWDialogue
win->addText(error); win->addText(error);
} }
void DialogueManager::askQuestion(std::string question, int choice) void DialogueManager::askQuestion (const std::string& question, int choice)
{ {
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->askQuestion(question); win->askQuestion(question);
@ -896,7 +893,7 @@ namespace MWDialogue
mIsInChoice = true; mIsInChoice = true;
} }
std::string DialogueManager::getFaction() std::string DialogueManager::getFaction() const
{ {
if (mActor.getTypeName() != typeid(ESM::NPC).name()) if (mActor.getTypeName() != typeid(ESM::NPC).name())
return ""; return "";

@ -1,5 +1,7 @@
#ifndef GAME_MMDIALOG_DIALOGUEMANAGER_H #ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#define GAME_MWDIALOG_DIALOGUEMANAGER_H #define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#include "../mwbase/dialoguemanager.hpp"
#include <components/esm/loadinfo.hpp> #include <components/esm/loadinfo.hpp>
@ -9,11 +11,12 @@
#include <components/compiler/output.hpp> #include <components/compiler/output.hpp>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include <map> #include <map>
namespace MWDialogue namespace MWDialogue
{ {
class DialogueManager class DialogueManager : public MWBase::DialogueManager
{ {
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const; bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const;
@ -50,21 +53,21 @@ namespace MWDialogue
DialogueManager (const Compiler::Extensions& extensions); DialogueManager (const Compiler::Extensions& extensions);
void startDialogue (const MWWorld::Ptr& actor); virtual void startDialogue (const MWWorld::Ptr& actor);
void addTopic(std::string topic); virtual void addTopic (const std::string& topic);
void askQuestion(std::string question,int choice); virtual void askQuestion (const std::string& question,int choice);
void goodbye(); virtual void goodbye();
///get the faction of the actor you are talking with ///get the faction of the actor you are talking with
std::string getFaction(); virtual std::string getFaction() const;
//calbacks for the GUI //calbacks for the GUI
void keywordSelected(std::string keyword); virtual void keywordSelected (const std::string& keyword);
void goodbyeSelected(); virtual void goodbyeSelected();
void questionAnswered(std::string answere); virtual void questionAnswered (const std::string& answer);
}; };
} }

@ -1,5 +1,5 @@
#ifndef GAME_MMDIALOGUE_JOURNALENTRY_H #ifndef GAME_MWDIALOGUE_JOURNALENTRY_H
#define GAME_MMDIALOGUE_JOURNALENTRY_H #define GAME_MWDIALOGUE_JOURNALENTRY_H
#include <string> #include <string>

@ -1,10 +1,12 @@
#include "journal.hpp" #include "journalimp.hpp"
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/messagebox.hpp" #include "../mwgui/messagebox.hpp"
namespace MWDialogue namespace MWDialogue

@ -1,9 +1,7 @@
#ifndef GAME_MMDIALOG_JOURNAL_H #ifndef GAME_MWDIALOG_JOURNAL_H
#define GAME_MWDIALOG_JOURNAL_H #define GAME_MWDIALOG_JOURNAL_H
#include <string> #include "../mwbase/journal.hpp"
#include <deque>
#include <map>
#include "journalentry.hpp" #include "journalentry.hpp"
#include "quest.hpp" #include "quest.hpp"
@ -11,19 +9,8 @@
namespace MWDialogue namespace MWDialogue
{ {
/// \brief The player's journal /// \brief The player's journal
class Journal class Journal : public MWBase::Journal
{ {
public:
typedef std::deque<StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, Quest> TQuestContainer; // topc, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, Topic> TTopicContainer; // topic-id, topic-content
typedef TTopicContainer::const_iterator TTopicIter;
private:
TEntryContainer mJournal; TEntryContainer mJournal;
TQuestContainer mQuests; TQuestContainer mQuests;
TTopicContainer mTopics; TTopicContainer mTopics;
@ -34,37 +21,37 @@ namespace MWDialogue
Journal(); Journal();
void addEntry (const std::string& id, int index); virtual void addEntry (const std::string& id, int index);
///< Add a journal entry. ///< Add a journal entry.
void setJournalIndex (const std::string& id, int index); virtual void setJournalIndex (const std::string& id, int index);
///< Set the journal index without adding an entry. ///< Set the journal index without adding an entry.
int getJournalIndex (const std::string& id) const; virtual int getJournalIndex (const std::string& id) const;
///< Get the journal index. ///< Get the journal index.
void addTopic (const std::string& topicId, const std::string& infoId); virtual void addTopic (const std::string& topicId, const std::string& infoId);
TEntryIter begin() const; virtual TEntryIter begin() const;
///< Iterator pointing to the begin of the main journal. ///< Iterator pointing to the begin of the main journal.
/// ///
/// \note Iterators to main journal entries will never become invalid. /// \note Iterators to main journal entries will never become invalid.
TEntryIter end() const; virtual TEntryIter end() const;
///< Iterator pointing past the end of the main journal. ///< Iterator pointing past the end of the main journal.
TQuestIter questBegin() const; virtual TQuestIter questBegin() const;
///< Iterator pointing to the first quest (sorted by topic ID) ///< Iterator pointing to the first quest (sorted by topic ID)
TQuestIter questEnd() const; virtual TQuestIter questEnd() const;
///< Iterator pointing past the last quest. ///< Iterator pointing past the last quest.
TTopicIter topicBegin() const; virtual TTopicIter topicBegin() const;
///< Iterator pointing to the first topic (sorted by topic ID) ///< Iterator pointing to the first topic (sorted by topic ID)
/// ///
/// \note The topic ID is identical with the user-visible topic string. /// \note The topic ID is identical with the user-visible topic string.
TTopicIter topicEnd() const; virtual TTopicIter topicEnd() const;
///< Iterator pointing past the last topic. ///< Iterator pointing past the last topic.
}; };
} }

@ -1,4 +1,4 @@
#ifndef GAME_MMDIALOG_QUEST_H #ifndef GAME_MWDIALOG_QUEST_H
#define GAME_MWDIALOG_QUEST_H #define GAME_MWDIALOG_QUEST_H
#include "topic.hpp" #include "topic.hpp"

@ -1,4 +1,4 @@
#ifndef GAME_MMDIALOG_TOPIC_H #ifndef GAME_MWDIALOG_TOPIC_H
#define GAME_MWDIALOG_TOPIC_H #define GAME_MWDIALOG_TOPIC_H
#include <string> #include <string>

@ -4,15 +4,13 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp"
namespace namespace
{ {
std::string getIconPath(MWWorld::Ptr ptr) std::string getIconPath(MWWorld::Ptr ptr)
@ -28,7 +26,7 @@ namespace
namespace MWGui namespace MWGui
{ {
AlchemyWindow::AlchemyWindow(WindowManager& parWindowManager) AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_alchemy_window.layout", parWindowManager) : WindowBase("openmw_alchemy_window.layout", parWindowManager)
, ContainerBase(0) , ContainerBase(0)
{ {

@ -10,7 +10,7 @@ namespace MWGui
class AlchemyWindow : public WindowBase, public ContainerBase class AlchemyWindow : public WindowBase, public ContainerBase
{ {
public: public:
AlchemyWindow(WindowManager& parWindowManager); AlchemyWindow(MWBase::WindowManager& parWindowManager);
virtual void open(); virtual void open();

@ -1,15 +1,20 @@
#include "birth.hpp" #include "birth.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "components/esm_store/store.hpp"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "widgets.hpp"
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
BirthDialog::BirthDialog(WindowManager& parWindowManager) BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_birth.layout", parWindowManager) : WindowBase("openmw_chargen_birth.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
@ -60,9 +65,9 @@ void BirthDialog::setNextButtonShow(bool shown)
void BirthDialog::open() void BirthDialog::open()
{ {
WindowBase::open();
updateBirths(); updateBirths();
updateSpells(); updateSpells();
setVisible(true);
} }
@ -114,7 +119,7 @@ void BirthDialog::updateBirths()
{ {
mBirthList->removeAllItems(); mBirthList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
@ -144,7 +149,7 @@ void BirthDialog::updateSpells()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId);
std::string texturePath = std::string("textures\\") + birth->texture; std::string texturePath = std::string("textures\\") + birth->texture;

@ -10,14 +10,13 @@
namespace MWGui namespace MWGui
{ {
/// \todo remove
using namespace MyGUI; using namespace MyGUI;
class WindowManager;
class BirthDialog : public WindowBase class BirthDialog : public WindowBase
{ {
public: public:
BirthDialog(WindowManager& parWindowManager); BirthDialog(MWBase::WindowManager& parWindowManager);
enum Gender enum Gender
{ {
@ -29,7 +28,7 @@ namespace MWGui
void setBirthId(const std::string &raceId); void setBirthId(const std::string &raceId);
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void open(); virtual void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;

@ -4,17 +4,17 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "formatting.hpp" #include "formatting.hpp"
#include "window_manager.hpp"
using namespace MWGui; using namespace MWGui;
BookWindow::BookWindow (WindowManager& parWindowManager) : BookWindow::BookWindow (MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_book.layout", parWindowManager) WindowBase("openmw_book.layout", parWindowManager)
{ {
getWidget(mCloseButton, "CloseButton"); getWidget(mCloseButton, "CloseButton");
@ -98,7 +98,7 @@ void BookWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack); MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
MWWorld::ActionTake take(mBook); MWWorld::ActionTake take(mBook);
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

@ -10,7 +10,7 @@ namespace MWGui
class BookWindow : public WindowBase class BookWindow : public WindowBase
{ {
public: public:
BookWindow(WindowManager& parWindowManager); BookWindow(MWBase::WindowManager& parWindowManager);
void open(MWWorld::Ptr book); void open(MWWorld::Ptr book);
void setTakeButtonShow(bool show); void setTakeButtonShow(bool show);
@ -43,4 +43,3 @@ namespace MWGui
} }
#endif #endif

@ -9,7 +9,8 @@
#include "mode.hpp" #include "mode.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
namespace namespace
{ {
@ -103,11 +104,19 @@ namespace
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
} }
} }; } };
struct ClassPoint
{
const char *id;
// Specialization points to match, in order: Stealth, Combat, Magic
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
unsigned int points[3];
};
} }
using namespace MWGui; using namespace MWGui;
CharacterCreation::CharacterCreation(WindowManager* _wm) CharacterCreation::CharacterCreation(MWBase::WindowManager* _wm)
: mNameDialog(0) : mNameDialog(0)
, mRaceDialog(0) , mRaceDialog(0)
, mClassChoiceDialog(0) , mClassChoiceDialog(0)
@ -178,64 +187,64 @@ void CharacterCreation::spawnDialog(const char id)
switch (id) switch (id)
{ {
case GM_Name: case GM_Name:
if(mNameDialog)
mWM->removeDialog(mNameDialog); mWM->removeDialog(mNameDialog);
mNameDialog = 0;
mNameDialog = new TextInputDialog(*mWM); mNameDialog = new TextInputDialog(*mWM);
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name")); mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
mNameDialog->setTextInput(mPlayerName); mNameDialog->setTextInput(mPlayerName);
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen); mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone); mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
mNameDialog->open(); mNameDialog->setVisible(true);
break; break;
case GM_Race: case GM_Race:
if (mRaceDialog)
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
mRaceDialog = new RaceDialog(*mWM); mRaceDialog = new RaceDialog(*mWM);
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
mRaceDialog->setRaceId(mPlayerRaceId); mRaceDialog->setRaceId(mPlayerRaceId);
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack); mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
mRaceDialog->open(); mRaceDialog->setVisible(true);;
break; break;
case GM_Class: case GM_Class:
if (mClassChoiceDialog)
mWM->removeDialog(mClassChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
mClassChoiceDialog = 0;
mClassChoiceDialog = new ClassChoiceDialog(*mWM); mClassChoiceDialog = new ClassChoiceDialog(*mWM);
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
mClassChoiceDialog->open(); mClassChoiceDialog->setVisible(true);
break; break;
case GM_ClassPick: case GM_ClassPick:
if (mPickClassDialog)
mWM->removeDialog(mPickClassDialog); mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
mPickClassDialog = new PickClassDialog(*mWM); mPickClassDialog = new PickClassDialog(*mWM);
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mPickClassDialog->setClassId(mPlayerClass.name); mPickClassDialog->setClassId(mPlayerClass.name);
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
mPickClassDialog->open(); mPickClassDialog->setVisible(true);
break; break;
case GM_Birth: case GM_Birth:
if (mBirthSignDialog)
mWM->removeDialog(mBirthSignDialog); mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog = new BirthDialog(*mWM);
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
mBirthSignDialog->open(); mBirthSignDialog->setVisible(true);
break; break;
case GM_ClassCreate: case GM_ClassCreate:
if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
mCreateClassDialog = new CreateClassDialog(*mWM); mCreateClassDialog = new CreateClassDialog(*mWM);
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone); mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack); mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
mCreateClassDialog->open(); mCreateClassDialog->setVisible(true);
break; break;
case GM_ClassGenerate: case GM_ClassGenerate:
mGenerateClassStep = 0; mGenerateClassStep = 0;
@ -246,8 +255,8 @@ void CharacterCreation::spawnDialog(const char id)
showClassQuestionDialog(); showClassQuestionDialog();
break; break;
case GM_Review: case GM_Review:
if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mReviewDialog = new ReviewDialog(*mWM); mReviewDialog = new ReviewDialog(*mWM);
mReviewDialog->setPlayerName(mPlayerName); mReviewDialog->setPlayerName(mPlayerName);
mReviewDialog->setRace(mPlayerRaceId); mReviewDialog->setRace(mPlayerRaceId);
@ -259,20 +268,20 @@ void CharacterCreation::spawnDialog(const char id)
mReviewDialog->setFatigue(mPlayerFatigue); mReviewDialog->setFatigue(mPlayerFatigue);
{ {
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > attributes = mWM->getPlayerAttributeValues(); std::map<int, MWMechanics::Stat<int> > attributes = mWM->getPlayerAttributeValues();
for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = attributes.begin(); for (std::map<int, MWMechanics::Stat<int> >::iterator it = attributes.begin();
it != attributes.end(); ++it) it != attributes.end(); ++it)
{ {
mReviewDialog->setAttribute(it->first, it->second); mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (it->first), it->second);
} }
} }
{ {
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > skills = mWM->getPlayerSkillValues(); std::map<int, MWMechanics::Stat<float> > skills = mWM->getPlayerSkillValues();
for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = skills.begin(); for (std::map<int, MWMechanics::Stat<float> >::iterator it = skills.begin();
it != skills.end(); ++it) it != skills.end(); ++it)
{ {
mReviewDialog->setSkillValue(it->first, it->second); mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (it->first), it->second);
} }
mReviewDialog->configureSkills(mWM->getPlayerMajorSkills(), mWM->getPlayerMinorSkills()); mReviewDialog->configureSkills(mWM->getPlayerMajorSkills(), mWM->getPlayerMinorSkills());
} }
@ -280,7 +289,7 @@ void CharacterCreation::spawnDialog(const char id)
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack); mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog); mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
mReviewDialog->open(); mReviewDialog->setVisible(true);
break; break;
} }
} }
@ -302,24 +311,24 @@ void CharacterCreation::setPlayerFatigue (const MWMechanics::DynamicStat<int>& v
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow) void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
{ {
if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mWM->popGuiMode(); mWM->popGuiMode();
} }
void CharacterCreation::onReviewDialogBack() void CharacterCreation::onReviewDialogBack()
{ {
if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mWM->pushGuiMode(GM_Birth); mWM->pushGuiMode(GM_Birth);
} }
void CharacterCreation::onReviewActivateDialog(int parDialog) void CharacterCreation::onReviewActivateDialog(int parDialog)
{ {
if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mCreationStage = CSE_ReviewNext; mCreationStage = CSE_ReviewNext;
mWM->popGuiMode(); mWM->popGuiMode();
@ -354,6 +363,7 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
mWM->setPlayerClass(mPlayerClass); mWM->setPlayerClass(mPlayerClass);
} }
mWM->removeDialog(mPickClassDialog); mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
} }
//TODO This bit gets repeated a few times; wrap it in a function //TODO This bit gets repeated a few times; wrap it in a function
@ -382,6 +392,7 @@ void CharacterCreation::onPickClassDialogBack()
if (!classId.empty()) if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
mWM->removeDialog(mPickClassDialog); mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
} }
mWM->popGuiMode(); mWM->popGuiMode();
@ -389,11 +400,9 @@ void CharacterCreation::onPickClassDialogBack()
} }
void CharacterCreation::onClassChoice(int _index) void CharacterCreation::onClassChoice(int _index)
{
if (mClassChoiceDialog)
{ {
mWM->removeDialog(mClassChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
} mClassChoiceDialog = 0;
mWM->popGuiMode(); mWM->popGuiMode();
@ -423,6 +432,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
mWM->setValue("name", mPlayerName); mWM->setValue("name", mPlayerName);
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName); MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
mWM->removeDialog(mNameDialog); mWM->removeDialog(mNameDialog);
mNameDialog = 0;
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
@ -450,6 +460,7 @@ void CharacterCreation::onRaceDialogBack()
if (!mPlayerRaceId.empty()) if (!mPlayerRaceId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
} }
mWM->popGuiMode(); mWM->popGuiMode();
@ -465,6 +476,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
if (!mPlayerRaceId.empty()) if (!mPlayerRaceId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
@ -492,6 +504,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
if (!mPlayerBirthSignId.empty()) if (!mPlayerBirthSignId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId); MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
mWM->removeDialog(mBirthSignDialog); mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
} }
if (mCreationStage >= CSE_BirthSignChosen) if (mCreationStage >= CSE_BirthSignChosen)
@ -512,6 +525,7 @@ void CharacterCreation::onBirthSignDialogBack()
{ {
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId()); MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
mWM->removeDialog(mBirthSignDialog); mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
} }
mWM->popGuiMode(); mWM->popGuiMode();
@ -547,6 +561,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
mWM->setPlayerClass(klass); mWM->setPlayerClass(klass);
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
@ -568,8 +583,8 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
void CharacterCreation::onCreateClassDialogBack() void CharacterCreation::onCreateClassDialogBack()
{ {
if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
mWM->popGuiMode(); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class); mWM->pushGuiMode(GM_Class);
@ -579,8 +594,9 @@ void CharacterCreation::onClassQuestionChosen(int _index)
{ {
MWBase::Environment::get().getSoundManager()->stopSay(); MWBase::Environment::get().getSoundManager()->stopSay();
if (mGenerateClassQuestionDialog)
mWM->removeDialog(mGenerateClassQuestionDialog); mWM->removeDialog(mGenerateClassQuestionDialog);
mGenerateClassQuestionDialog = 0;
if (_index < 0 || _index >= 3) if (_index < 0 || _index >= 3)
{ {
mWM->popGuiMode(); mWM->popGuiMode();
@ -657,13 +673,14 @@ void CharacterCreation::showClassQuestionDialog()
} }
} }
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM); mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
mGenerateClassResultDialog->setClassId(mGenerateClass); mGenerateClassResultDialog->setClassId(mGenerateClass);
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack); mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone); mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
mGenerateClassResultDialog->open(); mGenerateClassResultDialog->setVisible(true);
return; return;
} }
@ -674,8 +691,9 @@ void CharacterCreation::showClassQuestionDialog()
return; return;
} }
if (mGenerateClassQuestionDialog)
mWM->removeDialog(mGenerateClassQuestionDialog); mWM->removeDialog(mGenerateClassQuestionDialog);
mGenerateClassQuestionDialog = 0;
mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM); mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM);
InfoBoxDialog::ButtonList buttons; InfoBoxDialog::ButtonList buttons;
@ -685,7 +703,7 @@ void CharacterCreation::showClassQuestionDialog()
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
mGenerateClassQuestionDialog->setButtons(buttons); mGenerateClassQuestionDialog->setButtons(buttons);
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
mGenerateClassQuestionDialog->open(); mGenerateClassQuestionDialog->setVisible(true);
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound); MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound);
} }
@ -695,8 +713,9 @@ void CharacterCreation::onGenerateClassBack()
if(mCreationStage < CSE_ClassChosen) if(mCreationStage < CSE_ClassChosen)
mCreationStage = CSE_ClassChosen; mCreationStage = CSE_ClassChosen;
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
mWM->popGuiMode(); mWM->popGuiMode();
@ -705,8 +724,9 @@ void CharacterCreation::onGenerateClassBack()
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{ {
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass); const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass);
mPlayerClass = *klass; mPlayerClass = *klass;

@ -1,18 +1,15 @@
#ifndef CHARACTER_CREATION_HPP #ifndef CHARACTER_CREATION_HPP
#define CHARACTER_CREATION_HPP #define CHARACTER_CREATION_HPP
#include "window_manager.hpp"
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
namespace MWGui namespace MWGui
{ {
class WindowManager;
class WindowBase; class WindowBase;
class TextInputDialog; class TextInputDialog;
@ -32,7 +29,7 @@ namespace MWGui
public: public:
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
CharacterCreation(WindowManager* _wm); CharacterCreation(MWBase::WindowManager* _wm);
~CharacterCreation(); ~CharacterCreation();
//Show a dialog //Show a dialog
@ -61,7 +58,7 @@ namespace MWGui
BirthDialog* mBirthSignDialog; BirthDialog* mBirthSignDialog;
ReviewDialog* mReviewDialog; ReviewDialog* mReviewDialog;
WindowManager* mWM; MWBase::WindowManager* mWM;
//Player data //Player data
std::string mPlayerName; std::string mPlayerName;

@ -7,7 +7,10 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "window_manager.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
#undef min #undef min
@ -17,7 +20,7 @@ using namespace MWGui;
/* GenerateClassResultDialog */ /* GenerateClassResultDialog */
GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowManager) GenerateClassResultDialog::GenerateClassResultDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_generate_class_result.layout", parWindowManager) : WindowBase("openmw_chargen_generate_class_result.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
@ -43,11 +46,6 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23); backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23);
} }
void GenerateClassResultDialog::open()
{
setVisible(true);
}
std::string GenerateClassResultDialog::getClassId() const std::string GenerateClassResultDialog::getClassId() const
{ {
return mClassName->getCaption(); return mClassName->getCaption();
@ -57,8 +55,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
{ {
mCurrentClassId = classId; mCurrentClassId = classId;
mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
const ESMS::ESMStore &store = mWindowManager.getStore(); mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->name);
mClassName->setCaption(store.classes.find(mCurrentClassId)->name);
} }
// widget controls // widget controls
@ -75,7 +72,7 @@ void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
/* PickClassDialog */ /* PickClassDialog */
PickClassDialog::PickClassDialog(WindowManager& parWindowManager) PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_class.layout", parWindowManager) : WindowBase("openmw_chargen_class.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
@ -141,7 +138,6 @@ void PickClassDialog::open()
{ {
updateClasses(); updateClasses();
updateStats(); updateStats();
setVisible(true);
} }
@ -193,7 +189,7 @@ void PickClassDialog::updateClasses()
{ {
mClassList->removeAllItems(); mClassList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
@ -217,7 +213,7 @@ void PickClassDialog::updateStats()
{ {
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
return; return;
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Class *klass = store.classes.search(mCurrentClassId); const ESM::Class *klass = store.classes.search(mCurrentClassId);
if (!klass) if (!klass)
return; return;
@ -281,7 +277,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
widget->setSize(width, pos); widget->setSize(width, pos);
} }
InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager) InfoBoxDialog::InfoBoxDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_infobox.layout", parWindowManager) : WindowBase("openmw_infobox.layout", parWindowManager)
, mCurrentButton(-1) , mCurrentButton(-1)
{ {
@ -339,7 +335,6 @@ void InfoBoxDialog::open()
layoutVertically(mMainWidget, 4 + 6); layoutVertically(mMainWidget, 4 + 6);
center(); center();
setVisible(true);
} }
int InfoBoxDialog::getChosenButton() const int InfoBoxDialog::getChosenButton() const
@ -365,7 +360,7 @@ void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
/* ClassChoiceDialog */ /* ClassChoiceDialog */
ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager) ClassChoiceDialog::ClassChoiceDialog(MWBase::WindowManager& parWindowManager)
: InfoBoxDialog(parWindowManager) : InfoBoxDialog(parWindowManager)
{ {
setText(""); setText("");
@ -379,7 +374,7 @@ ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager)
/* CreateClassDialog */ /* CreateClassDialog */
CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) CreateClassDialog::CreateClassDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_create_class.layout", parWindowManager) : WindowBase("openmw_chargen_create_class.layout", parWindowManager)
, mSpecDialog(nullptr) , mSpecDialog(nullptr)
, mAttribDialog(nullptr) , mAttribDialog(nullptr)
@ -547,36 +542,22 @@ void CreateClassDialog::setNextButtonShow(bool shown)
descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23); descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23);
} }
void CreateClassDialog::open()
{
setVisible(true);
}
// widget controls // widget controls
void CreateClassDialog::onDialogCancel() void CreateClassDialog::onDialogCancel()
{
if (mSpecDialog)
{ {
mWindowManager.removeDialog(mSpecDialog); mWindowManager.removeDialog(mSpecDialog);
mSpecDialog = 0; mSpecDialog = 0;
}
if (mAttribDialog)
{
mWindowManager.removeDialog(mAttribDialog); mWindowManager.removeDialog(mAttribDialog);
mAttribDialog = 0; mAttribDialog = 0;
}
if (mSkillDialog)
{
mWindowManager.removeDialog(mSkillDialog); mWindowManager.removeDialog(mSkillDialog);
mSkillDialog = 0; mSkillDialog = 0;
}
if (mDescDialog)
{
mWindowManager.removeDialog(mDescDialog); mWindowManager.removeDialog(mDescDialog);
mDescDialog = 0; mDescDialog = 0;
} }
}
void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
{ {
@ -701,8 +682,8 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
/* SelectSpecializationDialog */ /* SelectSpecializationDialog */
SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowManager) SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_specialization.layout", parWindowManager) : WindowModal("openmw_chargen_select_specialization.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -734,13 +715,10 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
int buttonWidth = cancelButton->getTextSize().width + 24; int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21); cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21);
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
} }
SelectSpecializationDialog::~SelectSpecializationDialog() SelectSpecializationDialog::~SelectSpecializationDialog()
{ {
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
} }
// widget controls // widget controls
@ -766,8 +744,8 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender)
/* SelectAttributeDialog */ /* SelectAttributeDialog */
SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager) SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_attribute.layout", parWindowManager) : WindowModal("openmw_chargen_select_attribute.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -792,13 +770,10 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
int buttonWidth = cancelButton->getTextSize().width + 24; int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21); cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21);
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
} }
SelectAttributeDialog::~SelectAttributeDialog() SelectAttributeDialog::~SelectAttributeDialog()
{ {
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
} }
// widget controls // widget controls
@ -818,8 +793,8 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender)
/* SelectSkillDialog */ /* SelectSkillDialog */
SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) SelectSkillDialog::SelectSkillDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_skill.layout", parWindowManager) : WindowModal("openmw_chargen_select_skill.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -891,12 +866,10 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
int buttonWidth = cancelButton->getTextSize().width + 24; int buttonWidth = cancelButton->getTextSize().width + 24;
cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21); cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21);
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
} }
SelectSkillDialog::~SelectSkillDialog() SelectSkillDialog::~SelectSkillDialog()
{ {
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
} }
// widget controls // widget controls
@ -914,8 +887,8 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender)
/* DescriptionDialog */ /* DescriptionDialog */
DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_class_description.layout", parWindowManager) : WindowModal("openmw_chargen_class_description.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -931,13 +904,10 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
} }
DescriptionDialog::~DescriptionDialog() DescriptionDialog::~DescriptionDialog()
{ {
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
} }
// widget controls // widget controls

@ -12,14 +12,13 @@
namespace MWGui namespace MWGui
{ {
/// \todo remove!
using namespace MyGUI; using namespace MyGUI;
class WindowManager;
class InfoBoxDialog : public WindowBase class InfoBoxDialog : public WindowBase
{ {
public: public:
InfoBoxDialog(WindowManager& parWindowManager); InfoBoxDialog(MWBase::WindowManager& parWindowManager);
typedef std::vector<std::string> ButtonList; typedef std::vector<std::string> ButtonList;
@ -27,7 +26,7 @@ namespace MWGui
std::string getText() const; std::string getText() const;
void setButtons(ButtonList &buttons); void setButtons(ButtonList &buttons);
void open(); virtual void open();
int getChosenButton() const; int getChosenButton() const;
// Events // Events
@ -64,19 +63,17 @@ namespace MWGui
Class_Create = 2, Class_Create = 2,
Class_Back = 3 Class_Back = 3
}; };
ClassChoiceDialog(WindowManager& parWindowManager); ClassChoiceDialog(MWBase::WindowManager& parWindowManager);
}; };
class GenerateClassResultDialog : public WindowBase class GenerateClassResultDialog : public WindowBase
{ {
public: public:
GenerateClassResultDialog(WindowManager& parWindowManager); GenerateClassResultDialog(MWBase::WindowManager& parWindowManager);
std::string getClassId() const; std::string getClassId() const;
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
@ -99,13 +96,13 @@ namespace MWGui
class PickClassDialog : public WindowBase class PickClassDialog : public WindowBase
{ {
public: public:
PickClassDialog(WindowManager& parWindowManager); PickClassDialog(MWBase::WindowManager& parWindowManager);
const std::string &getClassId() const { return mCurrentClassId; } const std::string &getClassId() const { return mCurrentClassId; }
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void open(); virtual void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
@ -135,10 +132,10 @@ namespace MWGui
std::string mCurrentClassId; std::string mCurrentClassId;
}; };
class SelectSpecializationDialog : public WindowBase class SelectSpecializationDialog : public WindowModal
{ {
public: public:
SelectSpecializationDialog(WindowManager& parWindowManager); SelectSpecializationDialog(MWBase::WindowManager& parWindowManager);
~SelectSpecializationDialog(); ~SelectSpecializationDialog();
ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; } ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
@ -166,10 +163,10 @@ namespace MWGui
ESM::Class::Specialization mSpecializationId; ESM::Class::Specialization mSpecializationId;
}; };
class SelectAttributeDialog : public WindowBase class SelectAttributeDialog : public WindowModal
{ {
public: public:
SelectAttributeDialog(WindowManager& parWindowManager); SelectAttributeDialog(MWBase::WindowManager& parWindowManager);
~SelectAttributeDialog(); ~SelectAttributeDialog();
ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; } ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
@ -199,10 +196,10 @@ namespace MWGui
ESM::Attribute::AttributeID mAttributeId; ESM::Attribute::AttributeID mAttributeId;
}; };
class SelectSkillDialog : public WindowBase class SelectSkillDialog : public WindowModal
{ {
public: public:
SelectSkillDialog(WindowManager& parWindowManager); SelectSkillDialog(MWBase::WindowManager& parWindowManager);
~SelectSkillDialog(); ~SelectSkillDialog();
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
@ -235,10 +232,10 @@ namespace MWGui
ESM::Skill::SkillEnum mSkillId; ESM::Skill::SkillEnum mSkillId;
}; };
class DescriptionDialog : public WindowBase class DescriptionDialog : public WindowModal
{ {
public: public:
DescriptionDialog(WindowManager& parWindowManager); DescriptionDialog(MWBase::WindowManager& parWindowManager);
~DescriptionDialog(); ~DescriptionDialog();
std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; } std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; }
@ -254,7 +251,7 @@ namespace MWGui
class CreateClassDialog : public WindowBase class CreateClassDialog : public WindowBase
{ {
public: public:
CreateClassDialog(WindowManager& parWindowManager); CreateClassDialog(MWBase::WindowManager& parWindowManager);
virtual ~CreateClassDialog(); virtual ~CreateClassDialog();
std::string getName() const; std::string getName() const;
@ -265,7 +262,6 @@ namespace MWGui
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const; std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;

@ -7,8 +7,8 @@
namespace MWGui namespace MWGui
{ {
ConfirmationDialog::ConfirmationDialog(WindowManager& parWindowManager) : ConfirmationDialog::ConfirmationDialog(MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_confirmation_dialog.layout", parWindowManager) WindowModal("openmw_confirmation_dialog.layout", parWindowManager)
{ {
getWidget(mMessage, "Message"); getWidget(mMessage, "Message");
getWidget(mOkButton, "OkButton"); getWidget(mOkButton, "OkButton");
@ -32,9 +32,6 @@ namespace MWGui
center(); center();
// make other gui elements inaccessible while this dialog is open
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
int okButtonWidth = mOkButton->getTextSize().width + 24; int okButtonWidth = mOkButton->getTextSize().width + 24;
mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth, mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth,
mOkButton->getTop(), mOkButton->getTop(),
@ -52,19 +49,13 @@ namespace MWGui
{ {
eventCancelClicked(); eventCancelClicked();
close(); setVisible(false);
} }
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender) void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
{ {
eventOkClicked(); eventOkClicked();
close();
}
void ConfirmationDialog::close()
{
setVisible(false); setVisible(false);
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
} }
} }

@ -5,10 +5,10 @@
namespace MWGui namespace MWGui
{ {
class ConfirmationDialog : public WindowBase class ConfirmationDialog : public WindowModal
{ {
public: public:
ConfirmationDialog(WindowManager& parWindowManager); ConfirmationDialog(MWBase::WindowManager& parWindowManager);
void open(const std::string& message); void open(const std::string& message);
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
@ -26,8 +26,6 @@ namespace MWGui
void onCancelButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender);
void onOkButtonClicked(MyGUI::Widget* _sender); void onOkButtonClicked(MyGUI::Widget* _sender);
void close();
}; };
} }

@ -10,6 +10,8 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
@ -18,11 +20,6 @@
#include "../mwclass/container.hpp" #include "../mwclass/container.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "countdialog.hpp" #include "countdialog.hpp"
#include "tradewindow.hpp" #include "tradewindow.hpp"
@ -594,7 +591,7 @@ MWWorld::ContainerStore& ContainerBase::getContainerStore()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
: ContainerBase(dragAndDrop) : ContainerBase(dragAndDrop)
, WindowBase("openmw_container_window.layout", parWindowManager) , WindowBase("openmw_container_window.layout", parWindowManager)
{ {

@ -127,7 +127,7 @@ namespace MWGui
class ContainerWindow : public ContainerBase, public WindowBase class ContainerWindow : public ContainerBase, public WindowBase
{ {
public: public:
ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop); ContainerWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
virtual ~ContainerWindow(); virtual ~ContainerWindow();

@ -7,8 +7,8 @@
namespace MWGui namespace MWGui
{ {
CountDialog::CountDialog(WindowManager& parWindowManager) : CountDialog::CountDialog(MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_count_window.layout", parWindowManager) WindowModal("openmw_count_window.layout", parWindowManager)
{ {
getWidget(mSlider, "CountSlider"); getWidget(mSlider, "CountSlider");
getWidget(mItemEdit, "ItemEdit"); getWidget(mItemEdit, "ItemEdit");
@ -40,9 +40,6 @@ namespace MWGui
width, width,
mMainWidget->getHeight()); mMainWidget->getHeight());
// make other gui elements inaccessible while this dialog is open
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
MyGUI::InputManager::getInstance().setKeyFocusWidget(mItemEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mItemEdit);
mSlider->setScrollPosition(maxCount-1); mSlider->setScrollPosition(maxCount-1);
@ -63,14 +60,14 @@ namespace MWGui
void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender) void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
close(); setVisible(false);
} }
void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender) void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender)
{ {
eventOkClicked(NULL, mSlider->getScrollPosition()+1); eventOkClicked(NULL, mSlider->getScrollPosition()+1);
close(); setVisible(false);
} }
void CountDialog::onEditTextChange(MyGUI::EditBox* _sender) void CountDialog::onEditTextChange(MyGUI::EditBox* _sender)
@ -99,10 +96,4 @@ namespace MWGui
{ {
mItemEdit->setCaption(boost::lexical_cast<std::string>(_position+1)); mItemEdit->setCaption(boost::lexical_cast<std::string>(_position+1));
} }
void CountDialog::close()
{
setVisible(false);
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
}
} }

@ -5,10 +5,10 @@
namespace MWGui namespace MWGui
{ {
class CountDialog : public WindowBase class CountDialog : public WindowModal
{ {
public: public:
CountDialog(WindowManager& parWindowManager); CountDialog(MWBase::WindowManager& parWindowManager);
void open(const std::string& item, const std::string& message, const int maxCount); void open(const std::string& item, const std::string& message, const int maxCount);
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt; typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;
@ -30,8 +30,6 @@ namespace MWGui
void onOkButtonClicked(MyGUI::Widget* _sender); void onOkButtonClicked(MyGUI::Widget* _sender);
void onEditTextChange(MyGUI::EditBox* _sender); void onEditTextChange(MyGUI::EditBox* _sender);
void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position); void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position);
void close();
}; };
} }

@ -16,4 +16,5 @@ CursorReplace::CursorReplace()
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize2.png", 45); OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize2.png", 45);
OEngine::Render::Atlas::createFromFile("atlas1.cfg", "mwgui1", "textures\\"); OEngine::Render::Atlas::createFromFile("atlas1.cfg", "mwgui1", "textures\\");
OEngine::Render::Atlas::createFromFile("mainmenu.cfg", "mwgui2", "textures\\");
} }

@ -9,10 +9,11 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwdialogue/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "dialogue_history.hpp" #include "dialogue_history.hpp"
#include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "list.hpp" #include "list.hpp"
#include "tradewindow.hpp" #include "tradewindow.hpp"
@ -41,7 +42,7 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
} }
DialogueWindow::DialogueWindow(WindowManager& parWindowManager) DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window.layout", parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager)
, mEnabled(true) , mEnabled(true)
, mShowTrade(false) , mShowTrade(false)

@ -29,7 +29,7 @@ namespace MWGui
class DialogueWindow: public WindowBase, public ReferenceInterface class DialogueWindow: public WindowBase, public ReferenceInterface
{ {
public: public:
DialogueWindow(WindowManager& parWindowManager); DialogueWindow(MWBase::WindowManager& parWindowManager);
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -1,5 +1,7 @@
#include "dialogue_history.hpp" #include "dialogue_history.hpp"
#include "window_manager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -71,4 +73,3 @@ void DialogueHistory::addDialogText(const UString& parText)
addText(parText); addText(parText);
addText("\n"); addText("\n");
} }

@ -8,16 +8,15 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwgui/widgets.hpp" #include "../mwgui/widgets.hpp"
#include "inventorywindow.hpp" #include "inventorywindow.hpp"
#include "window_manager.hpp"
#include "container.hpp" #include "container.hpp"
#include "console.hpp" #include "console.hpp"
@ -25,9 +24,9 @@ using namespace MWGui;
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
: Layout("openmw_hud.layout") : Layout("openmw_hud.layout")
, health(NULL) , mHealth(NULL)
, magicka(NULL) , mMagicka(NULL)
, stamina(NULL) , mStamina(NULL)
, mWeapImage(NULL) , mWeapImage(NULL)
, mSpellImage(NULL) , mSpellImage(NULL)
, mWeapStatus(NULL) , mWeapStatus(NULL)
@ -37,10 +36,10 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
, mMinimap(NULL) , mMinimap(NULL)
, mCompass(NULL) , mCompass(NULL)
, mCrosshair(NULL) , mCrosshair(NULL)
, fpsbox(NULL) , mFpsBox(NULL)
, fpscounter(NULL) , mFpsCounter(NULL)
, trianglecounter(NULL) , mTriangleCounter(NULL)
, batchcounter(NULL) , mBatchCounter(NULL)
, mHealthManaStaminaBaseLeft(0) , mHealthManaStaminaBaseLeft(0)
, mWeapBoxBaseLeft(0) , mWeapBoxBaseLeft(0)
, mSpellBoxBaseLeft(0) , mSpellBoxBaseLeft(0)
@ -58,10 +57,9 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
// Energy bars // Energy bars
getWidget(mHealthFrame, "HealthFrame"); getWidget(mHealthFrame, "HealthFrame");
getWidget(health, "Health"); getWidget(mHealth, "Health");
getWidget(magicka, "Magicka"); getWidget(mMagicka, "Magicka");
getWidget(stamina, "Stamina"); getWidget(mStamina, "Stamina");
mHealthManaStaminaBaseLeft = mHealthFrame->getLeft(); mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame; MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
@ -94,9 +92,10 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
getWidget(mMinimapBox, "MiniMapBox"); getWidget(mMinimapBox, "MiniMapBox");
mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight(); mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
mMinimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
getWidget(mMinimap, "MiniMap"); getWidget(mMinimap, "MiniMap");
getWidget(mCompass, "Compass"); getWidget(mCompass, "Compass");
getWidget(mMinimapButton, "MiniMapButton");
mMinimapButton->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
getWidget(mCellNameBox, "CellName"); getWidget(mCellNameBox, "CellName");
getWidget(mWeaponSpellBox, "WeaponSpellName"); getWidget(mWeaponSpellBox, "WeaponSpellName");
@ -105,8 +104,8 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
setFpsLevel(fpsLevel); setFpsLevel(fpsLevel);
getWidget(trianglecounter, "TriangleCounter"); getWidget(mTriangleCounter, "TriangleCounter");
getWidget(batchcounter, "BatchCounter"); getWidget(mBatchCounter, "BatchCounter");
setEffect("icons\\s\\tx_s_chameleon.dds"); setEffect("icons\\s\\tx_s_chameleon.dds");
@ -119,7 +118,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
void HUD::setFpsLevel(int level) void HUD::setFpsLevel(int level)
{ {
fpscounter = 0; mFpsCounter = 0;
MyGUI::Widget* fps; MyGUI::Widget* fps;
getWidget(fps, "FPSBoxAdv"); getWidget(fps, "FPSBoxAdv");
@ -129,32 +128,32 @@ void HUD::setFpsLevel(int level)
if (level == 2) if (level == 2)
{ {
getWidget(fpsbox, "FPSBoxAdv"); getWidget(mFpsBox, "FPSBoxAdv");
fpsbox->setVisible(true); mFpsBox->setVisible(true);
getWidget(fpscounter, "FPSCounterAdv"); getWidget(mFpsCounter, "FPSCounterAdv");
} }
else if (level == 1) else if (level == 1)
{ {
getWidget(fpsbox, "FPSBox"); getWidget(mFpsBox, "FPSBox");
fpsbox->setVisible(true); mFpsBox->setVisible(true);
getWidget(fpscounter, "FPSCounter"); getWidget(mFpsCounter, "FPSCounter");
} }
} }
void HUD::setFPS(float fps) void HUD::setFPS(float fps)
{ {
if (fpscounter) if (mFpsCounter)
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps)); mFpsCounter->setCaption(boost::lexical_cast<std::string>((int)fps));
} }
void HUD::setTriangleCount(unsigned int count) 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) 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) void HUD::setEffect(const char *img)
@ -177,20 +176,20 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
switch (i) switch (i)
{ {
case 0: case 0:
health->setProgressRange (value.getModified()); mHealth->setProgressRange (value.getModified());
health->setProgressPosition (value.getCurrent()); mHealth->setProgressPosition (value.getCurrent());
getWidget(w, "HealthFrame"); getWidget(w, "HealthFrame");
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
break; break;
case 1: case 1:
magicka->setProgressRange (value.getModified()); mMagicka->setProgressRange (value.getModified());
magicka->setProgressPosition (value.getCurrent()); mMagicka->setProgressPosition (value.getCurrent());
getWidget(w, "MagickaFrame"); getWidget(w, "MagickaFrame");
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
break; break;
case 2: case 2:
stamina->setProgressRange (value.getModified()); mStamina->setProgressRange (value.getModified());
stamina->setProgressPosition (value.getCurrent()); mStamina->setProgressPosition (value.getCurrent());
getWidget(w, "FatigueFrame"); getWidget(w, "FatigueFrame");
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
break; break;
@ -198,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) void HUD::onWorldClicked(MyGUI::Widget* _sender)
{ {
if (!MWBase::Environment::get().getWindowManager ()->isGuiMode ())
return;
if (mDragAndDrop->mIsOnDragAndDrop) if (mDragAndDrop->mIsOnDragAndDrop)
{ {
// drop item into the gameworld // drop item into the gameworld
@ -518,3 +482,68 @@ void HUD::unsetSelectedWeapon()
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds"); mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
mWeapBox->clearUserStrings(); 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 setFPS(float fps);
void setTriangleCount(unsigned int count); void setTriangleCount(unsigned int count);
void setBatchCount(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 setFpsLevel(const int level);
void setSelectedSpell(const std::string& spellId, int successChancePercent); void setSelectedSpell(const std::string& spellId, int successChancePercent);
@ -28,6 +34,8 @@ namespace MWGui
void unsetSelectedSpell(); void unsetSelectedSpell();
void unsetSelectedWeapon(); void unsetSelectedWeapon();
void setCrosshairVisible(bool visible);
void onFrame(float dt); void onFrame(float dt);
void onResChange(int width, int height); void onResChange(int width, int height);
@ -35,12 +43,14 @@ namespace MWGui
bool getWorldMouseOver() { return mWorldMouseOver; } bool getWorldMouseOver() { return mWorldMouseOver; }
MyGUI::ProgressPtr health, magicka, stamina; private:
MyGUI::ProgressPtr mHealth, mMagicka, mStamina;
MyGUI::Widget* mHealthFrame; MyGUI::Widget* mHealthFrame;
MyGUI::Widget *mWeapBox, *mSpellBox; MyGUI::Widget *mWeapBox, *mSpellBox;
MyGUI::ImageBox *mWeapImage, *mSpellImage; MyGUI::ImageBox *mWeapImage, *mSpellImage;
MyGUI::ProgressPtr mWeapStatus, mSpellStatus; MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
MyGUI::Widget *mEffectBox, *mMinimapBox; MyGUI::Widget *mEffectBox, *mMinimapBox;
MyGUI::Button* mMinimapButton;
MyGUI::ImageBox* mEffect1; MyGUI::ImageBox* mEffect1;
MyGUI::ScrollView* mMinimap; MyGUI::ScrollView* mMinimap;
MyGUI::ImageBox* mCompass; MyGUI::ImageBox* mCompass;
@ -48,12 +58,13 @@ namespace MWGui
MyGUI::TextBox* mCellNameBox; MyGUI::TextBox* mCellNameBox;
MyGUI::TextBox* mWeaponSpellBox; MyGUI::TextBox* mWeaponSpellBox;
MyGUI::WidgetPtr fpsbox; MyGUI::Widget* mDummy;
MyGUI::TextBox* fpscounter;
MyGUI::TextBox* trianglecounter; MyGUI::WidgetPtr mFpsBox;
MyGUI::TextBox* batchcounter; MyGUI::TextBox* mFpsCounter;
MyGUI::TextBox* mTriangleCounter;
MyGUI::TextBox* mBatchCounter;
private:
// bottom left elements // bottom left elements
int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft; int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft;
// bottom right elements // bottom right elements
@ -81,5 +92,7 @@ namespace MWGui
void onWeaponClicked(MyGUI::Widget* _sender); void onWeaponClicked(MyGUI::Widget* _sender);
void onMagicClicked(MyGUI::Widget* _sender); void onMagicClicked(MyGUI::Widget* _sender);
void onMapClicked(MyGUI::Widget* _sender); void onMapClicked(MyGUI::Widget* _sender);
void updatePositions();
}; };
} }

@ -9,6 +9,8 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -17,11 +19,6 @@
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwclass/container.hpp"
#include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "bookwindow.hpp" #include "bookwindow.hpp"
#include "scrollwindow.hpp" #include "scrollwindow.hpp"
@ -43,7 +40,7 @@ namespace
namespace MWGui namespace MWGui
{ {
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) InventoryWindow::InventoryWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
: ContainerBase(dragAndDrop) : ContainerBase(dragAndDrop)
, WindowPinnableBase("openmw_inventory_window.layout", parWindowManager) , WindowPinnableBase("openmw_inventory_window.layout", parWindowManager)
, mTrading(false) , mTrading(false)

@ -9,7 +9,7 @@ namespace MWGui
class InventoryWindow : public ContainerBase, public WindowPinnableBase class InventoryWindow : public ContainerBase, public WindowPinnableBase
{ {
public: public:
InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop); InventoryWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
virtual void open(); virtual void open();

@ -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();
}
}

@ -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);
};
}

@ -2,12 +2,11 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/journal.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwdialogue/journal.hpp" #include "../mwdialogue/journalentry.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp"
namespace namespace
{ {
@ -82,7 +81,7 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize)
} }
MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) MWGui::JournalWindow::JournalWindow (MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_journal.layout", parWindowManager) : WindowBase("openmw_journal.layout", parWindowManager)
, mLastPos(0) , mLastPos(0)
, mVisible(false) , mVisible(false)

@ -10,13 +10,11 @@
namespace MWGui namespace MWGui
{ {
class WindowManager;
class JournalWindow : public WindowBase class JournalWindow : public WindowBase
{ {
public: public:
JournalWindow(WindowManager& parWindowManager); JournalWindow(MWBase::WindowManager& parWindowManager);
void open(); virtual void open();
virtual void setVisible(bool visible); // only used to play close sound virtual void setVisible(bool visible); // only used to play close sound

@ -0,0 +1,84 @@
#include "mainmenu.hpp"
#include <OgreRoot.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
namespace MWGui
{
MainMenu::MainMenu(int w, int h)
: OEngine::GUI::Layout("openmw_mainmenu.layout")
, mButtonBox(0)
{
onResChange(w,h);
}
void MainMenu::onResChange(int w, int h)
{
setCoord(0,0,w,h);
int height = 64 * 3;
if (mButtonBox)
MyGUI::Gui::getInstance ().destroyWidget(mButtonBox);
mButtonBox = mMainWidget->createWidget<MyGUI::Widget>("", MyGUI::IntCoord(w/2 - 64, h/2 - height/2, 128, height), MyGUI::Align::Default);
int curH = 0;
mReturn = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mReturn->setImageResource ("Menu_Return");
mReturn->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::returnToGame);
curH += 64;
/*
mNewGame = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mNewGame->setImageResource ("Menu_NewGame");
curH += 64;
mLoadGame = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mLoadGame->setImageResource ("Menu_LoadGame");
curH += 64;
mSaveGame = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mSaveGame->setImageResource ("Menu_SaveGame");
curH += 64;
*/
mOptions = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mOptions->setImageResource ("Menu_Options");
mOptions->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::showOptions);
curH += 64;
/*
mCredits = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mCredits->setImageResource ("Menu_Credits");
curH += 64;
*/
mExitGame = mButtonBox->createWidget<MyGUI::Button> ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default);
mExitGame->setImageResource ("Menu_ExitGame");
mExitGame->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::exitGame);
curH += 64;
}
void MainMenu::returnToGame(MyGUI::Widget* sender)
{
MWBase::Environment::get().getWindowManager ()->removeGuiMode (GM_MainMenu);
}
void MainMenu::showOptions(MyGUI::Widget* sender)
{
MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings);
}
void MainMenu::exitGame(MyGUI::Widget* sender)
{
Ogre::Root::getSingleton ().queueEndRendering ();
}
}

@ -6,11 +6,24 @@ namespace MWGui
class MainMenu : public OEngine::GUI::Layout class MainMenu : public OEngine::GUI::Layout
{ {
public: public:
MainMenu(int w, int h) MainMenu(int w, int h);
: Layout("openmw_mainmenu.layout")
{ void onResChange(int w, int h);
setCoord(0,0,w,h);
} private:
MyGUI::Button* mReturn;
MyGUI::Button* mNewGame;
MyGUI::Button* mLoadGame;
MyGUI::Button* mSaveGame;
MyGUI::Button* mOptions;
MyGUI::Button* mCredits;
MyGUI::Button* mExitGame;
MyGUI::Widget* mButtonBox;
void returnToGame(MyGUI::Widget* sender);
void showOptions(MyGUI::Widget* sender);
void exitGame(MyGUI::Widget* sender);
}; };
} }

@ -1,8 +1,13 @@
#include "map_window.hpp" #include "map_window.hpp"
#include "window_manager.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <OgreVector2.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
using namespace MWGui; using namespace MWGui;
LocalMapBase::LocalMapBase() LocalMapBase::LocalMapBase()
@ -88,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) 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 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 mx=0; mx<3; ++mx)
{ {
for (int my=0; my<3; ++my) for (int my=0; my<3; ++my)
{ {
// map
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_" std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
+ boost::lexical_cast<std::string>(y + (interior ? (my-1) : -1*(my-1))); + boost::lexical_cast<std::string>(y + (interior ? (my-1) : -1*(my-1)));
@ -107,12 +133,78 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
box->setImageTexture(image); box->setImageTexture(image);
else else
box->setImageTexture("black.png"); 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; mInterior = interior;
mCurX = x; mCurX = x;
mCurY = y; mCurY = y;
mChanged = false; mChanged = false;
// fog of war
applyFogOfWar(); applyFogOfWar();
// set the compass texture again, because MyGUI determines sorting of ImageBox widgets // set the compass texture again, because MyGUI determines sorting of ImageBox widgets
@ -154,7 +246,7 @@ void LocalMapBase::setPlayerDir(const float x, const float y)
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
MapWindow::MapWindow(WindowManager& parWindowManager) : MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) :
MWGui::WindowPinnableBase("openmw_map_window.layout", parWindowManager), MWGui::WindowPinnableBase("openmw_map_window.layout", parWindowManager),
mGlobal(false) mGlobal(false)
{ {

@ -18,6 +18,15 @@ namespace MWGui
void toggleFogOfWar(); void toggleFogOfWar();
struct MarkerPosition
{
bool interior;
int cellX;
int cellY;
float nX;
float nY;
};
protected: protected:
int mCurX, mCurY; int mCurX, mCurY;
bool mInterior; bool mInterior;
@ -32,6 +41,9 @@ namespace MWGui
void applyFogOfWar(); void applyFogOfWar();
void onMarkerFocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
void onMarkerUnfocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
OEngine::GUI::Layout* mLayout; OEngine::GUI::Layout* mLayout;
bool mMapDragAndDrop; bool mMapDragAndDrop;
@ -45,7 +57,7 @@ namespace MWGui
class MapWindow : public MWGui::WindowPinnableBase, public LocalMapBase class MapWindow : public MWGui::WindowPinnableBase, public LocalMapBase
{ {
public: public:
MapWindow(WindowManager& parWindowManager); MapWindow(MWBase::WindowManager& parWindowManager);
virtual ~MapWindow(){} virtual ~MapWindow(){}
void setCellName(const std::string& cellName); void setCellName(const std::string& cellName);

@ -2,7 +2,7 @@
using namespace MWGui; using namespace MWGui;
MessageBoxManager::MessageBoxManager (WindowManager *windowManager) MessageBoxManager::MessageBoxManager (MWBase::WindowManager *windowManager)
{ {
mWindowManager = windowManager; mWindowManager = windowManager;
// defines // defines

@ -5,13 +5,13 @@
#include <MyGUI.h> #include <MyGUI.h>
#include "window_base.hpp" #include "window_base.hpp"
#include "window_manager.hpp"
#include "../mwbase/windowmanager.hpp"
#undef MessageBox #undef MessageBox
namespace MWGui namespace MWGui
{ {
class InteractiveMessageBox; class InteractiveMessageBox;
class MessageBoxManager; class MessageBoxManager;
class MessageBox; class MessageBox;
@ -25,7 +25,7 @@ namespace MWGui
class MessageBoxManager class MessageBoxManager
{ {
public: public:
MessageBoxManager (WindowManager* windowManager); MessageBoxManager (MWBase::WindowManager* windowManager);
void onFrame (float frameDuration); void onFrame (float frameDuration);
void createMessageBox (const std::string& message); void createMessageBox (const std::string& message);
bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons); bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
@ -37,7 +37,7 @@ namespace MWGui
int readPressedButton (); int readPressedButton ();
WindowManager *mWindowManager; MWBase::WindowManager *mWindowManager;
private: private:
std::vector<MessageBox*> mMessageBoxes; std::vector<MessageBox*> mMessageBoxes;

@ -32,7 +32,9 @@ namespace MWGui
GM_Review, GM_Review,
// interactive MessageBox // interactive MessageBox
GM_InterMessageBox GM_InterMessageBox,
GM_QuickKeysMenu
}; };
// Windows shown in inventory mode // Windows shown in inventory mode

@ -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;
}
}

@ -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

@ -8,14 +8,17 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "window_manager.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
RaceDialog::RaceDialog(WindowManager& parWindowManager) RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_race.layout", parWindowManager) : WindowBase("openmw_chargen_race.layout", parWindowManager)
, mGenderIndex(0) , mGenderIndex(0)
, mFaceIndex(0) , mFaceIndex(0)
@ -110,7 +113,6 @@ void RaceDialog::open()
updateRaces(); updateRaces();
updateSkills(); updateSkills();
updateSpellPowers(); updateSpellPowers();
setVisible(true);
} }
@ -209,7 +211,7 @@ void RaceDialog::updateRaces()
{ {
mRaceList->removeAllItems(); mRaceList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
@ -243,7 +245,7 @@ void RaceDialog::updateSkills()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
@ -281,7 +283,7 @@ void RaceDialog::updateSpellPowers()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->powers.list.begin(); std::vector<std::string>::const_iterator it = race->powers.list.begin();

@ -24,7 +24,7 @@ namespace MWGui
class RaceDialog : public WindowBase class RaceDialog : public WindowBase
{ {
public: public:
RaceDialog(WindowManager& parWindowManager); RaceDialog(MWBase::WindowManager& parWindowManager);
enum Gender enum Gender
{ {
@ -43,7 +43,7 @@ namespace MWGui
// setHair() // setHair()
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void open(); virtual void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;

@ -7,7 +7,10 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "window_manager.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
@ -19,7 +22,7 @@ using namespace Widgets;
const int ReviewDialog::sLineHeight = 18; const int ReviewDialog::sLineHeight = 18;
ReviewDialog::ReviewDialog(WindowManager& parWindowManager) ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_chargen_review.layout", parWindowManager) : WindowBase("openmw_chargen_review.layout", parWindowManager)
, mLastPos(0) , mLastPos(0)
{ {
@ -107,7 +110,6 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
void ReviewDialog::open() void ReviewDialog::open()
{ {
updateSkillArea(); updateSkillArea();
setVisible(true);
} }
void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
@ -138,7 +140,7 @@ void ReviewDialog::setPlayerName(const std::string &name)
void ReviewDialog::setRace(const std::string &raceId) void ReviewDialog::setRace(const std::string &raceId)
{ {
mRaceId = raceId; mRaceId = raceId;
const ESM::Race *race = mWindowManager.getStore().races.search(mRaceId); const ESM::Race *race = MWBase::Environment::get().getWorld()->getStore().races.search(mRaceId);
if (race) if (race)
{ {
ToolTips::createRaceToolTip(mRaceWidget, race); ToolTips::createRaceToolTip(mRaceWidget, race);
@ -156,7 +158,7 @@ void ReviewDialog::setClass(const ESM::Class& class_)
void ReviewDialog::setBirthSign(const std::string& signId) void ReviewDialog::setBirthSign(const std::string& signId)
{ {
mBirthSignId = signId; mBirthSignId = signId;
const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(mBirthSignId); const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId);
if (sign) if (sign)
{ {
mBirthSignWidget->setCaption(sign->name); mBirthSignWidget->setCaption(sign->name);

@ -30,7 +30,7 @@ namespace MWGui
}; };
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
ReviewDialog(WindowManager& parWindowManager); ReviewDialog(MWBase::WindowManager& parWindowManager);
void setPlayerName(const std::string &name); void setPlayerName(const std::string &name);
void setRace(const std::string &raceId); void setRace(const std::string &raceId);
@ -46,7 +46,7 @@ namespace MWGui
void configureSkills(const SkillList& major, const SkillList& minor); void configureSkills(const SkillList& major, const SkillList& minor);
void setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value); void setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value);
void open(); virtual void open();
// Events // Events
typedef delegates::CMultiDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;

@ -2,17 +2,17 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwsound/soundmanager.hpp"
#include "formatting.hpp" #include "formatting.hpp"
#include "window_manager.hpp"
using namespace MWGui; using namespace MWGui;
ScrollWindow::ScrollWindow (WindowManager& parWindowManager) : ScrollWindow::ScrollWindow (MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_scroll.layout", parWindowManager) WindowBase("openmw_scroll.layout", parWindowManager)
{ {
getWidget(mTextView, "TextView"); getWidget(mTextView, "TextView");
@ -62,7 +62,7 @@ void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack); MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
MWWorld::ActionTake take(mScroll); MWWorld::ActionTake take(mScroll);
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

@ -10,7 +10,7 @@ namespace MWGui
class ScrollWindow : public WindowBase class ScrollWindow : public WindowBase
{ {
public: public:
ScrollWindow (WindowManager& parWindowManager); ScrollWindow (MWBase::WindowManager& parWindowManager);
void open (MWWorld::Ptr scroll); void open (MWWorld::Ptr scroll);
void setTakeButtonShow(bool show); void setTakeButtonShow(bool show);

@ -12,14 +12,12 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwrender/renderingmanager.hpp" #include "../mwrender/renderingmanager.hpp"
#include "../mwsound/soundmanager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "window_manager.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
namespace namespace
@ -83,10 +81,12 @@ namespace
namespace MWGui namespace MWGui
{ {
SettingsWindow::SettingsWindow(WindowManager& parWindowManager) : SettingsWindow::SettingsWindow(MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_settings_window.layout", parWindowManager) WindowBase("openmw_settings_window.layout", parWindowManager)
{ {
getWidget(mOkButton, "OkButton"); getWidget(mOkButton, "OkButton");
getWidget(mSubtitlesButton, "SubtitlesButton");
getWidget(mCrosshairButton, "CrosshairButton");
getWidget(mResolutionList, "ResolutionList"); getWidget(mResolutionList, "ResolutionList");
getWidget(mMenuTransparencySlider, "MenuTransparencySlider"); getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
getWidget(mToolTipDelaySlider, "ToolTipDelaySlider"); getWidget(mToolTipDelaySlider, "ToolTipDelaySlider");
@ -117,7 +117,15 @@ namespace MWGui
getWidget(mMiscShadows, "MiscShadows"); getWidget(mMiscShadows, "MiscShadows");
getWidget(mShadowsDebug, "ShadowsDebug"); getWidget(mShadowsDebug, "ShadowsDebug");
getWidget(mUnderwaterButton, "UnderwaterButton"); 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); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled); mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
@ -156,6 +164,9 @@ namespace MWGui
mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(), mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(),
okSize, mOkButton->getHeight()); okSize, mOkButton->getHeight());
mResetControlsButton->setSize (mResetControlsButton->getTextSize ().width + 24, mResetControlsButton->getHeight());
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
// fill resolution list // fill resolution list
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem(); Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues; Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues;
@ -185,6 +196,9 @@ namespace MWGui
int tooltip_delay = (mToolTipDelaySlider->getScrollRange()-1) * Settings::Manager::getFloat("tooltip delay", "GUI"); int tooltip_delay = (mToolTipDelaySlider->getScrollRange()-1) * Settings::Manager::getFloat("tooltip delay", "GUI");
mToolTipDelaySlider->setScrollPosition(tooltip_delay); 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); float fovVal = (Settings::Manager::getFloat("field of view", "General")-sFovMin)/(sFovMax-sFovMin);
mFOVSlider->setScrollPosition(fovVal * (mFOVSlider->getScrollRange()-1)); mFOVSlider->setScrollPosition(fovVal * (mFOVSlider->getScrollRange()-1));
MyGUI::TextBox* fovText; MyGUI::TextBox* fovText;
@ -221,6 +235,16 @@ namespace MWGui
mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}"); mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "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; std::string shaders;
if (!Settings::Manager::getBool("shaders", "Objects")) if (!Settings::Manager::getBool("shaders", "Objects"))
shaders = "off"; shaders = "off";
@ -264,6 +288,7 @@ namespace MWGui
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept);
dialog->eventCancelClicked.clear(); dialog->eventCancelClicked.clear();
dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionCancel);
} }
void SettingsWindow::onResolutionAccept() void SettingsWindow::onResolutionAccept()
@ -383,6 +408,12 @@ namespace MWGui
Settings::Manager::setBool("misc shadows", "Shadows", newState); Settings::Manager::setBool("misc shadows", "Shadows", newState);
else if (_sender == mShadowsDebug) else if (_sender == mShadowsDebug)
Settings::Manager::setBool("debug", "Shadows", newState); 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(); apply();
} }
@ -500,6 +531,10 @@ namespace MWGui
Settings::Manager::setFloat("footsteps volume", "Sound", val); Settings::Manager::setFloat("footsteps volume", "Sound", val);
else if (scroller == mMusicVolumeSlider) else if (scroller == mMusicVolumeSlider)
Settings::Manager::setFloat("music volume", "Sound", val); 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(); apply();
} }
@ -512,4 +547,78 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed); MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
MWBase::Environment::get().getInputManager()->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 ();
}
} }

@ -13,7 +13,11 @@ namespace MWGui
class SettingsWindow : public WindowBase class SettingsWindow : public WindowBase
{ {
public: public:
SettingsWindow(WindowManager& parWindowManager); SettingsWindow(MWBase::WindowManager& parWindowManager);
virtual void open();
void updateControlsBox();
private: private:
static int const sFovMin = 30; static int const sFovMin = 30;
@ -26,6 +30,8 @@ namespace MWGui
MyGUI::ScrollBar* mMenuTransparencySlider; MyGUI::ScrollBar* mMenuTransparencySlider;
MyGUI::ScrollBar* mToolTipDelaySlider; MyGUI::ScrollBar* mToolTipDelaySlider;
MyGUI::Button* mSubtitlesButton;
MyGUI::Button* mCrosshairButton;
// graphics // graphics
MyGUI::ListBox* mResolutionList; MyGUI::ListBox* mResolutionList;
@ -60,6 +66,13 @@ namespace MWGui
MyGUI::ScrollBar* mFootstepsVolumeSlider; MyGUI::ScrollBar* mFootstepsVolumeSlider;
MyGUI::ScrollBar* mMusicVolumeSlider; 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 onOkButtonClicked(MyGUI::Widget* _sender);
void onFpsToggled(MyGUI::Widget* _sender); void onFpsToggled(MyGUI::Widget* _sender);
void onTextureFilteringToggled(MyGUI::Widget* _sender); void onTextureFilteringToggled(MyGUI::Widget* _sender);
@ -72,9 +85,13 @@ namespace MWGui
void onShadersToggled(MyGUI::Widget* _sender); void onShadersToggled(MyGUI::Widget* _sender);
void onShadowTextureSize(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(); void apply();
}; };
} }
#endif #endif

@ -8,17 +8,17 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwmechanics/spells.hpp" #include "../mwmechanics/spells.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/spellsuccess.hpp" #include "../mwmechanics/spellsuccess.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp"
#include "inventorywindow.hpp" #include "inventorywindow.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
@ -43,7 +43,7 @@ namespace
namespace MWGui namespace MWGui
{ {
SpellWindow::SpellWindow(WindowManager& parWindowManager) SpellWindow::SpellWindow(MWBase::WindowManager& parWindowManager)
: WindowPinnableBase("openmw_spell_window.layout", parWindowManager) : WindowPinnableBase("openmw_spell_window.layout", parWindowManager)
, mHeight(0) , mHeight(0)
, mWidth(0) , mWidth(0)
@ -351,34 +351,10 @@ namespace MWGui
if (_sender->getUserString("Equipped") == "false" if (_sender->getUserString("Equipped") == "false"
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty()) && !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 // 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? MWWorld::ActionEquip action(item);
// slots that this item can be equipped in action.execute (MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ());
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?
// since we changed equipping status, update the inventory window // since we changed equipping status, update the inventory window
mWindowManager.getInventoryWindow()->drawItems(); mWindowManager.getInventoryWindow()->drawItems();

@ -8,7 +8,7 @@ namespace MWGui
class SpellWindow : public WindowPinnableBase class SpellWindow : public WindowPinnableBase
{ {
public: public:
SpellWindow(WindowManager& parWindowManager); SpellWindow(MWBase::WindowManager& parWindowManager);
void updateSpells(); void updateSpells();

@ -8,20 +8,21 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/npcstats.hpp"
#include "window_manager.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
using namespace MWGui; using namespace MWGui;
const int StatsWindow::sLineHeight = 18; const int StatsWindow::sLineHeight = 18;
StatsWindow::StatsWindow (WindowManager& parWindowManager) StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager)
: WindowPinnableBase("openmw_stats_window.layout", parWindowManager) : WindowPinnableBase("openmw_stats_window.layout", parWindowManager)
, mSkillAreaWidget(NULL) , mSkillAreaWidget(NULL)
, mSkillClientWidget(NULL) , mSkillClientWidget(NULL)
@ -56,7 +57,7 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
{ 0, 0 } { 0, 0 }
}; };
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
for (int i=0; names[i][0]; ++i) for (int i=0; names[i][0]; ++i)
{ {
setText (names[i][0], store.gameSettings.find (names[i][1])->str); setText (names[i][0], store.gameSettings.find (names[i][1])->str);
@ -382,12 +383,12 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
float modified = stat.getModified(); float modified = stat.getModified();
int progressPercent = (modified - float(static_cast<int>(modified))) * 100; int progressPercent = (modified - float(static_cast<int>(modified))) * 100;
const ESM::Skill* skill = mWindowManager.getStore().skills.search(skillId); const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId);
assert(skill); assert(skill);
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
const ESM::Attribute* attr = mWindowManager.getStore().attributes.search(skill->data.attribute); const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->data.attribute);
assert(attr); assert(attr);
std::string state = "normal"; std::string state = "normal";
@ -442,7 +443,7 @@ void StatsWindow::updateSkillArea()
if (!mMiscSkills.empty()) if (!mMiscSkills.empty())
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
// race tooltip // race tooltip
const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace());
@ -484,8 +485,8 @@ void StatsWindow::updateSkillArea()
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1]; text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1];
ESM::RankData rankData = faction->data.rankData[it->second+1]; ESM::RankData rankData = faction->data.rankData[it->second+1];
const ESM::Attribute* attr1 = mWindowManager.getStore().attributes.search(faction->data.attribute1); const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute1);
const ESM::Attribute* attr2 = mWindowManager.getStore().attributes.search(faction->data.attribute2); const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute2);
assert(attr1 && attr2); assert(attr1 && attr2);
text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1) text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1)
@ -495,7 +496,7 @@ void StatsWindow::updateSkillArea()
text += "\n#BF9959"; text += "\n#BF9959";
for (int i=0; i<6; ++i) for (int i=0; i<6; ++i)
{ {
const ESM::Skill* skill = mWindowManager.getStore().skills.search(faction->data.skillID[i]); const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(faction->data.skillID[i]);
assert(skill); assert(skill);
text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}"; text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}";
if (i<5) if (i<5)

@ -22,7 +22,7 @@ namespace MWGui
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
StatsWindow(WindowManager& parWindowManager); StatsWindow(MWBase::WindowManager& parWindowManager);
/// automatically updates all the data in the stats window, but only if it has changed. /// automatically updates all the data in the stats window, but only if it has changed.
void onFrame(); void onFrame();
@ -82,4 +82,3 @@ namespace MWGui
}; };
} }
#endif #endif

@ -1,9 +1,10 @@
#include "text_input.hpp" #include "text_input.hpp"
#include "window_manager.hpp"
#include "../mwbase/windowmanager.hpp"
using namespace MWGui; using namespace MWGui;
TextInputDialog::TextInputDialog(WindowManager& parWindowManager) TextInputDialog::TextInputDialog(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_text_input.layout", parWindowManager) : WindowBase("openmw_text_input.layout", parWindowManager)
{ {
// Centre dialog // Centre dialog
@ -44,7 +45,6 @@ void TextInputDialog::open()
{ {
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
setVisible(true);
} }
// widget controls // widget controls

@ -18,14 +18,14 @@ namespace MWGui
class TextInputDialog : public WindowBase class TextInputDialog : public WindowBase
{ {
public: public:
TextInputDialog(WindowManager& parWindowManager); TextInputDialog(MWBase::WindowManager& parWindowManager);
std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; } std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; }
void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); } void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); }
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
void setTextLabel(const std::string &label); void setTextLabel(const std::string &label);
void open(); virtual void open();
protected: protected:
void onOkClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender);

@ -8,16 +8,17 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "window_manager.hpp" #include "map_window.hpp"
#include "widgets.hpp" #include "widgets.hpp"
using namespace MWGui; using namespace MWGui;
using namespace MyGUI; using namespace MyGUI;
ToolTips::ToolTips(WindowManager* windowManager) : ToolTips::ToolTips(MWBase::WindowManager* windowManager) :
Layout("openmw_tooltips.layout") Layout("openmw_tooltips.layout")
, mGameMode(true) , mGameMode(true)
, mWindowManager(windowManager) , mWindowManager(windowManager)
@ -150,7 +151,19 @@ void ToolTips::onFrame(float frameDuration)
{ {
return; 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>(); mFocusObject = *focus->getUserData<MWWorld::Ptr>();
tooltipSize = getToolTipViaPtr(false); tooltipSize = getToolTipViaPtr(false);
@ -199,7 +212,8 @@ void ToolTips::onFrame(float frameDuration)
it != userStrings.end(); ++it) it != userStrings.end(); ++it)
{ {
if (it->first == "ToolTipType" if (it->first == "ToolTipType"
|| it->first == "ToolTipLayout") || it->first == "ToolTipLayout"
|| it->first == "IsMarker")
continue; continue;

@ -9,8 +9,6 @@
namespace MWGui namespace MWGui
{ {
class WindowManager;
// Info about tooltip that is supplied by the MWWorld::Class object // Info about tooltip that is supplied by the MWWorld::Class object
struct ToolTipInfo struct ToolTipInfo
{ {
@ -29,7 +27,7 @@ namespace MWGui
class ToolTips : public OEngine::GUI::Layout class ToolTips : public OEngine::GUI::Layout
{ {
public: public:
ToolTips(WindowManager* windowManager); ToolTips(MWBase::WindowManager* windowManager);
void onFrame(float frameDuration); void onFrame(float frameDuration);
@ -71,7 +69,7 @@ namespace MWGui
private: private:
MyGUI::Widget* mDynamicToolTipBox; MyGUI::Widget* mDynamicToolTipBox;
WindowManager* mWindowManager; MWBase::WindowManager* mWindowManager;
MWWorld::Ptr mFocusObject; MWWorld::Ptr mFocusObject;

@ -4,17 +4,17 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp"
#include "inventorywindow.hpp" #include "inventorywindow.hpp"
namespace MWGui namespace MWGui
{ {
TradeWindow::TradeWindow(WindowManager& parWindowManager) : TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_trade_window.layout", parWindowManager) WindowBase("openmw_trade_window.layout", parWindowManager)
, ContainerBase(NULL) // no drag&drop , ContainerBase(NULL) // no drag&drop
, mCurrentBalance(0) , mCurrentBalance(0)
@ -291,14 +291,14 @@ namespace MWGui
if (mPtr.getTypeName() == typeid(ESM::NPC).name()) if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
if (ref->base->hasAI) if (ref->base->mHasAI)
services = ref->base->AI.services; services = ref->base->mAiData.mServices;
} }
else if (mPtr.getTypeName() == typeid(ESM::Creature).name()) else if (mPtr.getTypeName() == typeid(ESM::Creature).name())
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
if (ref->base->hasAI) if (ref->base->mHasAI)
services = ref->base->AI.services; services = ref->base->mAiData.mServices;
} }
/// \todo what about potions, there doesn't seem to be a flag for them?? /// \todo what about potions, there doesn't seem to be a flag for them??

@ -23,7 +23,7 @@ namespace MWGui
class TradeWindow : public ContainerBase, public WindowBase class TradeWindow : public ContainerBase, public WindowBase
{ {
public: public:
TradeWindow(WindowManager& parWindowManager); TradeWindow(MWBase::WindowManager& parWindowManager);
void startTrade(MWWorld::Ptr actor); void startTrade(MWWorld::Ptr actor);

@ -1,9 +1,13 @@
#include "widgets.hpp" #include "widgets.hpp"
#include "window_manager.hpp"
#include "components/esm_store/store.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#undef min #undef min
#undef max #undef max
@ -224,7 +228,7 @@ void MWSpell::setSpellId(const std::string &spellId)
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.spells.search(mId); const ESM::Spell *spell = store.spells.search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
@ -255,7 +259,7 @@ void MWSpell::updateWidgets()
{ {
if (mSpellNameWidget && mWindowManager) if (mSpellNameWidget && mWindowManager)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.spells.search(mId); const ESM::Spell *spell = store.spells.search(mId);
if (spell) if (spell)
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->name); static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->name);
@ -384,7 +388,7 @@ void MWSpellEffect::updateWidgets()
if (!mWindowManager) if (!mWindowManager)
return; return;
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID);
if (!magicEffect) if (!magicEffect)
return; return;

@ -10,14 +10,19 @@
#undef MYGUI_EXPORT #undef MYGUI_EXPORT
#define MYGUI_EXPORT #define MYGUI_EXPORT
namespace MWBase
{
class WindowManager;
}
/* /*
This file contains various custom widgets used in OpenMW. This file contains various custom widgets used in OpenMW.
*/ */
namespace MWGui namespace MWGui
{ {
/// \todo remove!
using namespace MyGUI; using namespace MyGUI;
class WindowManager;
namespace Widgets namespace Widgets
{ {
@ -81,12 +86,12 @@ namespace MWGui
typedef MWMechanics::Stat<float> SkillValue; typedef MWMechanics::Stat<float> SkillValue;
void setWindowManager(WindowManager *m) { mManager = m; } void setWindowManager(MWBase::WindowManager *m) { mManager = m; } /// \todo remove
void setSkillId(ESM::Skill::SkillEnum skillId); void setSkillId(ESM::Skill::SkillEnum skillId);
void setSkillNumber(int skillId); void setSkillNumber(int skillId);
void setSkillValue(const SkillValue& value); void setSkillValue(const SkillValue& value);
WindowManager *getWindowManager() const { return mManager; } MWBase::WindowManager *getWindowManager() const { return mManager; }
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
const SkillValue& getSkillValue() const { return mValue; } const SkillValue& getSkillValue() const { return mValue; }
@ -109,7 +114,7 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager *mManager; MWBase::WindowManager *mManager;
ESM::Skill::SkillEnum mSkillId; ESM::Skill::SkillEnum mSkillId;
SkillValue mValue; SkillValue mValue;
MyGUI::WidgetPtr mSkillNameWidget, mSkillValueWidget; MyGUI::WidgetPtr mSkillNameWidget, mSkillValueWidget;
@ -124,11 +129,11 @@ namespace MWGui
typedef MWMechanics::Stat<int> AttributeValue; typedef MWMechanics::Stat<int> AttributeValue;
void setWindowManager(WindowManager *m) { mManager = m; } void setWindowManager(MWBase::WindowManager *m) { mManager = m; }
void setAttributeId(int attributeId); void setAttributeId(int attributeId);
void setAttributeValue(const AttributeValue& value); void setAttributeValue(const AttributeValue& value);
WindowManager *getWindowManager() const { return mManager; } MWBase::WindowManager *getWindowManager() const { return mManager; }
int getAttributeId() const { return mId; } int getAttributeId() const { return mId; }
const AttributeValue& getAttributeValue() const { return mValue; } const AttributeValue& getAttributeValue() const { return mValue; }
@ -151,7 +156,7 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager *mManager; MWBase::WindowManager *mManager;
int mId; int mId;
AttributeValue mValue; AttributeValue mValue;
MyGUI::WidgetPtr mAttributeNameWidget, mAttributeValueWidget; MyGUI::WidgetPtr mAttributeNameWidget, mAttributeValueWidget;
@ -170,7 +175,7 @@ namespace MWGui
typedef MWMechanics::Stat<int> SpellValue; typedef MWMechanics::Stat<int> SpellValue;
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setWindowManager(MWBase::WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellId(const std::string &id); void setSpellId(const std::string &id);
/** /**
@ -192,7 +197,7 @@ namespace MWGui
private: private:
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; MWBase::WindowManager* mWindowManager;
std::string mId; std::string mId;
MyGUI::TextBox* mSpellNameWidget; MyGUI::TextBox* mSpellNameWidget;
}; };
@ -212,7 +217,7 @@ namespace MWGui
EF_Constant = 0x02 // constant effect means that duration will not be displayed EF_Constant = 0x02 // constant effect means that duration will not be displayed
}; };
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setWindowManager(MWBase::WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setEffectList(const SpellEffectList& list); void setEffectList(const SpellEffectList& list);
static SpellEffectList effectListFromESM(const ESM::EffectList* effects); static SpellEffectList effectListFromESM(const ESM::EffectList* effects);
@ -234,7 +239,7 @@ namespace MWGui
private: private:
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; MWBase::WindowManager* mWindowManager;
SpellEffectList mEffectList; SpellEffectList mEffectList;
}; };
typedef MWEffectList* MWEffectListPtr; typedef MWEffectList* MWEffectListPtr;
@ -247,7 +252,7 @@ namespace MWGui
typedef ESM::ENAMstruct SpellEffectValue; typedef ESM::ENAMstruct SpellEffectValue;
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setWindowManager(MWBase::WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellEffect(const SpellEffectParams& params); void setSpellEffect(const SpellEffectParams& params);
std::string effectIDToString(const short effectID); std::string effectIDToString(const short effectID);
@ -267,7 +272,7 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; MWBase::WindowManager* mWindowManager;
SpellEffectParams mEffectParams; SpellEffectParams mEffectParams;
MyGUI::ImageBox* mImageWidget; MyGUI::ImageBox* mImageWidget;
MyGUI::TextBox* mTextWidget; MyGUI::TextBox* mTextWidget;

@ -1,27 +1,26 @@
#include "window_base.hpp" #include "window_base.hpp"
#include "window_manager.hpp"
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwbase/windowmanager.hpp"
using namespace MWGui; using namespace MWGui;
WindowBase::WindowBase(const std::string& parLayout, WindowManager& parWindowManager) WindowBase::WindowBase(const std::string& parLayout, MWBase::WindowManager& parWindowManager)
: Layout(parLayout) : Layout(parLayout)
, mWindowManager(parWindowManager) , mWindowManager(parWindowManager)
{ {
} }
void WindowBase::open()
{
}
void WindowBase::setVisible(bool visible) void WindowBase::setVisible(bool visible)
{ {
bool wasVisible = mMainWidget->getVisible(); bool wasVisible = mMainWidget->getVisible();
mMainWidget->setVisible(visible); mMainWidget->setVisible(visible);
if (!wasVisible && visible) if (visible)
open(); open();
else if (wasVisible && !visible)
close();
} }
void WindowBase::center() void WindowBase::center()
@ -39,3 +38,18 @@ void WindowBase::center()
coord.top = (gameWindowSize.height - coord.height)/2; coord.top = (gameWindowSize.height - coord.height)/2;
mMainWidget->setCoord(coord); 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);
}

@ -3,6 +3,11 @@
#include <openengine/gui/layout.hpp> #include <openengine/gui/layout.hpp>
namespace MWBase
{
class WindowManager;
}
namespace MWGui namespace MWGui
{ {
class WindowManager; class WindowManager;
@ -10,13 +15,14 @@ namespace MWGui
class WindowBase: public OEngine::GUI::Layout class WindowBase: public OEngine::GUI::Layout
{ {
public: public:
WindowBase(const std::string& parLayout, WindowManager& parWindowManager); WindowBase(const std::string& parLayout, MWBase::WindowManager& parWindowManager);
// Events // Events
typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase; typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase;
virtual void open(); virtual void open() {}
virtual void setVisible(bool visible); // calls open() if visible is true and was false before virtual void close () {}
virtual void setVisible(bool visible);
void center(); void center();
/** Event : Dialog finished, OK button clicked.\n /** Event : Dialog finished, OK button clicked.\n
@ -25,9 +31,21 @@ namespace MWGui
EventHandle_WindowBase eventDone; EventHandle_WindowBase eventDone;
protected: protected:
WindowManager& mWindowManager; /// \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 #endif

@ -1,317 +0,0 @@
#ifndef MWGUI_WINDOWMANAGER_H
#define MWGUI_WINDOWMANAGER_H
/**
This class owns and controls all the MW specific windows in the
GUI. It can enable/disable Gui mode, and is responsible for sending
and retrieving information from the Gui.
MyGUI should be initialized separately before creating instances of
this class.
**/
#include "MyGUI_UString.h"
#include <components/esm_store/store.hpp>
#include <components/settings/settings.hpp>
#include <openengine/ogre/renderer.hpp>
#include <openengine/gui/manager.hpp>
#include "../mwmechanics/stat.hpp"
#include "mode.hpp"
namespace MyGUI
{
class Gui;
class Widget;
}
namespace Compiler
{
class Extensions;
}
namespace MWWorld
{
class Ptr;
class CellStore;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace OEngine
{
namespace GUI
{
class Layout;
}
}
namespace MWGui
{
class WindowBase;
class HUD;
class MapWindow;
class MainMenu;
class StatsWindow;
class InventoryWindow;
class Console;
class JournalWindow;
class CharacterCreation;
class ContainerWindow;
class DragAndDrop;
class InventoryWindow;
class ToolTips;
class ScrollWindow;
class BookWindow;
class TextInputDialog;
class InfoBoxDialog;
class DialogueWindow;
class MessageBoxManager;
class CountDialog;
class TradeWindow;
class SettingsWindow;
class ConfirmationDialog;
class AlchemyWindow;
class SpellWindow;
struct ClassPoint
{
const char *id;
// Specialization points to match, in order: Stealth, Combat, Magic
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
unsigned int points[3];
};
class WindowManager
{
public:
typedef std::pair<std::string, int> Faction;
typedef std::vector<Faction> FactionList;
typedef std::vector<int> SkillList;
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts);
virtual ~WindowManager();
/**
* Should be called each frame to update windows/gui elements.
* This could mean updating sizes of gui elements or opening
* new dialogs.
*/
void update();
void pushGuiMode(GuiMode mode);
void popGuiMode();
void removeGuiMode(GuiMode mode); ///< can be anywhere in the stack
GuiMode getMode() const
{
if (mGuiModes.empty())
throw std::runtime_error ("getMode() called, but there is no active mode");
return mGuiModes.back();
}
bool isGuiMode() const { return !mGuiModes.empty(); }
void toggleVisible(GuiWindow wnd)
{
mShown = (mShown & wnd) ? (GuiWindow) (mShown & ~wnd) : (GuiWindow) (mShown | wnd);
updateVisible();
}
// Disallow all inventory mode windows
void disallowAll()
{
mAllowed = GW_None;
updateVisible();
}
// Allow one or more windows
void allow(GuiWindow wnd)
{
mAllowed = (GuiWindow)(mAllowed | wnd);
updateVisible();
}
bool isAllowed(GuiWindow wnd) const
{
return mAllowed & wnd;
}
MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;}
MWGui::ContainerWindow* getContainerWindow() {return mContainerWindow;}
MWGui::InventoryWindow* getInventoryWindow() {return mInventoryWindow;}
MWGui::BookWindow* getBookWindow() {return mBookWindow;}
MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;}
MWGui::CountDialog* getCountDialog() {return mCountDialog;}
MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
MWGui::Console* getConsole() {return mConsole;}
MyGUI::Gui* getGui() const { return mGui; }
void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount)
{
mFPS = fps;
mTriangleCount = triangleCount;
mBatchCount = batchCount;
}
// MWMechanics::DynamicStat<int> getValue(const std::string& id);
///< Set value for the given ID.
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
void setValue (const std::string& id, const std::string& value);
void setValue (const std::string& id, int value);
void setPlayerClass (const ESM::Class &class_); ///< set current class of player
void configureSkills (const SkillList& major, const SkillList& minor); ///< configure skill groups, each set contains the skill ID for that group.
void setReputation (int reputation); ///< set the current reputation value
void setBounty (int bounty); ///< set the current bounty value
void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty
void changeCell(MWWorld::CellStore* cell); ///< change the active cell
void setPlayerPos(const float x, const float y); ///< set player position in map space
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
void setFocusObject(const MWWorld::Ptr& focus);
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
void setMouseVisible(bool visible);
void getMousePosition(int &x, int &y);
void getMousePosition(float &x, float &y);
void setDragDrop(bool dragDrop);
bool getWorldMouseOver();
void toggleFogOfWar();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
void setInteriorMapTexture(const int x, const int y);
///< set the index of the map texture that should be used (for interiors)
// sets the visibility of the hud health/magicka/stamina bars
void setHMSVisibility(bool visible);
// sets the visibility of the hud minimap
void setMinimapVisibility(bool visible);
void setWeaponVisibility(bool visible);
void setSpellVisibility(bool visible);
void setSelectedSpell(const std::string& spellId, int successChancePercent);
void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent);
void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent);
void unsetSelectedSpell();
void unsetSelectedWeapon();
template<typename T>
void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr.
void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
void onFrame (float frameDuration);
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > getPlayerSkillValues() { return mPlayerSkillValues; }
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > getPlayerAttributeValues() { return mPlayerAttributes; }
SkillList getPlayerMinorSkills() { return mPlayerMinorSkills; }
SkillList getPlayerMajorSkills() { return mPlayerMajorSkills; }
/**
* Fetches a GMST string from the store, if there is no setting with the given
* ID or it is not a string the default string is returned.
*
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
const std::string &getGameSettingString(const std::string &id, const std::string &default_);
const ESMS::ESMStore& getStore() const;
void processChangedSettings(const Settings::CategorySettingVector& changed);
void executeInConsole (const std::string& path);
private:
OEngine::GUI::MyGUIManager *mGuiManager;
HUD *mHud;
MapWindow *mMap;
MainMenu *mMenu;
ToolTips *mToolTips;
StatsWindow *mStatsWindow;
MessageBoxManager *mMessageBoxManager;
Console *mConsole;
JournalWindow* mJournal;
DialogueWindow *mDialogueWindow;
ContainerWindow *mContainerWindow;
DragAndDrop* mDragAndDrop;
InventoryWindow *mInventoryWindow;
ScrollWindow* mScrollWindow;
BookWindow* mBookWindow;
CountDialog* mCountDialog;
TradeWindow* mTradeWindow;
SettingsWindow* mSettingsWindow;
ConfirmationDialog* mConfirmationDialog;
AlchemyWindow* mAlchemyWindow;
SpellWindow* mSpellWindow;
CharacterCreation* mCharGen;
// Various stats about player as needed by window manager
ESM::Class mPlayerClass;
std::string mPlayerName;
std::string mPlayerRaceId;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > mPlayerAttributes;
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > mPlayerSkillValues;
MWMechanics::DynamicStat<int> mPlayerHealth, mPlayerMagicka, mPlayerFatigue;
MyGUI::Gui *mGui; // Gui
std::vector<GuiMode> mGuiModes;
std::vector<OEngine::GUI::Layout*> mGarbageDialogs;
void cleanupGarbage();
GuiWindow mShown; // Currently shown windows in inventory mode
/* Currently ALLOWED windows in inventory mode. This is used at
the start of the game, when windows are enabled one by one
through script commands. You can manipulate this through using
allow() and disableAll().
*/
GuiWindow mAllowed;
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
int mShowFPSLevel;
float mFPS;
unsigned int mTriangleCount;
unsigned int mBatchCount;
void onDialogueWindowBye();
/**
* Called when MyGUI tries to retrieve a tag. This usually corresponds to a GMST string,
* so this method will retrieve the GMST with the name \a _tag and place the result in \a _result
*/
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
};
template<typename T>
void WindowManager::removeDialog(T*& dialog)
{
OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog);
removeDialog(d);
dialog = 0;
}
}
#endif

@ -1,9 +1,10 @@
#include "window_pinnable_base.hpp" #include "window_pinnable_base.hpp"
#include "window_manager.hpp"
#include "../mwbase/windowmanager.hpp"
using namespace MWGui; using namespace MWGui;
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, WindowManager& parWindowManager) WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, MWBase::WindowManager& parWindowManager)
: WindowBase(parLayout, parWindowManager), mPinned(false), mVisible(false) : WindowBase(parLayout, parWindowManager), mPinned(false), mVisible(false)
{ {
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget); MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
@ -30,4 +31,3 @@ void WindowPinnableBase::onWindowButtonPressed(MyGUI::Window* sender, const std:
eventDone(this); eventDone(this);
} }

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

Loading…
Cancel
Save