OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mapwindow.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_MAPWINDOW_H
2 #define MWGUI_MAPWINDOW_H
3 
4 #include <stdint.h>
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include "windowpinnablebase.hpp"
9 
11 
13 
14 namespace MWRender
15 {
16  class GlobalMap;
17  class LocalMap;
18 }
19 
20 namespace ESM
21 {
22  class ESMReader;
23  class ESMWriter;
24 }
25 
26 namespace MWWorld
27 {
28  class CellStore;
29 }
30 
31 namespace Loading
32 {
33  class Listener;
34 }
35 
36 namespace MWGui
37 {
38 
40  {
41  public:
42  void addMarker(const ESM::CustomMarker& marker, bool triggerEvent=true);
43  void deleteMarker (const ESM::CustomMarker& marker);
44  void updateMarker(const ESM::CustomMarker& marker, const std::string& newNote);
45 
46  void clear();
47 
48  size_t size() const;
49 
50  typedef std::multimap<ESM::CellId, ESM::CustomMarker> ContainerType;
51 
52  typedef std::pair<ContainerType::const_iterator, ContainerType::const_iterator> RangeType;
53 
54  ContainerType::const_iterator begin() const;
55  ContainerType::const_iterator end() const;
56 
57  RangeType getMarkers(const ESM::CellId& cellId) const;
58 
59  typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
61 
62  private:
64  };
65 
67  {
68  public:
69  LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled = true);
70  virtual ~LocalMapBase();
71  void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize, int cellDistance);
72 
73  void setCellPrefix(const std::string& prefix);
74  void setActiveCell(const int x, const int y, bool interior=false);
75  void requestMapRender(const MWWorld::CellStore* cell);
76  void setPlayerDir(const float x, const float y);
77  void setPlayerPos(int cellX, int cellY, const float nx, const float ny);
78 
79  void onFrame(float dt);
80 
81  bool toggleFogOfWar();
82 
84  {
86  : mLocalMapRender(map)
87  , cellX(0)
88  , cellY(0)
89  , nX(0.f)
90  , nY(0.f)
91  {
92  }
93 
94  bool isPositionExplored() const;
95 
97  int cellX;
98  int cellY;
99  float nX;
100  float nY;
101  std::vector<std::string> notes;
102  std::string caption;
103  };
104 
105  protected:
107 
108  int mCurX, mCurY;
109  bool mInterior;
110  MyGUI::ScrollView* mLocalMap;
111  MyGUI::ImageBox* mCompass;
112  std::string mPrefix;
113  bool mChanged;
116 
118 
119  int mNumCells; // for convenience, mCellDistance * 2 + 1
121 
122  // Stores markers that were placed by a player. May be shared between multiple map views.
124 
125  std::vector<MyGUI::ImageBox*> mMapWidgets;
126  std::vector<MyGUI::ImageBox*> mFogWidgets;
127 
128  typedef std::vector<boost::shared_ptr<MyGUI::ITexture> > TextureVector;
131 
132  // Keep track of created marker widgets, just to easily remove them later.
133  std::vector<MyGUI::Widget*> mDoorMarkerWidgets;
134  std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
135  std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
136 
137  virtual void updateCustomMarkers();
138 
139  void applyFogOfWar();
140 
141  MyGUI::IntPoint getMarkerPosition (float worldX, float worldY, MarkerUserData& markerPos);
142 
143  virtual void notifyPlayerUpdate() {}
144  virtual void notifyMapChanged() {}
145 
146  virtual void customMarkerCreated(MyGUI::Widget* marker) {}
147  virtual void doorMarkerCreated(MyGUI::Widget* marker) {}
148 
149  void updateMagicMarkers();
150  void addDetectionMarkers(int type);
151 
152  void redraw();
153 
155 
158 
159  private:
160  void updateDoorMarkers();
162  };
163 
165  {
166  public:
167  EditNoteDialog();
168 
169  virtual void open();
170  virtual void exit();
171 
172  void showDeleteButton(bool show);
173  bool getDeleteButtonShown();
174  void setText(const std::string& text);
175  std::string getText();
176 
177  typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
178 
181 
182  private:
183  void onCancelButtonClicked(MyGUI::Widget* sender);
184  void onOkButtonClicked(MyGUI::Widget* sender);
185  void onDeleteButtonClicked(MyGUI::Widget* sender);
186 
187  MyGUI::TextBox* mTextEdit;
188  MyGUI::Button* mOkButton;
189  MyGUI::Button* mCancelButton;
190  MyGUI::Button* mDeleteButton;
191  };
192 
194  {
195  public:
196  MapWindow(CustomMarkerCollection& customMarkers, DragAndDrop* drag, MWRender::LocalMap* localMapRender);
197  virtual ~MapWindow();
198 
199  void setCellName(const std::string& cellName);
200 
201  virtual void setAlpha(float alpha);
202 
203  void renderGlobalMap(Loading::Listener* loadingListener);
204 
207  void addVisitedLocation(const std::string& name, int x, int y);
208 
209  // reveals this cell's map on the global map
210  void cellExplored(int x, int y);
211 
212  void setGlobalMapPlayerPosition (float worldX, float worldY);
213  void setGlobalMapPlayerDir(const float x, const float y);
214 
215  virtual void open();
216 
217  void onFrame(float dt);
218 
219  virtual void updateCustomMarkers();
220 
222  void clear();
223 
224  void write (ESM::ESMWriter& writer, Loading::Listener& progress);
225  void readRecord (ESM::ESMReader& reader, uint32_t type);
226 
227  private:
228  void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
229  void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
230  void onWorldButtonClicked(MyGUI::Widget* _sender);
231  void onMapDoubleClicked(MyGUI::Widget* sender);
232  void onCustomMarkerDoubleClicked(MyGUI::Widget* sender);
233  void onNoteEditOk();
234  void onNoteEditDelete();
236  void onNoteDoubleClicked(MyGUI::Widget* sender);
237  void onChangeScrollWindowCoord(MyGUI::Widget* sender);
238  void globalMapUpdatePlayer();
239  void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y);
240 
241  MyGUI::ScrollView* mGlobalMap;
242  std::auto_ptr<MyGUI::ITexture> mGlobalMapTexture;
243  std::auto_ptr<MyGUI::ITexture> mGlobalMapOverlayTexture;
244  MyGUI::ImageBox* mGlobalMapImage;
245  MyGUI::ImageBox* mGlobalMapOverlay;
246  MyGUI::ImageBox* mPlayerArrowLocal;
247  MyGUI::ImageBox* mPlayerArrowGlobal;
248  MyGUI::Button* mButton;
249  MyGUI::IntPoint mLastDragPos;
250  bool mGlobal;
251 
253 
254  // Markers on global map
255  typedef std::pair<int, int> CellId;
256  std::set<CellId> mMarkers;
257 
258  // Cells that should be explored in the next frame (i.e. their map revealed on the global map)
259  // We can't do this immediately, because the map update is not immediate either (see mNeedMapUpdate in scene.cpp)
260  std::vector<CellId> mQueuedToExplore;
261 
262  MyGUI::Button* mEventBoxGlobal;
263  MyGUI::Button* mEventBoxLocal;
264 
266 
267  std::map<std::pair<int, int>, MyGUI::Widget*> mGlobalMapMarkers;
268 
271 
272  virtual void onPinToggled();
273  virtual void onTitleDoubleClicked();
274 
275  virtual void doorMarkerCreated(MyGUI::Widget* marker);
276  virtual void customMarkerCreated(MyGUI::Widget *marker);
277 
278  virtual void notifyPlayerUpdate();
279 
280  };
281 }
282 #endif
virtual void doorMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.cpp:1045
bool mFogOfWarEnabled
Definition: mapwindow.hpp:115
std::vector< MyGUI::ImageBox * > mMapWidgets
Definition: mapwindow.hpp:125
std::auto_ptr< MyGUI::ITexture > mGlobalMapOverlayTexture
Definition: mapwindow.hpp:243
MapWindow(CustomMarkerCollection &customMarkers, DragAndDrop *drag, MWRender::LocalMap *localMapRender)
Definition: mapwindow.cpp:625
void setGlobalMapPlayerPosition(float worldX, float worldY)
Definition: mapwindow.cpp:963
void requestMapRender(const MWWorld::CellStore *cell)
Definition: mapwindow.cpp:404
std::map< std::pair< int, int >, MyGUI::Widget * > mGlobalMapMarkers
Definition: mapwindow.hpp:267
EventHandle_Void eventMarkersChanged
Definition: mapwindow.hpp:60
MyGUI::ImageBox * mGlobalMapImage
Definition: mapwindow.hpp:244
void globalMapUpdatePlayer()
Definition: mapwindow.cpp:946
void onDragStart(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
Definition: mapwindow.cpp:897
RangeType getMarkers(const ESM::CellId &cellId) const
Definition: mapwindow.cpp:147
bool mFogOfWarToggled
Definition: mapwindow.hpp:114
MyGUI::ImageBox * mCompass
Definition: mapwindow.hpp:111
virtual void onPinToggled()
Definition: mapwindow.cpp:930
Definition: mapwindow.hpp:66
void write(ESM::ESMWriter &writer, Loading::Listener &progress)
Definition: mapwindow.cpp:999
Definition: mapwindow.hpp:39
MyGUI::ImageBox * mPlayerArrowGlobal
Definition: mapwindow.hpp:247
int cellX
Definition: mapwindow.hpp:97
Definition: esmreader.hpp:21
void setPlayerDir(const float x, const float y)
Definition: mapwindow.cpp:448
void onFrame(float dt)
Definition: mapwindow.cpp:842
int mMapWidgetSize
Definition: mapwindow.hpp:117
Definition: mapwindow.hpp:193
void updateDoorMarkers()
Definition: mapwindow.cpp:526
void onFrame(float dt)
Definition: mapwindow.cpp:509
virtual void notifyMapChanged()
Definition: mapwindow.hpp:144
MyGUI::IntCoord mLastScrollWindowCoordinates
Definition: mapwindow.hpp:252
std::multimap< ESM::CellId, ESM::CustomMarker > ContainerType
Definition: mapwindow.hpp:50
void clear()
Clear all savegame-specific data.
Definition: mapwindow.cpp:987
bool toggleFogOfWar()
Definition: mapwindow.cpp:228
void updateMagicMarkers()
Definition: mapwindow.cpp:589
virtual void onTitleDoubleClicked()
Definition: mapwindow.cpp:935
void readRecord(ESM::ESMReader &reader, uint32_t type)
Definition: mapwindow.cpp:1011
void onCustomMarkerDoubleClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:714
virtual ~MapWindow()
Definition: mapwindow.cpp:792
std::string mPrefix
Definition: mapwindow.hpp:112
void clear()
Definition: mapwindow.cpp:131
void updateMarker(const ESM::CustomMarker &marker, const std::string &newNote)
Definition: mapwindow.cpp:115
int mCurX
Definition: mapwindow.hpp:108
virtual void open()
Notify that window has been made visible.
Definition: mapwindow.cpp:1086
MyGUI::TextBox * mTextEdit
Definition: mapwindow.hpp:187
std::pair< ContainerType::const_iterator, ContainerType::const_iterator > RangeType
Definition: mapwindow.hpp:52
Definition: loadinglistener.hpp:8
int mNumCells
Definition: mapwindow.hpp:119
std::vector< CellId > mQueuedToExplore
Definition: mapwindow.hpp:260
Definition: draganddrop.hpp:17
void onNoteEditOk()
Definition: mapwindow.cpp:685
void cellExplored(int x, int y)
Definition: mapwindow.cpp:837
int mCellDistance
Definition: mapwindow.hpp:120
void setPlayerPos(int cellX, int cellY, const float nx, const float ny)
Definition: mapwindow.cpp:430
std::vector< std::string > notes
Definition: mapwindow.hpp:101
MyGUI::ImageBox * mPlayerArrowLocal
Definition: mapwindow.hpp:246
int cellY
Definition: mapwindow.hpp:98
EditNoteDialog mEditNoteDialog
Definition: mapwindow.hpp:269
virtual void setAlpha(float alpha)
Definition: mapwindow.cpp:1029
TextureVector mMapTextures
Definition: mapwindow.hpp:129
void renderGlobalMap(Loading::Listener *loadingListener)
Definition: mapwindow.cpp:777
ContainerType mMarkers
Definition: mapwindow.hpp:63
MyGUI::ImageBox * mGlobalMapOverlay
Definition: mapwindow.hpp:245
Definition: esmwriter.hpp:17
float mLastDirectionY
Definition: mapwindow.hpp:157
std::set< CellId > mMarkers
Definition: mapwindow.hpp:256
ESM::CustomMarker mEditingMarker
Definition: mapwindow.hpp:270
TextureVector mFogTextures
Definition: mapwindow.hpp:130
std::string getText()
Definition: mapwindow.cpp:1081
MyGUI::Button * mEventBoxLocal
Definition: mapwindow.hpp:263
std::vector< MyGUI::Widget * > mDoorMarkerWidgets
Definition: mapwindow.hpp:133
EventHandle_Void eventOkClicked
Definition: mapwindow.hpp:180
void onNoteDoubleClicked(MyGUI::Widget *sender)
MyGUI::Button * mCancelButton
Definition: mapwindow.hpp:189
Definition: windowbase.hpp:52
void onCancelButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1098
void addVisitedLocation(const std::string &name, int x, int y)
Definition: mapwindow.cpp:802
Definition: windowpinnablebase.hpp:10
virtual void updateCustomMarkers()
Definition: mapwindow.cpp:313
MyGUI::ScrollView * mLocalMap
Definition: mapwindow.hpp:110
MyGUI::IntPoint mLastDragPos
Definition: mapwindow.hpp:249
bool mChanged
Definition: mapwindow.hpp:113
bool getDeleteButtonShown()
Definition: mapwindow.cpp:1071
void onOkButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1103
void init(MyGUI::ScrollView *widget, MyGUI::ImageBox *compass, int mapWidgetSize, int cellDistance)
Definition: mapwindow.cpp:186
virtual void notifyPlayerUpdate()
Definition: mapwindow.cpp:956
bool mNeedDoorMarkersUpdate
Definition: mapwindow.hpp:161
Local map rendering.
Definition: localmap.hpp:36
CustomMarkerCollection & mCustomMarkers
Definition: mapwindow.hpp:123
float mLastDirectionX
Definition: mapwindow.hpp:156
void onMapDoubleClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:722
virtual void exit()
Gracefully exits the window.
Definition: mapwindow.cpp:1093
Definition: mapwindow.hpp:164
void deleteMarker(const ESM::CustomMarker &marker)
Definition: mapwindow.cpp:99
MyGUI::IntPoint getMarkerPosition(float worldX, float worldY, MarkerUserData &markerPos)
Definition: mapwindow.cpp:271
void addMarker(const ESM::CustomMarker &marker, bool triggerEvent=true)
Definition: mapwindow.cpp:92
Mutable state of a cell.
Definition: cellstore.hpp:53
void setGlobalMapMarkerTooltip(MyGUI::Widget *widget, int x, int y)
Definition: mapwindow.cpp:858
int mCurY
Definition: mapwindow.hpp:108
std::vector< MyGUI::Widget * > mMagicMarkerWidgets
Definition: mapwindow.hpp:134
MarkerUserData(MWRender::LocalMap *map)
Definition: mapwindow.hpp:85
MWRender::LocalMap * mLocalMapRender
Definition: mapwindow.hpp:96
void setCellPrefix(const std::string &prefix)
Definition: mapwindow.cpp:222
float mMarkerUpdateTimer
Definition: mapwindow.hpp:154
void setText(const std::string &text)
Definition: mapwindow.cpp:1076
MyGUI::delegates::CMultiDelegate0 EventHandle_Void
Definition: mapwindow.hpp:177
void setCellName(const std::string &cellName)
Definition: mapwindow.cpp:797
ContainerType::const_iterator begin() const
Definition: mapwindow.cpp:137
virtual void customMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.hpp:146
void onDeleteButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1108
MyGUI::delegates::CMultiDelegate0 EventHandle_Void
Definition: mapwindow.hpp:59
MyGUI::Button * mOkButton
Definition: mapwindow.hpp:188
Definition: custommarkerstate.hpp:10
ContainerType::const_iterator end() const
Definition: mapwindow.cpp:142
EditNoteDialog()
Definition: mapwindow.cpp:1053
void addDetectionMarkers(int type)
Definition: mapwindow.cpp:465
void onMouseDrag(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
Definition: mapwindow.cpp:903
virtual void customMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.cpp:1038
void onWorldButtonClicked(MyGUI::Widget *_sender)
Definition: mapwindow.cpp:917
MyGUI::Button * mButton
Definition: mapwindow.hpp:248
size_t size() const
Definition: mapwindow.cpp:152
bool mInterior
Definition: mapwindow.hpp:109
bool isPositionExplored() const
Definition: mapwindow.cpp:1113
virtual ~LocalMapBase()
Definition: mapwindow.cpp:181
void setActiveCell(const int x, const int y, bool interior=false)
Definition: mapwindow.cpp:359
float nX
Definition: mapwindow.hpp:99
void showDeleteButton(bool show)
Definition: mapwindow.cpp:1066
std::pair< int, int > CellId
Definition: mapwindow.hpp:255
MyGUI::Button * mDeleteButton
Definition: mapwindow.hpp:190
void redraw()
Definition: mapwindow.cpp:424
LocalMapBase(CustomMarkerCollection &markers, MWRender::LocalMap *localMapRender, bool fogOfWarEnabled=true)
Definition: mapwindow.cpp:159
std::string caption
Definition: mapwindow.hpp:102
MWRender::LocalMap * mLocalMapRender
Definition: mapwindow.hpp:106
float nY
Definition: mapwindow.hpp:100
virtual void doorMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.hpp:147
Definition: cellid.hpp:11
void applyFogOfWar()
Definition: mapwindow.cpp:235
void onChangeScrollWindowCoord(MyGUI::Widget *sender)
Definition: mapwindow.cpp:763
Definition: mapwindow.hpp:83
MyGUI::Button * mEventBoxGlobal
Definition: mapwindow.hpp:262
virtual void notifyPlayerUpdate()
Definition: mapwindow.hpp:143
virtual void updateCustomMarkers()
Definition: mapwindow.cpp:884
std::vector< MyGUI::Widget * > mCustomMarkerWidgets
Definition: mapwindow.hpp:135
void setGlobalMapPlayerDir(const float x, const float y)
Definition: mapwindow.cpp:978
EventHandle_Void eventDeleteClicked
Definition: mapwindow.hpp:179
std::vector< boost::shared_ptr< MyGUI::ITexture > > TextureVector
Definition: mapwindow.hpp:128
MyGUI::ScrollView * mGlobalMap
Definition: mapwindow.hpp:241
std::auto_ptr< MyGUI::ITexture > mGlobalMapTexture
Definition: mapwindow.hpp:242
std::vector< MyGUI::ImageBox * > mFogWidgets
Definition: mapwindow.hpp:126
bool mGlobal
Definition: mapwindow.hpp:250
void onNoteEditDeleteConfirm()
Definition: mapwindow.cpp:707
void onNoteEditDelete()
Definition: mapwindow.cpp:698
virtual void open()
Notify that window has been made visible.
Definition: mapwindow.cpp:941
Definition: windowbase.hpp:41
MWRender::GlobalMap * mGlobalMapRender
Definition: mapwindow.hpp:265
const char * name
Definition: crashcatcher.cpp:59
Definition: globalmap.hpp:30