1 #ifndef GAME_MWBASE_WINDOWMANAGER_H 2 #define GAME_MWBASE_WINDOWMANAGER_H 3 4 #include <stdint.h> 5 #include <string> 6 #include <vector> 7 #include <map> 8 #include <set> 9 10 #include <MyGUI_KeyCode.h> 11 12 #include "../mwgui/mode.hpp" 13 14 #include <components/sdlutil/events.hpp> 15 16 namespace Loading 17 { 18 class Listener; 19 } 20 21 namespace Translation 22 { 23 class Storage; 24 } 25 26 namespace MyGUI 27 { 28 class Gui; 29 class Widget; 30 class UString; 31 } 32 33 namespace ESM 34 { 35 class ESMReader; 36 class ESMWriter; 37 struct CellId; 38 } 39 40 namespace MWMechanics 41 { 42 class AttributeValue; 43 template<typename T> 44 class DynamicStat; 45 class SkillValue; 46 } 47 48 namespace MWWorld 49 { 50 class CellStore; 51 class Ptr; 52 } 53 54 namespace MWGui 55 { 56 class Layout; 57 58 class Console; 59 class SpellWindow; 60 class TradeWindow; 61 class TravelWindow; 62 class SpellBuyingWindow; 63 class ConfirmationDialog; 64 class CountDialog; 65 class ScrollWindow; 66 class BookWindow; 67 class InventoryWindow; 68 class ContainerWindow; 69 class DialogueWindow; 70 class WindowModal; 71 class JailScreen; 72 73 enum ShowInDialogueMode { 74 ShowInDialogueMode_IfPossible, 75 ShowInDialogueMode_Only, 76 ShowInDialogueMode_Never 77 }; 78 79 struct TextColours; 80 } 81 82 namespace SFO 83 { 84 class CursorManager; 85 } 86 87 namespace MWBase 88 { 89 /// \brief Interface for widnow manager (implemented in MWGui) 90 class WindowManager : public SDLUtil::WindowListener 91 { 92 WindowManager (const WindowManager&); 93 ///< not implemented 94 95 WindowManager& operator= (const WindowManager&); 96 ///< not implemented 97 98 public: 99 100 typedef std::vector<int> SkillList; 101 WindowManager()102 WindowManager() {} 103 ~WindowManager()104 virtual ~WindowManager() {} 105 106 /// @note This method will block until the video finishes playing 107 /// (and will continually update the window while doing so) 108 virtual void playVideo(const std::string& name, bool allowSkipping) = 0; 109 110 virtual void setNewGame(bool newgame) = 0; 111 112 virtual void pushGuiMode (MWGui::GuiMode mode, const MWWorld::Ptr& arg) = 0; 113 virtual void pushGuiMode (MWGui::GuiMode mode) = 0; 114 virtual void popGuiMode(bool noSound=false) = 0; 115 116 virtual void removeGuiMode (MWGui::GuiMode mode, bool noSound=false) = 0; 117 ///< can be anywhere in the stack 118 119 virtual void goToJail(int days) = 0; 120 121 virtual void updatePlayer() = 0; 122 123 virtual MWGui::GuiMode getMode() const = 0; 124 virtual bool containsMode(MWGui::GuiMode) const = 0; 125 126 virtual bool isGuiMode() const = 0; 127 128 virtual bool isConsoleMode() const = 0; 129 130 virtual void toggleVisible (MWGui::GuiWindow wnd) = 0; 131 132 virtual void forceHide(MWGui::GuiWindow wnd) = 0; 133 virtual void unsetForceHide(MWGui::GuiWindow wnd) = 0; 134 135 /// Disallow all inventory mode windows 136 virtual void disallowAll() = 0; 137 138 /// Allow one or more windows 139 virtual void allow (MWGui::GuiWindow wnd) = 0; 140 141 virtual bool isAllowed (MWGui::GuiWindow wnd) const = 0; 142 143 /// \todo investigate, if we really need to expose every single lousy UI element to the outside world 144 virtual MWGui::InventoryWindow* getInventoryWindow() = 0; 145 virtual MWGui::CountDialog* getCountDialog() = 0; 146 virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; 147 virtual MWGui::TradeWindow* getTradeWindow() = 0; 148 149 /// Make the player use an item, while updating GUI state accordingly 150 virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; 151 152 virtual void updateSpellWindow() = 0; 153 154 virtual void setConsoleSelectedObject(const MWWorld::Ptr& object) = 0; 155 156 /// Set time left for the player to start drowning (update the drowning bar) 157 /// @param time time left to start drowning 158 /// @param maxTime how long we can be underwater (in total) until drowning starts 159 virtual void setDrowningTimeLeft (float time, float maxTime) = 0; 160 161 virtual void changeCell(const MWWorld::CellStore* cell) = 0; 162 ///< change the active cell 163 164 virtual void setFocusObject(const MWWorld::Ptr& focus) = 0; 165 virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) = 0; 166 167 virtual void setCursorVisible(bool visible) = 0; 168 virtual void setCursorActive(bool active) = 0; 169 virtual void getMousePosition(int &x, int &y) = 0; 170 virtual void getMousePosition(float &x, float &y) = 0; 171 virtual void setDragDrop(bool dragDrop) = 0; 172 virtual bool getWorldMouseOver() = 0; 173 174 virtual float getScalingFactor() = 0; 175 176 virtual bool toggleFogOfWar() = 0; 177 178 virtual bool toggleFullHelp() = 0; 179 ///< show extra info in item tooltips (owner, script) 180 181 virtual bool getFullHelp() const = 0; 182 183 virtual void setActiveMap(int x, int y, bool interior) = 0; 184 ///< set the indices of the map texture that should be used 185 186 /// sets the visibility of the drowning bar 187 virtual void setDrowningBarVisibility(bool visible) = 0; 188 189 /// sets the visibility of the hud health/magicka/stamina bars 190 virtual void setHMSVisibility(bool visible) = 0; 191 192 /// sets the visibility of the hud minimap 193 virtual void setMinimapVisibility(bool visible) = 0; 194 virtual void setWeaponVisibility(bool visible) = 0; 195 virtual void setSpellVisibility(bool visible) = 0; 196 virtual void setSneakVisibility(bool visible) = 0; 197 198 /// activate selected quick key 199 virtual void activateQuickKey (int index) = 0; 200 /// update activated quick key state (if action executing was delayed for some reason) 201 virtual void updateActivatedQuickKey () = 0; 202 203 virtual std::string getSelectedSpell() = 0; 204 virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0; 205 virtual void setSelectedEnchantItem(const MWWorld::Ptr& item) = 0; 206 virtual const MWWorld::Ptr& getSelectedEnchantItem() const = 0; 207 virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0; 208 virtual const MWWorld::Ptr& getSelectedWeapon() const = 0; 209 virtual int getFontHeight() const = 0; 210 virtual void unsetSelectedSpell() = 0; 211 virtual void unsetSelectedWeapon() = 0; 212 213 virtual void showCrosshair(bool show) = 0; 214 virtual bool getSubtitlesEnabled() = 0; 215 virtual bool toggleHud() = 0; 216 217 virtual void disallowMouse() = 0; 218 virtual void allowMouse() = 0; 219 virtual void notifyInputActionBound() = 0; 220 221 virtual void addVisitedLocation(const std::string& name, int x, int y) = 0; 222 223 /// Hides dialog and schedules dialog to be deleted. 224 virtual void removeDialog(MWGui::Layout* dialog) = 0; 225 226 ///Gracefully attempts to exit the topmost GUI mode 227 /** No guarantee of actually closing the window **/ 228 virtual void exitCurrentGuiMode() = 0; 229 230 virtual void messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0; 231 virtual void staticMessageBox(const std::string& message) = 0; 232 virtual void removeStaticMessageBox() = 0; 233 virtual void interactiveMessageBox (const std::string& message, 234 const std::vector<std::string>& buttons = std::vector<std::string>(), bool block=false) = 0; 235 236 /// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) 237 virtual int readPressedButton() = 0; 238 239 virtual void update (float duration) = 0; 240 241 virtual void updateConsoleObjectPtr(const MWWorld::Ptr& currentPtr, const MWWorld::Ptr& newPtr) = 0; 242 243 /** 244 * Fetches a GMST string from the store, if there is no setting with the given 245 * ID or it is not a string the default string is returned. 246 * 247 * @param id Identifier for the GMST setting, e.g. "aName" 248 * @param default Default value if the GMST setting cannot be used. 249 */ 250 virtual std::string getGameSettingString(const std::string &id, const std::string &default_) = 0; 251 252 virtual void processChangedSettings(const std::set< std::pair<std::string, std::string> >& changed) = 0; 253 254 virtual void executeInConsole (const std::string& path) = 0; 255 256 virtual void enableRest() = 0; 257 virtual bool getRestEnabled() = 0; 258 virtual bool getJournalAllowed() = 0; 259 260 virtual bool getPlayerSleeping() = 0; 261 virtual void wakeUpPlayer() = 0; 262 263 virtual void showSoulgemDialog (MWWorld::Ptr item) = 0; 264 265 virtual void changePointer (const std::string& name) = 0; 266 267 virtual void setEnemy (const MWWorld::Ptr& enemy) = 0; 268 269 virtual int getMessagesCount() const = 0; 270 271 virtual const Translation::Storage& getTranslationDataStorage() const = 0; 272 273 /// Warning: do not use MyGUI::InputManager::setKeyFocusWidget directly. Instead use this. 274 virtual void setKeyFocusWidget (MyGUI::Widget* widget) = 0; 275 276 virtual void loadUserFonts() = 0; 277 278 virtual Loading::Listener* getLoadingScreen() = 0; 279 280 /// Should the cursor be visible? 281 virtual bool getCursorVisible() = 0; 282 283 /// Clear all savegame-specific data 284 virtual void clear() = 0; 285 286 virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) = 0; 287 virtual void readRecord (ESM::ESMReader& reader, uint32_t type) = 0; 288 virtual int countSavedGameRecords() const = 0; 289 290 /// Does the current stack of GUI-windows permit saving? 291 virtual bool isSavingAllowed() const = 0; 292 293 /// Send exit command to active Modal window 294 virtual void exitCurrentModal() = 0; 295 296 /// Sets the current Modal 297 /** Used to send exit command to active Modal when Esc is pressed **/ 298 virtual void addCurrentModal(MWGui::WindowModal* input) = 0; 299 300 /// Removes the top Modal 301 /** Used when one Modal adds another Modal 302 \param input Pointer to the current modal, to ensure proper modal is removed **/ 303 virtual void removeCurrentModal(MWGui::WindowModal* input) = 0; 304 305 virtual void pinWindow (MWGui::GuiWindow window) = 0; 306 virtual void toggleMaximized(MWGui::Layout *layout) = 0; 307 308 /// Fade the screen in, over \a time seconds 309 virtual void fadeScreenIn(const float time, bool clearQueue=true, float delay=0.f) = 0; 310 /// Fade the screen out to black, over \a time seconds 311 virtual void fadeScreenOut(const float time, bool clearQueue=true, float delay=0.f) = 0; 312 /// Fade the screen to a specified percentage of black, over \a time seconds 313 virtual void fadeScreenTo(const int percent, const float time, bool clearQueue=true, float delay=0.f) = 0; 314 /// Darken the screen to a specified percentage 315 virtual void setBlindness(const int percent) = 0; 316 317 virtual void activateHitOverlay(bool interrupt=true) = 0; 318 virtual void setWerewolfOverlay(bool set) = 0; 319 320 virtual void toggleConsole() = 0; 321 virtual void toggleDebugWindow() = 0; 322 323 /// Cycle to next or previous spell 324 virtual void cycleSpell(bool next) = 0; 325 /// Cycle to next or previous weapon 326 virtual void cycleWeapon(bool next) = 0; 327 328 virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0; 329 330 // In WindowManager for now since there isn't a VFS singleton 331 virtual std::string correctIconPath(const std::string& path) = 0; 332 virtual std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) = 0; 333 virtual std::string correctTexturePath(const std::string& path) = 0; 334 virtual bool textureExists(const std::string& path) = 0; 335 336 virtual void addCell(MWWorld::CellStore* cell) = 0; 337 virtual void removeCell(MWWorld::CellStore* cell) = 0; 338 virtual void writeFog(MWWorld::CellStore* cell) = 0; 339 340 virtual const MWGui::TextColours& getTextColours() = 0; 341 342 virtual bool injectKeyPress(MyGUI::KeyCode key, unsigned int text, bool repeat) = 0; 343 virtual bool injectKeyRelease(MyGUI::KeyCode key) = 0; 344 345 void windowVisibilityChange(bool visible) override = 0; 346 void windowResized(int x, int y) override = 0; 347 void windowClosed() override = 0; 348 virtual bool isWindowVisible() = 0; 349 350 virtual void watchActor(const MWWorld::Ptr& ptr) = 0; 351 virtual MWWorld::Ptr getWatchedActor() const = 0; 352 }; 353 } 354 355 #endif 356