OpenMW
apps/openmw/mwgui/windowmanagerimp.hpp
Go to the documentation of this file.
00001 #ifndef MWGUI_WINDOWMANAGERIMP_H
00002 #define MWGUI_WINDOWMANAGERIMP_H
00003 
00013 #include "../mwbase/windowmanager.hpp"
00014 
00015 namespace MyGUI
00016 {
00017     class Gui;
00018     class Widget;
00019     class Window;
00020     class UString;
00021 }
00022 
00023 namespace Compiler
00024 {
00025     class Extensions;
00026 }
00027 
00028 namespace Translation
00029 {
00030     class Storage;
00031 }
00032 
00033 namespace OEngine
00034 {
00035     namespace GUI
00036     {
00037         class Layout;
00038         class MyGUIManager;
00039     }
00040 
00041     namespace Render
00042     {
00043         class OgreRenderer;
00044     }
00045 }
00046 
00047 namespace SFO
00048 {
00049     class CursorManager;
00050 }
00051 
00052 namespace MWGui
00053 {
00054   class WindowBase;
00055   class HUD;
00056   class MapWindow;
00057   class MainMenu;
00058   class StatsWindow;
00059   class InventoryWindow;
00060   class JournalWindow;
00061   class CharacterCreation;
00062   class DragAndDrop;
00063   class ToolTips;
00064   class TextInputDialog;
00065   class InfoBoxDialog;
00066   class MessageBoxManager;
00067   class SettingsWindow;
00068   class AlchemyWindow;
00069   class QuickKeysMenu;
00070   class LoadingScreen;
00071   class LevelupDialog;
00072   class WaitDialog;
00073   class SpellCreationDialog;
00074   class EnchantingDialog;
00075   class TrainingWindow;
00076   class Cursor;
00077   class SpellIcons;
00078   class MerchantRepair;
00079   class Repair;
00080   class SoulgemDialog;
00081   class Recharge;
00082   class CompanionWindow;
00083 
00084   class WindowManager : public MWBase::WindowManager
00085   {
00086   public:
00087     typedef std::pair<std::string, int> Faction;
00088     typedef std::vector<Faction> FactionList;
00089 
00090     WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
00091                   OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
00092                   const std::string& cacheDir, bool consoleOnlyScripts,
00093                   Translation::Storage& translationDataStorage, ToUTF8::FromType encoding);
00094     virtual ~WindowManager();
00095 
00096     void initUI();
00097     void renderWorldMap();
00098 
00099     virtual Loading::Listener* getLoadingScreen();
00100 
00106     virtual void update();
00107 
00108     virtual void setKeyFocusWidget (MyGUI::Widget* widget);
00109 
00110     virtual void setNewGame(bool newgame);
00111 
00112     virtual void pushGuiMode(GuiMode mode);
00113     virtual void popGuiMode();
00114     virtual void removeGuiMode(GuiMode mode); 
00115 
00116     virtual GuiMode getMode() const;
00117     virtual bool containsMode(GuiMode mode) const;
00118 
00119     virtual bool isGuiMode() const;
00120 
00121     virtual bool isConsoleMode() const;
00122 
00123     virtual void toggleVisible(GuiWindow wnd);
00124 
00125     virtual void forceHide(MWGui::GuiWindow wnd);
00126     virtual void unsetForceHide(MWGui::GuiWindow wnd);
00127 
00128     // Disallow all inventory mode windows
00129     virtual void disallowAll();
00130 
00131     // Allow one or more windows
00132     virtual void allow(GuiWindow wnd);
00133 
00134     virtual bool isAllowed(GuiWindow wnd) const;
00135 
00137     virtual MWGui::DialogueWindow* getDialogueWindow();
00138     virtual MWGui::ContainerWindow* getContainerWindow();
00139     virtual MWGui::InventoryWindow* getInventoryWindow();
00140     virtual MWGui::BookWindow* getBookWindow();
00141     virtual MWGui::ScrollWindow* getScrollWindow();
00142     virtual MWGui::CountDialog* getCountDialog();
00143     virtual MWGui::ConfirmationDialog* getConfirmationDialog();
00144     virtual MWGui::TradeWindow* getTradeWindow();
00145     virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow();
00146     virtual MWGui::TravelWindow* getTravelWindow();
00147     virtual MWGui::SpellWindow* getSpellWindow();
00148     virtual MWGui::Console* getConsole();
00149 
00150     virtual MyGUI::Gui* getGui() const;
00151 
00152     virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount);
00153 
00155     virtual void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
00156     virtual void setValue (int parSkill, const MWMechanics::Stat<float>& value);
00157     virtual void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value);
00158     virtual void setValue (const std::string& id, const std::string& value);
00159     virtual void setValue (const std::string& id, int value);
00160 
00163     virtual void setDrowningTimeLeft (float time);
00164 
00165     virtual void setPlayerClass (const ESM::Class &class_);                        
00166     virtual void configureSkills (const SkillList& major, const SkillList& minor); 
00167     virtual void setReputation (int reputation);                                   
00168     virtual void setBounty (int bounty);                                           
00169     virtual void updateSkillArea();                                                
00170 
00171     virtual void changeCell(MWWorld::CellStore* cell); 
00172     virtual void setPlayerPos(const float x, const float y); 
00173     virtual void setPlayerDir(const float x, const float y); 
00174 
00175     virtual void setFocusObject(const MWWorld::Ptr& focus);
00176     virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
00177 
00178     virtual void getMousePosition(int &x, int &y);
00179     virtual void getMousePosition(float &x, float &y);
00180     virtual void setDragDrop(bool dragDrop);
00181     virtual bool getWorldMouseOver();
00182 
00183     virtual void toggleFogOfWar();
00184     virtual void toggleFullHelp(); 
00185     virtual bool getFullHelp() const;
00186 
00187     virtual void setInteriorMapTexture(const int x, const int y);
00189 
00191     virtual void setDrowningBarVisibility(bool visible);
00192 
00193     // sets the visibility of the hud health/magicka/stamina bars
00194     virtual void setHMSVisibility(bool visible);
00195     // sets the visibility of the hud minimap
00196     virtual void setMinimapVisibility(bool visible);
00197     virtual void setWeaponVisibility(bool visible);
00198     virtual void setSpellVisibility(bool visible);
00199     virtual void setSneakVisibility(bool visible);
00200 
00201     virtual void activateQuickKey  (int index);
00202 
00203     virtual std::string getSelectedSpell() { return mSelectedSpell; }
00204     virtual void setSelectedSpell(const std::string& spellId, int successChancePercent);
00205     virtual void setSelectedEnchantItem(const MWWorld::Ptr& item);
00206     virtual void setSelectedWeapon(const MWWorld::Ptr& item);
00207     virtual void unsetSelectedSpell();
00208     virtual void unsetSelectedWeapon();
00209 
00210     virtual void showCrosshair(bool show);
00211     virtual bool getSubtitlesEnabled();
00212     virtual void toggleHud();
00213 
00214     virtual void disallowMouse();
00215     virtual void allowMouse();
00216     virtual void notifyInputActionBound();
00217 
00218     virtual void addVisitedLocation(const std::string& name, int x, int y);
00219 
00220     virtual void removeDialog(OEngine::GUI::Layout* dialog); 
00221 
00222     virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false);
00223     virtual void staticMessageBox(const std::string& message);
00224     virtual void removeStaticMessageBox();
00225     virtual void enterPressed ();
00226     virtual void activateKeyPressed ();
00227     virtual int readPressedButton (); 
00228 
00229     virtual void onFrame (float frameDuration);
00230 
00232     virtual std::map<int, MWMechanics::Stat<float> > getPlayerSkillValues();
00233     virtual std::map<int, MWMechanics::Stat<int> > getPlayerAttributeValues();
00234     virtual SkillList getPlayerMinorSkills();
00235     virtual SkillList getPlayerMajorSkills();
00236 
00244     virtual std::string getGameSettingString(const std::string &id, const std::string &default_);
00245 
00246     virtual void processChangedSettings(const Settings::CategorySettingVector& changed);
00247 
00248     virtual void windowResized(int x, int y);
00249 
00250     virtual void executeInConsole (const std::string& path);
00251 
00252     virtual void enableRest() { mRestAllowed = true; }
00253     virtual bool getRestEnabled();
00254 
00255     virtual bool getJournalAllowed() { return (mAllowed & GW_Magic); }
00256 
00257     virtual bool getPlayerSleeping();
00258     virtual void wakeUpPlayer();
00259 
00260     virtual void updatePlayer();
00261 
00262     virtual void showCompanionWindow(MWWorld::Ptr actor);
00263     virtual void startSpellMaking(MWWorld::Ptr actor);
00264     virtual void startEnchanting(MWWorld::Ptr actor);
00265     virtual void startSelfEnchanting(MWWorld::Ptr soulgem);
00266     virtual void startTraining(MWWorld::Ptr actor);
00267     virtual void startRepair(MWWorld::Ptr actor);
00268     virtual void startRepairItem(MWWorld::Ptr item);
00269     virtual void startRecharge(MWWorld::Ptr soulgem);
00270 
00271     virtual void frameStarted(float dt);
00272 
00273     virtual void showSoulgemDialog (MWWorld::Ptr item);
00274 
00275     virtual void changePointer (const std::string& name);
00276 
00277     virtual void setEnemy (const MWWorld::Ptr& enemy);
00278 
00279     virtual const Translation::Storage& getTranslationDataStorage() const;
00280 
00281     void onSoulgemDialogButtonPressed (int button);
00282 
00283     virtual bool getCursorVisible();
00284 
00285   private:
00286     bool mConsoleOnlyScripts;
00287 
00288     std::map<MyGUI::Window*, std::string> mTrackedWindows;
00289     void trackWindow(OEngine::GUI::Layout* layout, const std::string& name);
00290     void onWindowChangeCoord(MyGUI::Window* _sender);
00291 
00292     std::string mSelectedSpell;
00293 
00294     OEngine::GUI::MyGUIManager *mGuiManager;
00295     OEngine::Render::OgreRenderer *mRendering;
00296     HUD *mHud;
00297     MapWindow *mMap;
00298     MainMenu *mMenu;
00299     ToolTips *mToolTips;
00300     StatsWindow *mStatsWindow;
00301     MessageBoxManager *mMessageBoxManager;
00302     Console *mConsole;
00303     JournalWindow* mJournal;
00304     DialogueWindow *mDialogueWindow;
00305     ContainerWindow *mContainerWindow;
00306     DragAndDrop* mDragAndDrop;
00307     InventoryWindow *mInventoryWindow;
00308     ScrollWindow* mScrollWindow;
00309     BookWindow* mBookWindow;
00310     CountDialog* mCountDialog;
00311     TradeWindow* mTradeWindow;
00312     SpellBuyingWindow* mSpellBuyingWindow;
00313     TravelWindow* mTravelWindow;
00314     SettingsWindow* mSettingsWindow;
00315     ConfirmationDialog* mConfirmationDialog;
00316     AlchemyWindow* mAlchemyWindow;
00317     SpellWindow* mSpellWindow;
00318     QuickKeysMenu* mQuickKeysMenu;
00319     LoadingScreen* mLoadingScreen;
00320     LevelupDialog* mLevelupDialog;
00321     WaitDialog* mWaitDialog;
00322     SpellCreationDialog* mSpellCreationDialog;
00323     EnchantingDialog* mEnchantingDialog;
00324     TrainingWindow* mTrainingWindow;
00325     MerchantRepair* mMerchantRepair;
00326     SoulgemDialog* mSoulgemDialog;
00327     Repair* mRepair;
00328     Recharge* mRecharge;
00329     CompanionWindow* mCompanionWindow;
00330 
00331     Translation::Storage& mTranslationDataStorage;
00332     Cursor* mSoftwareCursor;
00333 
00334     CharacterCreation* mCharGen;
00335 
00336     MyGUI::Widget* mInputBlocker;
00337 
00338     bool mCrosshairEnabled;
00339     bool mSubtitlesEnabled;
00340     bool mHudEnabled;
00341     bool mCursorVisible;
00342 
00343     void setCursorVisible(bool visible);
00344 
00346     // Various stats about player as needed by window manager
00347     std::string mPlayerName;
00348     std::string mPlayerRaceId;
00349     std::map<int, MWMechanics::Stat<int> > mPlayerAttributes;
00350     SkillList mPlayerMajorSkills, mPlayerMinorSkills;
00351     std::map<int, MWMechanics::Stat<float> > mPlayerSkillValues;
00352 
00353     MyGUI::Gui *mGui; // Gui
00354     std::vector<GuiMode> mGuiModes;
00355 
00356     SFO::CursorManager* mCursorManager;
00357 
00358     std::vector<OEngine::GUI::Layout*> mGarbageDialogs;
00359     void cleanupGarbage();
00360 
00361     GuiWindow mShown; // Currently shown windows in inventory mode
00362     GuiWindow mForceHidden; // Hidden windows (overrides mShown)
00363 
00364     /* Currently ALLOWED windows in inventory mode. This is used at
00365        the start of the game, when windows are enabled one by one
00366        through script commands. You can manipulate this through using
00367        allow() and disableAll().
00368      */
00369     GuiWindow mAllowed;
00370     // is the rest window allowed?
00371     bool mRestAllowed;
00372 
00373     void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
00374 
00375     int mShowFPSLevel;
00376     float mFPS;
00377     unsigned int mTriangleCount;
00378     unsigned int mBatchCount;
00379 
00384     void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
00385 
00386     void onCursorChange(const std::string& name);
00387     void onKeyFocusChanged(MyGUI::Widget* widget);
00388   };
00389 }
00390 
00391 #endif