Finally merged in master
commit
0697c7f7f4
@ -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
|
@ -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
|
@ -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
|
@ -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);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -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 ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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
|
@ -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
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue