OpenMW
apps/openmw/mwgui/mapwindow.hpp
Go to the documentation of this file.
00001 #ifndef MWGUI_MAPWINDOW_H
00002 #define MWGUI_MAPWINDOW_H
00003 
00004 #include "windowpinnablebase.hpp"
00005 
00006 namespace MWRender
00007 {
00008     class GlobalMap;
00009 }
00010 
00011 namespace Loading
00012 {
00013     class Listener;
00014 }
00015 
00016 namespace MWGui
00017 {
00018     class LocalMapBase
00019     {
00020     public:
00021         LocalMapBase();
00022         virtual ~LocalMapBase();
00023         void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, OEngine::GUI::Layout* layout, bool mapDragAndDrop=false);
00024 
00025         void setCellPrefix(const std::string& prefix);
00026         void setActiveCell(const int x, const int y, bool interior=false);
00027         void setPlayerDir(const float x, const float y);
00028         void setPlayerPos(const float x, const float y);
00029 
00030         void toggleFogOfWar();
00031 
00032         struct MarkerPosition
00033         {
00034             bool interior;
00035             int cellX;
00036             int cellY;
00037             float nX;
00038             float nY;
00039         };
00040 
00041     protected:
00042         int mCurX, mCurY;
00043         bool mInterior;
00044         MyGUI::ScrollView* mLocalMap;
00045         MyGUI::ImageBox* mCompass;
00046         std::string mPrefix;
00047         bool mChanged;
00048         bool mFogOfWar;
00049 
00050         std::vector<MyGUI::ImageBox*> mMapWidgets;
00051         std::vector<MyGUI::ImageBox*> mFogWidgets;
00052 
00053         void applyFogOfWar();
00054 
00055         void onMarkerFocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
00056         void onMarkerUnfocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
00057 
00058         MyGUI::IntPoint getMarkerPosition (float worldX, float worldY, MarkerPosition& markerPos);
00059 
00060         virtual void notifyPlayerUpdate() {}
00061         virtual void notifyMapChanged() {}
00062 
00063         // Update markers (Detect X effects, Mark/Recall effects)
00064         // Note, door markers handled in setActiveCell
00065         void updateMarkers();
00066         void addDetectionMarkers(int type);
00067 
00068         OEngine::GUI::Layout* mLayout;
00069 
00070         bool mMapDragAndDrop;
00071 
00072         float mLastPositionX;
00073         float mLastPositionY;
00074         float mLastDirectionX;
00075         float mLastDirectionY;
00076     };
00077 
00078     class MapWindow : public MWGui::WindowPinnableBase, public LocalMapBase
00079     {
00080     public:
00081         MapWindow(const std::string& cacheDir);
00082         virtual ~MapWindow();
00083 
00084         void setCellName(const std::string& cellName);
00085 
00086         void renderGlobalMap(Loading::Listener* loadingListener);
00087 
00088         void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map
00089         void cellExplored(int x, int y);
00090 
00091         void setGlobalMapPlayerPosition (float worldX, float worldY);
00092 
00093         virtual void open();
00094 
00095     private:
00096         void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
00097         void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
00098         void onWorldButtonClicked(MyGUI::Widget* _sender);
00099 
00100         void globalMapUpdatePlayer();
00101 
00102         MyGUI::ScrollView* mGlobalMap;
00103         MyGUI::ImageBox* mGlobalMapImage;
00104         MyGUI::ImageBox* mGlobalMapOverlay;
00105         MyGUI::ImageBox* mPlayerArrowLocal;
00106         MyGUI::ImageBox* mPlayerArrowGlobal;
00107         MyGUI::Button* mButton;
00108         MyGUI::IntPoint mLastDragPos;
00109         bool mGlobal;
00110 
00111         MyGUI::Button* mEventBoxGlobal;
00112         MyGUI::Button* mEventBoxLocal;
00113 
00114         MWRender::GlobalMap* mGlobalMapRender;
00115 
00116     protected:
00117         virtual void onPinToggled();
00118 
00119         virtual void notifyPlayerUpdate();
00120         virtual void notifyMapChanged();
00121 
00122     };
00123 }
00124 #endif