2010-07-17 14:01:47 +02:00
|
|
|
#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.
|
2012-01-30 21:53:17 +02:00
|
|
|
**/
|
2010-07-17 14:01:47 +02:00
|
|
|
|
2012-05-19 14:19:21 +02:00
|
|
|
#include "MyGUI_UString.h"
|
|
|
|
|
2010-10-21 09:28:09 +02:00
|
|
|
#include <components/esm_store/store.hpp>
|
2012-05-24 11:50:48 +02:00
|
|
|
#include <components/settings/settings.hpp>
|
2012-01-29 17:31:18 +02:00
|
|
|
#include <openengine/ogre/renderer.hpp>
|
|
|
|
#include <openengine/gui/manager.hpp>
|
2012-05-19 14:19:21 +02:00
|
|
|
|
2010-07-27 15:59:41 +02:00
|
|
|
#include "../mwmechanics/stat.hpp"
|
2012-05-19 14:19:21 +02:00
|
|
|
|
2010-09-15 14:48:19 +02:00
|
|
|
#include "mode.hpp"
|
2010-07-27 15:59:41 +02:00
|
|
|
|
2010-07-17 14:01:47 +02:00
|
|
|
namespace MyGUI
|
|
|
|
{
|
|
|
|
class Gui;
|
2010-10-10 00:42:56 +02:00
|
|
|
class Widget;
|
2010-07-17 14:01:47 +02:00
|
|
|
}
|
|
|
|
|
2010-07-20 23:21:48 +02:00
|
|
|
namespace Compiler
|
|
|
|
{
|
|
|
|
class Extensions;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-07-03 13:55:53 +02:00
|
|
|
class Ptr;
|
|
|
|
class CellStore;
|
2012-01-30 16:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
class MechanicsManager;
|
2010-07-20 23:21:48 +02:00
|
|
|
}
|
|
|
|
|
2010-10-22 22:53:34 +02:00
|
|
|
namespace OEngine
|
|
|
|
{
|
|
|
|
namespace GUI
|
|
|
|
{
|
|
|
|
class Layout;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-17 14:01:47 +02:00
|
|
|
namespace MWGui
|
|
|
|
{
|
2011-02-21 22:33:29 +01:00
|
|
|
class WindowBase;
|
2010-07-17 14:01:47 +02:00
|
|
|
class HUD;
|
|
|
|
class MapWindow;
|
|
|
|
class MainMenu;
|
|
|
|
class StatsWindow;
|
2010-09-10 03:29:29 +02:00
|
|
|
class InventoryWindow;
|
2010-07-20 21:10:51 +02:00
|
|
|
class Console;
|
2011-11-28 16:51:11 +01:00
|
|
|
class JournalWindow;
|
2012-01-30 16:38:43 +02:00
|
|
|
class CharacterCreation;
|
2012-04-15 17:52:39 +02:00
|
|
|
class ContainerWindow;
|
2012-04-30 13:01:18 +02:00
|
|
|
class DragAndDrop;
|
2012-04-21 10:51:01 +02:00
|
|
|
class InventoryWindow;
|
2012-04-14 17:47:44 +02:00
|
|
|
class ToolTips;
|
2012-05-03 03:33:33 +02:00
|
|
|
class ScrollWindow;
|
|
|
|
class BookWindow;
|
2010-09-14 23:17:08 +02:00
|
|
|
class TextInputDialog;
|
2010-10-10 00:42:56 +02:00
|
|
|
class InfoBoxDialog;
|
2010-11-03 21:21:08 +01:00
|
|
|
class DialogueWindow;
|
2011-06-14 18:29:55 +02:00
|
|
|
class MessageBoxManager;
|
2012-05-15 12:51:51 +02:00
|
|
|
class CountDialog;
|
2012-05-17 13:36:25 +02:00
|
|
|
class TradeWindow;
|
2012-05-22 21:40:42 +02:00
|
|
|
class SettingsWindow;
|
2012-05-23 05:28:25 +02:00
|
|
|
class ConfirmationDialog;
|
2012-05-24 15:57:23 +02:00
|
|
|
class AlchemyWindow;
|
2012-05-29 09:02:22 +02:00
|
|
|
class SpellWindow;
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2011-01-02 17:42:45 +01:00
|
|
|
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];
|
|
|
|
};
|
|
|
|
|
2010-07-17 14:01:47 +02:00
|
|
|
class WindowManager
|
|
|
|
{
|
2010-10-21 09:28:09 +02:00
|
|
|
public:
|
|
|
|
typedef std::pair<std::string, int> Faction;
|
|
|
|
typedef std::vector<Faction> FactionList;
|
|
|
|
typedef std::vector<int> SkillList;
|
|
|
|
|
2012-06-06 20:29:30 +02:00
|
|
|
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath);
|
2010-07-17 14:01:47 +02:00
|
|
|
virtual ~WindowManager();
|
|
|
|
|
2010-10-22 22:53:34 +02:00
|
|
|
/**
|
|
|
|
* Should be called each frame to update windows/gui elements.
|
|
|
|
* This could mean updating sizes of gui elements or opening
|
|
|
|
* new dialogs.
|
|
|
|
*/
|
|
|
|
void update();
|
|
|
|
|
2012-05-23 12:23:35 +02:00
|
|
|
void pushGuiMode(GuiMode mode);
|
|
|
|
void popGuiMode();
|
2012-05-27 01:14:33 +02:00
|
|
|
void removeGuiMode(GuiMode mode); ///< can be anywhere in the stack
|
2010-07-28 18:48:01 +02:00
|
|
|
|
2012-05-23 12:23:35 +02:00
|
|
|
GuiMode getMode() const
|
|
|
|
{
|
|
|
|
if (mGuiModes.empty())
|
|
|
|
throw std::runtime_error ("getMode() called, but there is no active mode");
|
|
|
|
return mGuiModes.back();
|
2010-07-17 14:01:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-23 12:23:35 +02:00
|
|
|
bool isGuiMode() const { return !mGuiModes.empty(); }
|
2010-07-17 14:01:47 +02:00
|
|
|
|
2012-05-26 21:09:21 +02:00
|
|
|
void toggleVisible(GuiWindow wnd)
|
|
|
|
{
|
2012-07-13 03:51:58 -07:00
|
|
|
mShown = (mShown & wnd) ? (GuiWindow) (mShown & ~wnd) : (GuiWindow) (mShown | wnd);
|
2012-05-26 21:09:21 +02:00
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
2010-07-17 14:01:47 +02:00
|
|
|
// Disallow all inventory mode windows
|
|
|
|
void disallowAll()
|
|
|
|
{
|
2012-07-13 03:51:58 -07:00
|
|
|
mAllowed = GW_None;
|
2010-07-17 14:01:47 +02:00
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow one or more windows
|
|
|
|
void allow(GuiWindow wnd)
|
|
|
|
{
|
2012-07-13 03:51:58 -07:00
|
|
|
mAllowed = (GuiWindow)(mAllowed | wnd);
|
2010-07-17 14:01:47 +02:00
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
2012-06-06 20:29:30 +02:00
|
|
|
bool isAllowed(GuiWindow wnd) const
|
2012-05-25 18:45:17 +02:00
|
|
|
{
|
2012-07-13 03:51:58 -07:00
|
|
|
return mAllowed & wnd;
|
2012-05-25 18:45:17 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 13:01:18 +02:00
|
|
|
MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;}
|
|
|
|
MWGui::ContainerWindow* getContainerWindow() {return mContainerWindow;}
|
2012-05-17 21:15:48 +02:00
|
|
|
MWGui::InventoryWindow* getInventoryWindow() {return mInventoryWindow;}
|
2012-05-03 05:26:05 +02:00
|
|
|
MWGui::BookWindow* getBookWindow() {return mBookWindow;}
|
|
|
|
MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;}
|
2012-05-15 12:51:51 +02:00
|
|
|
MWGui::CountDialog* getCountDialog() {return mCountDialog;}
|
2012-05-23 05:28:25 +02:00
|
|
|
MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
|
2012-05-17 17:15:44 +02:00
|
|
|
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
|
2012-05-29 12:35:03 +02:00
|
|
|
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
|
2012-07-13 03:51:58 -07:00
|
|
|
MWGui::Console* getConsole() {return mConsole;}
|
2012-05-03 05:26:05 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
MyGUI::Gui* getGui() const { return mGui; }
|
2010-07-28 18:48:01 +02:00
|
|
|
|
2012-06-22 12:56:04 +02:00
|
|
|
void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount)
|
2012-01-16 15:33:21 +00:00
|
|
|
{
|
|
|
|
mFPS = fps;
|
|
|
|
mTriangleCount = triangleCount;
|
|
|
|
mBatchCount = batchCount;
|
|
|
|
}
|
2011-02-18 17:46:24 +03:00
|
|
|
|
2012-02-03 11:24:28 +01:00
|
|
|
// MWMechanics::DynamicStat<int> getValue(const std::string& id);
|
2010-07-28 18:48:01 +02:00
|
|
|
|
2010-09-18 18:04:53 +02:00
|
|
|
///< Set value for the given ID.
|
2012-01-30 21:53:17 +02:00
|
|
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
|
|
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
2010-07-28 18:48:01 +02:00
|
|
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
2010-09-15 12:22:06 +02:00
|
|
|
void setValue (const std::string& id, const std::string& value);
|
2010-09-15 15:32:35 +02:00
|
|
|
void setValue (const std::string& id, int value);
|
2010-09-18 01:30:23 +02:00
|
|
|
|
2012-01-30 21:53:17 +02:00
|
|
|
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
|
2010-09-18 02:24:42 +02:00
|
|
|
|
2012-07-03 13:55:53 +02:00
|
|
|
void changeCell(MWWorld::CellStore* cell); ///< change the active cell
|
2012-03-23 08:16:04 +01:00
|
|
|
void setPlayerPos(const float x, const float y); ///< set player position in map space
|
2012-03-23 15:00:48 +01:00
|
|
|
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
|
2012-03-29 19:45:19 +02:00
|
|
|
|
2012-04-15 17:10:08 +02:00
|
|
|
void setFocusObject(const MWWorld::Ptr& focus);
|
2012-05-14 21:37:43 +02:00
|
|
|
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
|
2012-04-15 17:10:08 +02:00
|
|
|
|
2012-05-13 11:25:35 +02:00
|
|
|
void setMouseVisible(bool visible);
|
2012-06-02 12:25:24 +02:00
|
|
|
void getMousePosition(int &x, int &y);
|
|
|
|
void getMousePosition(float &x, float &y);
|
2012-05-13 11:25:35 +02:00
|
|
|
void setDragDrop(bool dragDrop);
|
2012-06-02 12:25:24 +02:00
|
|
|
bool getWorldMouseOver();
|
2012-05-13 10:18:17 +02:00
|
|
|
|
2012-03-29 19:45:19 +02:00
|
|
|
void toggleFogOfWar();
|
2012-04-16 15:00:44 +02:00
|
|
|
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
|
2012-04-16 22:58:16 +02:00
|
|
|
bool getFullHelp() const;
|
2012-04-13 13:17:50 +02:00
|
|
|
|
2012-03-17 13:59:51 +01:00
|
|
|
void setInteriorMapTexture(const int x, const int y);
|
|
|
|
///< set the index of the map texture that should be used (for interiors)
|
2012-03-10 16:05:12 +01:00
|
|
|
|
2012-04-06 01:17:23 +03:00
|
|
|
// 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);
|
2012-05-12 22:44:12 +02:00
|
|
|
void setWeaponVisibility(bool visible);
|
|
|
|
void setSpellVisibility(bool visible);
|
2012-04-06 01:17:23 +03:00
|
|
|
|
2012-05-29 18:33:01 +02:00
|
|
|
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();
|
|
|
|
|
2010-10-22 23:14:21 +02:00
|
|
|
template<typename T>
|
2012-01-30 21:53:17 +02:00
|
|
|
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.
|
2010-10-22 23:14:21 +02:00
|
|
|
|
2010-08-22 11:22:10 +02:00
|
|
|
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
2012-01-30 21:53:17 +02:00
|
|
|
int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
2012-02-03 11:24:28 +01:00
|
|
|
|
2011-06-15 22:53:05 +02:00
|
|
|
void onFrame (float frameDuration);
|
2010-09-14 19:33:40 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
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; }
|
2012-05-28 10:50:00 +02:00
|
|
|
|
2010-09-15 12:41:53 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2010-09-15 22:22:27 +02:00
|
|
|
const std::string &getGameSettingString(const std::string &id, const std::string &default_);
|
2010-09-15 12:41:53 +02:00
|
|
|
|
2011-04-21 10:49:45 +02:00
|
|
|
const ESMS::ESMStore& getStore() const;
|
2011-02-21 20:36:35 +01:00
|
|
|
|
2012-05-24 11:50:48 +02:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
|
|
|
|
2010-09-14 19:33:40 +02:00
|
|
|
private:
|
2012-02-03 11:24:28 +01:00
|
|
|
OEngine::GUI::MyGUIManager *mGuiManager;
|
2012-07-13 03:51:58 -07:00
|
|
|
HUD *mHud;
|
|
|
|
MapWindow *mMap;
|
|
|
|
MainMenu *mMenu;
|
2012-04-14 17:47:44 +02:00
|
|
|
ToolTips *mToolTips;
|
2012-05-19 14:19:21 +02:00
|
|
|
StatsWindow *mStatsWindow;
|
2012-02-02 18:31:28 +02:00
|
|
|
MessageBoxManager *mMessageBoxManager;
|
2012-07-13 03:51:58 -07:00
|
|
|
Console *mConsole;
|
2012-02-02 18:31:28 +02:00
|
|
|
JournalWindow* mJournal;
|
2012-04-30 13:01:18 +02:00
|
|
|
DialogueWindow *mDialogueWindow;
|
|
|
|
ContainerWindow *mContainerWindow;
|
|
|
|
DragAndDrop* mDragAndDrop;
|
2012-04-21 10:51:01 +02:00
|
|
|
InventoryWindow *mInventoryWindow;
|
2012-05-03 03:33:33 +02:00
|
|
|
ScrollWindow* mScrollWindow;
|
|
|
|
BookWindow* mBookWindow;
|
2012-05-15 12:51:51 +02:00
|
|
|
CountDialog* mCountDialog;
|
2012-05-17 13:36:25 +02:00
|
|
|
TradeWindow* mTradeWindow;
|
2012-05-22 21:40:42 +02:00
|
|
|
SettingsWindow* mSettingsWindow;
|
2012-05-23 05:28:25 +02:00
|
|
|
ConfirmationDialog* mConfirmationDialog;
|
2012-05-24 15:57:23 +02:00
|
|
|
AlchemyWindow* mAlchemyWindow;
|
2012-05-29 09:02:22 +02:00
|
|
|
SpellWindow* mSpellWindow;
|
2010-11-03 21:21:08 +01:00
|
|
|
|
2012-02-02 18:31:28 +02:00
|
|
|
CharacterCreation* mCharGen;
|
2012-02-03 11:24:28 +01:00
|
|
|
|
2012-02-02 18:31:28 +02:00
|
|
|
// Various stats about player as needed by window manager
|
2012-07-13 03:51:58 -07:00
|
|
|
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;
|
2010-11-03 21:21:08 +01:00
|
|
|
|
2010-09-14 23:17:08 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
MyGUI::Gui *mGui; // Gui
|
2012-05-23 12:23:35 +02:00
|
|
|
std::vector<GuiMode> mGuiModes;
|
2010-09-19 04:29:22 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
std::vector<OEngine::GUI::Layout*> mGarbageDialogs;
|
2012-02-02 18:31:28 +02:00
|
|
|
void cleanupGarbage();
|
2010-10-10 00:42:56 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
GuiWindow mShown; // Currently shown windows in inventory mode
|
2010-10-10 00:42:56 +02:00
|
|
|
|
2012-02-02 18:31:28 +02:00
|
|
|
/* 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().
|
|
|
|
*/
|
2012-07-13 03:51:58 -07:00
|
|
|
GuiWindow mAllowed;
|
2010-10-10 02:43:44 +02:00
|
|
|
|
2012-02-02 18:31:28 +02:00
|
|
|
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
|
2010-10-20 21:40:32 +02:00
|
|
|
|
2012-07-13 03:51:58 -07:00
|
|
|
int mShowFPSLevel;
|
2012-02-02 18:31:28 +02:00
|
|
|
float mFPS;
|
2012-06-22 12:56:04 +02:00
|
|
|
unsigned int mTriangleCount;
|
|
|
|
unsigned int mBatchCount;
|
2011-01-03 00:57:40 +01:00
|
|
|
|
2010-11-03 21:21:08 +01:00
|
|
|
void onDialogueWindowBye();
|
2012-05-19 14:19:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when MyGUI tries to retrieve a tag. This usually corresponds to a GMST string,
|
2012-07-03 13:55:53 +02:00
|
|
|
* so this method will retrieve the GMST with the name \a _tag and place the result in \a _result
|
2012-05-19 14:19:21 +02:00
|
|
|
*/
|
|
|
|
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
|
2010-07-17 14:01:47 +02:00
|
|
|
};
|
2010-10-22 23:14:21 +02:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void WindowManager::removeDialog(T*& dialog)
|
|
|
|
{
|
|
|
|
OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog);
|
|
|
|
removeDialog(d);
|
2010-10-22 23:34:41 +02:00
|
|
|
dialog = 0;
|
2010-10-22 23:14:21 +02:00
|
|
|
}
|
2010-07-17 14:01:47 +02:00
|
|
|
}
|
2010-10-22 23:14:21 +02:00
|
|
|
|
2010-07-17 14:01:47 +02:00
|
|
|
#endif
|