1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 17:19:56 +00:00
openmw-tes3mp/apps/openmw/mwgui/window_manager.hpp

293 lines
9.1 KiB
C++
Raw Normal View History

#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 <string>
#include <vector>
#include <set>
#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"
2012-03-16 16:09:31 +00:00
#include "../mwworld/ptr.hpp"
#include "mode.hpp"
namespace MyGUI
{
class Gui;
class Widget;
}
namespace Compiler
{
class Extensions;
}
namespace MWWorld
{
class World;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace OEngine
{
namespace GUI
{
class Layout;
}
}
namespace MWGui
{
class WindowBase;
class HUD;
class MapWindow;
class MainMenu;
class StatsWindow;
class InventoryWindow;
2010-07-20 19:10:51 +00:00
class Console;
class JournalWindow;
class CharacterCreation;
2012-04-15 15:52:39 +00:00
class ContainerWindow;
2012-04-30 11:01:18 +00:00
class DragAndDrop;
2012-04-21 08:51:01 +00:00
class InventoryWindow;
2012-04-14 15:47:44 +00:00
class ToolTips;
2012-05-03 01:33:33 +00:00
class ScrollWindow;
class BookWindow;
class TextInputDialog;
class InfoBoxDialog;
2010-11-03 20:21:08 +00:00
class DialogueWindow;
2011-06-14 16:29:55 +00:00
class MessageBoxManager;
class CountDialog;
class TradeWindow;
class SettingsWindow;
2012-05-23 03:28:25 +00:00
class ConfirmationDialog;
class AlchemyWindow;
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);
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();
2012-05-23 10:23:35 +00:00
void pushGuiMode(GuiMode mode);
void popGuiMode();
2012-05-23 10:23:35 +00:00
GuiMode getMode() const
{
if (mGuiModes.empty())
throw std::runtime_error ("getMode() called, but there is no active mode");
return mGuiModes.back();
}
2012-05-23 10:23:35 +00:00
bool isGuiMode() const { return !mGuiModes.empty(); }
// Disallow all inventory mode windows
void disallowAll()
{
allowed = GW_None;
updateVisible();
}
// Allow one or more windows
void allow(GuiWindow wnd)
{
allowed = (GuiWindow)(allowed | wnd);
updateVisible();
}
2012-04-30 11:01:18 +00:00
MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;}
MWGui::ContainerWindow* getContainerWindow() {return mContainerWindow;}
2012-05-17 19:15:48 +00:00
MWGui::InventoryWindow* getInventoryWindow() {return mInventoryWindow;}
MWGui::BookWindow* getBookWindow() {return mBookWindow;}
MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;}
MWGui::CountDialog* getCountDialog() {return mCountDialog;}
2012-05-23 03:28:25 +00:00
MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
2012-05-17 15:15:44 +00:00
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
MyGUI::Gui* getGui() const { return gui; }
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)
{
mFPS = fps;
mTriangleCount = triangleCount;
mBatchCount = batchCount;
}
2011-02-18 14:46:24 +00:00
// 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);
2010-09-15 13:32:35 +00:00
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
2012-03-16 16:09:31 +00:00
void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell
void setPlayerPos(const float x, const float y); ///< set player position in map space
2012-03-23 14:00:48 +00:00
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
2012-03-29 17:45:19 +00:00
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 setDragDrop(bool dragDrop);
2012-03-29 17:45:19 +00:00
void toggleFogOfWar();
2012-04-16 13:00:44 +00:00
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
2012-04-13 11:17:50 +00:00
2012-03-17 12:59:51 +00: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 15:05:12 +00: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 20:44:12 +00:00
void setWeaponVisibility(bool visible);
void setSpellVisibility(bool visible);
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);
/**
* 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 20:22:27 +00:00
const std::string &getGameSettingString(const std::string &id, const std::string &default_);
2011-04-21 08:49:45 +00:00
const ESMS::ESMStore& getStore() const;
void processChangedSettings(const Settings::CategorySettingVector& changed);
private:
OEngine::GUI::MyGUIManager *mGuiManager;
HUD *hud;
MapWindow *map;
MainMenu *menu;
2012-04-14 15:47:44 +00:00
ToolTips *mToolTips;
StatsWindow *mStatsWindow;
MessageBoxManager *mMessageBoxManager;
Console *console;
JournalWindow* mJournal;
2012-04-30 11:01:18 +00:00
DialogueWindow *mDialogueWindow;
ContainerWindow *mContainerWindow;
DragAndDrop* mDragAndDrop;
2012-04-21 08:51:01 +00:00
InventoryWindow *mInventoryWindow;
2012-05-03 01:33:33 +00:00
ScrollWindow* mScrollWindow;
BookWindow* mBookWindow;
CountDialog* mCountDialog;
TradeWindow* mTradeWindow;
SettingsWindow* mSettingsWindow;
2012-05-23 03:28:25 +00:00
ConfirmationDialog* mConfirmationDialog;
AlchemyWindow* mAlchemyWindow;
2010-11-03 20:21:08 +00:00
CharacterCreation* mCharGen;
// Various stats about player as needed by window manager
ESM::Class playerClass;
std::string playerName;
std::string playerRaceId;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes;
SkillList playerMajorSkills, playerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues;
MWMechanics::DynamicStat<int> playerHealth, playerMagicka, playerFatigue;
2010-11-03 20:21:08 +00:00
MyGUI::Gui *gui; // Gui
2012-05-23 10:23:35 +00:00
std::vector<GuiMode> mGuiModes;
std::vector<OEngine::GUI::Layout*> garbageDialogs;
void cleanupGarbage();
GuiWindow shown; // 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().
The setting should also affect visibility of certain HUD
elements, but this is not done yet.
*/
GuiWindow allowed;
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
int showFPSLevel;
float mFPS;
size_t mTriangleCount;
size_t mBatchCount;
2010-11-03 20:21:08 +00:00
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