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 "windowpinnablebase.hpp"
7 
9 
11 
12 namespace MWRender
13 {
14  class GlobalMap;
15  class LocalMap;
16 }
17 
18 namespace ESM
19 {
20  class ESMReader;
21  class ESMWriter;
22 }
23 
24 namespace MWWorld
25 {
26  class CellStore;
27 }
28 
29 namespace Loading
30 {
31  class Listener;
32 }
33 
34 namespace SceneUtil
35 {
36  class WorkQueue;
37 }
38 
39 namespace MWGui
40 {
41 
43  {
44  public:
45  void addMarker(const ESM::CustomMarker& marker, bool triggerEvent=true);
46  void deleteMarker (const ESM::CustomMarker& marker);
47  void updateMarker(const ESM::CustomMarker& marker, const std::string& newNote);
48 
49  void clear();
50 
51  size_t size() const;
52 
53  typedef std::multimap<ESM::CellId, ESM::CustomMarker> ContainerType;
54 
55  typedef std::pair<ContainerType::const_iterator, ContainerType::const_iterator> RangeType;
56 
57  ContainerType::const_iterator begin() const;
58  ContainerType::const_iterator end() const;
59 
60  RangeType getMarkers(const ESM::CellId& cellId) const;
61 
62  typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
64 
65  private:
67  };
68 
70  {
71  public:
72  LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled = true);
73  virtual ~LocalMapBase();
74  void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize, int cellDistance);
75 
76  void setCellPrefix(const std::string& prefix);
77  void setActiveCell(const int x, const int y, bool interior=false);
78  void requestMapRender(const MWWorld::CellStore* cell);
79  void setPlayerDir(const float x, const float y);
80  void setPlayerPos(int cellX, int cellY, const float nx, const float ny);
81 
82  void onFrame(float dt);
83 
84  bool toggleFogOfWar();
85 
87  {
89  : mLocalMapRender(map)
90  , cellX(0)
91  , cellY(0)
92  , nX(0.f)
93  , nY(0.f)
94  {
95  }
96 
97  bool isPositionExplored() const;
98 
100  int cellX;
101  int cellY;
102  float nX;
103  float nY;
104  std::vector<std::string> notes;
105  std::string caption;
106  };
107 
108  protected:
110 
111  int mCurX, mCurY;
112  bool mInterior;
113  MyGUI::ScrollView* mLocalMap;
114  MyGUI::ImageBox* mCompass;
115  std::string mPrefix;
116  bool mChanged;
119 
121 
122  int mNumCells; // for convenience, mCellDistance * 2 + 1
124 
125  // Stores markers that were placed by a player. May be shared between multiple map views.
127 
128  std::vector<MyGUI::ImageBox*> mMapWidgets;
129  std::vector<MyGUI::ImageBox*> mFogWidgets;
130 
131  typedef std::vector<std::shared_ptr<MyGUI::ITexture> > TextureVector;
134 
135  // Keep track of created marker widgets, just to easily remove them later.
136  std::vector<MyGUI::Widget*> mDoorMarkerWidgets;
137  std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
138  std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
139 
140  virtual void updateCustomMarkers();
141 
142  void applyFogOfWar();
143 
144  MyGUI::IntPoint getMarkerPosition (float worldX, float worldY, MarkerUserData& markerPos);
145 
146  virtual void notifyPlayerUpdate() {}
147  virtual void notifyMapChanged() {}
148 
149  virtual void customMarkerCreated(MyGUI::Widget* marker) {}
150  virtual void doorMarkerCreated(MyGUI::Widget* marker) {}
151 
152  void updateMagicMarkers();
153  void addDetectionMarkers(int type);
154 
155  void redraw();
156 
158 
161 
162  private:
163  void updateDoorMarkers();
165  };
166 
168  {
169  public:
170  EditNoteDialog();
171 
172  virtual void onOpen();
173 
174  void showDeleteButton(bool show);
175  bool getDeleteButtonShown();
176  void setText(const std::string& text);
177  std::string getText();
178 
179  typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
180 
183 
184  private:
185  void onCancelButtonClicked(MyGUI::Widget* sender);
186  void onOkButtonClicked(MyGUI::Widget* sender);
187  void onDeleteButtonClicked(MyGUI::Widget* sender);
188 
189  MyGUI::TextBox* mTextEdit;
190  MyGUI::Button* mOkButton;
191  MyGUI::Button* mCancelButton;
192  MyGUI::Button* mDeleteButton;
193  };
194 
196  {
197  public:
198  MapWindow(CustomMarkerCollection& customMarkers, DragAndDrop* drag, MWRender::LocalMap* localMapRender, SceneUtil::WorkQueue* workQueue);
199  virtual ~MapWindow();
200 
201  void setCellName(const std::string& cellName);
202 
203  virtual void setAlpha(float alpha);
204  void setVisible(bool visible);
205 
206  void renderGlobalMap();
207 
210  void addVisitedLocation(const std::string& name, int x, int y);
211 
212  // reveals this cell's map on the global map
213  void cellExplored(int x, int y);
214 
215  void setGlobalMapPlayerPosition (float worldX, float worldY);
216  void setGlobalMapPlayerDir(const float x, const float y);
217 
218  void ensureGlobalMapLoaded();
219 
220  virtual void onOpen();
221 
222  void onFrame(float dt);
223 
224  virtual void updateCustomMarkers();
225 
227  void clear();
228 
229  void write (ESM::ESMWriter& writer, Loading::Listener& progress);
230  void readRecord (ESM::ESMReader& reader, uint32_t type);
231 
232  private:
233  void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
234  void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
235  void onWorldButtonClicked(MyGUI::Widget* _sender);
236  void onMapDoubleClicked(MyGUI::Widget* sender);
237  void onCustomMarkerDoubleClicked(MyGUI::Widget* sender);
238  void onNoteEditOk();
239  void onNoteEditDelete();
241  void onNoteDoubleClicked(MyGUI::Widget* sender);
242  void onChangeScrollWindowCoord(MyGUI::Widget* sender);
243  void globalMapUpdatePlayer();
244  void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y);
245 
246  MyGUI::ScrollView* mGlobalMap;
247  std::unique_ptr<MyGUI::ITexture> mGlobalMapTexture;
248  std::unique_ptr<MyGUI::ITexture> mGlobalMapOverlayTexture;
249  MyGUI::ImageBox* mGlobalMapImage;
250  MyGUI::ImageBox* mGlobalMapOverlay;
251  MyGUI::ImageBox* mPlayerArrowLocal;
252  MyGUI::ImageBox* mPlayerArrowGlobal;
253  MyGUI::Button* mButton;
254  MyGUI::IntPoint mLastDragPos;
255  bool mGlobal;
256 
258 
259  // Markers on global map
260  typedef std::pair<int, int> CellId;
261  std::set<CellId> mMarkers;
262 
263  // Cells that should be explored in the next frame (i.e. their map revealed on the global map)
264  // We can't do this immediately, because the map update is not immediate either (see mNeedMapUpdate in scene.cpp)
265  std::vector<CellId> mQueuedToExplore;
266 
267  MyGUI::Button* mEventBoxGlobal;
268  MyGUI::Button* mEventBoxLocal;
269 
271 
272  std::map<std::pair<int, int>, MyGUI::Widget*> mGlobalMapMarkers;
273 
276 
277  virtual void onPinToggled();
278  virtual void onTitleDoubleClicked();
279 
280  virtual void doorMarkerCreated(MyGUI::Widget* marker);
281  virtual void customMarkerCreated(MyGUI::Widget *marker);
282 
283  virtual void notifyPlayerUpdate();
284 
285  };
286 }
287 #endif
virtual void doorMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.cpp:1071
bool mFogOfWarEnabled
Definition: mapwindow.hpp:118
std::vector< MyGUI::ImageBox * > mMapWidgets
Definition: mapwindow.hpp:128
void setGlobalMapPlayerPosition(float worldX, float worldY)
Definition: mapwindow.cpp:972
MapWindow(CustomMarkerCollection &customMarkers, DragAndDrop *drag, MWRender::LocalMap *localMapRender, SceneUtil::WorkQueue *workQueue)
Definition: mapwindow.cpp:625
void requestMapRender(const MWWorld::CellStore *cell)
Definition: mapwindow.cpp:404
std::map< std::pair< int, int >, MyGUI::Widget * > mGlobalMapMarkers
Definition: mapwindow.hpp:272
EventHandle_Void eventMarkersChanged
Definition: mapwindow.hpp:63
MyGUI::ImageBox * mGlobalMapImage
Definition: mapwindow.hpp:249
void globalMapUpdatePlayer()
Definition: mapwindow.cpp:955
void onDragStart(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
Definition: mapwindow.cpp:900
RangeType getMarkers(const ESM::CellId &cellId) const
Definition: mapwindow.cpp:147
bool mFogOfWarToggled
Definition: mapwindow.hpp:117
MyGUI::ImageBox * mCompass
Definition: mapwindow.hpp:114
void ensureGlobalMapLoaded()
Definition: mapwindow.cpp:996
virtual void onPinToggled()
Definition: mapwindow.cpp:935
Definition: mapwindow.hpp:69
void write(ESM::ESMWriter &writer, Loading::Listener &progress)
Definition: mapwindow.cpp:1025
Definition: mapwindow.hpp:42
MyGUI::ImageBox * mPlayerArrowGlobal
Definition: mapwindow.hpp:252
int cellX
Definition: mapwindow.hpp:100
A work queue that users can push work items onto, to be completed by one or more background threads...
Definition: workqueue.hpp:48
Definition: esmreader.hpp:21
void setPlayerDir(const float x, const float y)
Definition: mapwindow.cpp:448
void onFrame(float dt)
Called every frame if the window is in an active GUI mode.
Definition: mapwindow.cpp:845
int mMapWidgetSize
Definition: mapwindow.hpp:120
Definition: mapwindow.hpp:195
void updateDoorMarkers()
Definition: mapwindow.cpp:526
void onFrame(float dt)
Definition: mapwindow.cpp:509
virtual void notifyMapChanged()
Definition: mapwindow.hpp:147
MyGUI::IntCoord mLastScrollWindowCoordinates
Definition: mapwindow.hpp:257
std::multimap< ESM::CellId, ESM::CustomMarker > ContainerType
Definition: mapwindow.hpp:53
void clear()
Clear all savegame-specific data.
Definition: mapwindow.cpp:1013
bool toggleFogOfWar()
Definition: mapwindow.cpp:228
void updateMagicMarkers()
Definition: mapwindow.cpp:589
virtual void onTitleDoubleClicked()
Definition: mapwindow.cpp:942
void readRecord(ESM::ESMReader &reader, uint32_t type)
Definition: mapwindow.cpp:1037
void onCustomMarkerDoubleClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:719
virtual ~MapWindow()
Definition: mapwindow.cpp:795
std::string mPrefix
Definition: mapwindow.hpp:115
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:111
void renderGlobalMap()
Definition: mapwindow.cpp:788
MyGUI::TextBox * mTextEdit
Definition: mapwindow.hpp:189
std::pair< ContainerType::const_iterator, ContainerType::const_iterator > RangeType
Definition: mapwindow.hpp:55
Definition: loadinglistener.hpp:8
std::unique_ptr< MyGUI::ITexture > mGlobalMapOverlayTexture
Definition: mapwindow.hpp:248
int mNumCells
Definition: mapwindow.hpp:122
std::vector< CellId > mQueuedToExplore
Definition: mapwindow.hpp:265
Definition: draganddrop.hpp:17
void onNoteEditOk()
Definition: mapwindow.cpp:690
void cellExplored(int x, int y)
Definition: mapwindow.cpp:840
int mCellDistance
Definition: mapwindow.hpp:123
void setPlayerPos(int cellX, int cellY, const float nx, const float ny)
Definition: mapwindow.cpp:430
std::vector< std::string > notes
Definition: mapwindow.hpp:104
MyGUI::ImageBox * mPlayerArrowLocal
Definition: mapwindow.hpp:251
int cellY
Definition: mapwindow.hpp:101
EditNoteDialog mEditNoteDialog
Definition: mapwindow.hpp:274
virtual void setAlpha(float alpha)
Definition: mapwindow.cpp:1055
TextureVector mMapTextures
Definition: mapwindow.hpp:132
ContainerType mMarkers
Definition: mapwindow.hpp:66
MyGUI::ImageBox * mGlobalMapOverlay
Definition: mapwindow.hpp:250
Definition: esmwriter.hpp:17
float mLastDirectionY
Definition: mapwindow.hpp:160
std::set< CellId > mMarkers
Definition: mapwindow.hpp:261
ESM::CustomMarker mEditingMarker
Definition: mapwindow.hpp:275
TextureVector mFogTextures
Definition: mapwindow.hpp:133
std::string getText()
Definition: mapwindow.cpp:1107
MyGUI::Button * mEventBoxLocal
Definition: mapwindow.hpp:268
std::vector< MyGUI::Widget * > mDoorMarkerWidgets
Definition: mapwindow.hpp:136
EventHandle_Void eventOkClicked
Definition: mapwindow.hpp:182
void onNoteDoubleClicked(MyGUI::Widget *sender)
MyGUI::Button * mCancelButton
Definition: mapwindow.hpp:191
Definition: windowbase.hpp:72
void onCancelButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1119
void addVisitedLocation(const std::string &name, int x, int y)
Definition: mapwindow.cpp:805
Definition: windowpinnablebase.hpp:10
virtual void updateCustomMarkers()
Definition: mapwindow.cpp:313
MyGUI::ScrollView * mLocalMap
Definition: mapwindow.hpp:113
MyGUI::IntPoint mLastDragPos
Definition: mapwindow.hpp:254
bool mChanged
Definition: mapwindow.hpp:116
virtual void onOpen()
Notify that window has been made visible.
Definition: mapwindow.cpp:1112
bool getDeleteButtonShown()
Definition: mapwindow.cpp:1097
void onOkButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1124
void init(MyGUI::ScrollView *widget, MyGUI::ImageBox *compass, int mapWidgetSize, int cellDistance)
Definition: mapwindow.cpp:186
virtual void notifyPlayerUpdate()
Definition: mapwindow.cpp:965
bool mNeedDoorMarkersUpdate
Definition: mapwindow.hpp:164
Local map rendering.
Definition: localmap.hpp:36
CustomMarkerCollection & mCustomMarkers
Definition: mapwindow.hpp:126
float mLastDirectionX
Definition: mapwindow.hpp:159
void onMapDoubleClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:727
Definition: mapwindow.hpp:167
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:51
void setGlobalMapMarkerTooltip(MyGUI::Widget *widget, int x, int y)
Definition: mapwindow.cpp:861
int mCurY
Definition: mapwindow.hpp:111
std::vector< MyGUI::Widget * > mMagicMarkerWidgets
Definition: mapwindow.hpp:137
MarkerUserData(MWRender::LocalMap *map)
Definition: mapwindow.hpp:88
void setVisible(bool visible)
Sets the visibility of the window.
Definition: mapwindow.cpp:782
MWRender::LocalMap * mLocalMapRender
Definition: mapwindow.hpp:99
void setCellPrefix(const std::string &prefix)
Definition: mapwindow.cpp:222
float mMarkerUpdateTimer
Definition: mapwindow.hpp:157
std::unique_ptr< MyGUI::ITexture > mGlobalMapTexture
Definition: mapwindow.hpp:247
void setText(const std::string &text)
Definition: mapwindow.cpp:1102
MyGUI::delegates::CMultiDelegate0 EventHandle_Void
Definition: mapwindow.hpp:179
void setCellName(const std::string &cellName)
Definition: mapwindow.cpp:800
ContainerType::const_iterator begin() const
Definition: mapwindow.cpp:137
virtual void customMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.hpp:149
void onDeleteButtonClicked(MyGUI::Widget *sender)
Definition: mapwindow.cpp:1129
MyGUI::delegates::CMultiDelegate0 EventHandle_Void
Definition: mapwindow.hpp:62
MyGUI::Button * mOkButton
Definition: mapwindow.hpp:190
Definition: custommarkerstate.hpp:10
ContainerType::const_iterator end() const
Definition: mapwindow.cpp:142
EditNoteDialog()
Definition: mapwindow.cpp:1079
void addDetectionMarkers(int type)
Definition: mapwindow.cpp:465
void onMouseDrag(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
Definition: mapwindow.cpp:906
virtual void customMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.cpp:1064
void onWorldButtonClicked(MyGUI::Widget *_sender)
Definition: mapwindow.cpp:920
MyGUI::Button * mButton
Definition: mapwindow.hpp:253
size_t size() const
Definition: mapwindow.cpp:152
bool mInterior
Definition: mapwindow.hpp:112
bool isPositionExplored() const
Definition: mapwindow.cpp:1134
virtual ~LocalMapBase()
Definition: mapwindow.cpp:181
void setActiveCell(const int x, const int y, bool interior=false)
Definition: mapwindow.cpp:359
virtual void onOpen()
Notify that window has been made visible.
Definition: mapwindow.cpp:948
float nX
Definition: mapwindow.hpp:102
void showDeleteButton(bool show)
Definition: mapwindow.cpp:1092
std::pair< int, int > CellId
Definition: mapwindow.hpp:260
MyGUI::Button * mDeleteButton
Definition: mapwindow.hpp:192
void redraw()
Definition: mapwindow.cpp:424
std::vector< std::shared_ptr< MyGUI::ITexture > > TextureVector
Definition: mapwindow.hpp:131
LocalMapBase(CustomMarkerCollection &markers, MWRender::LocalMap *localMapRender, bool fogOfWarEnabled=true)
Definition: mapwindow.cpp:159
std::string caption
Definition: mapwindow.hpp:105
MWRender::LocalMap * mLocalMapRender
Definition: mapwindow.hpp:109
float nY
Definition: mapwindow.hpp:103
virtual void doorMarkerCreated(MyGUI::Widget *marker)
Definition: mapwindow.hpp:150
Definition: cellid.hpp:11
void applyFogOfWar()
Definition: mapwindow.cpp:235
void onChangeScrollWindowCoord(MyGUI::Widget *sender)
Definition: mapwindow.cpp:768
Definition: mapwindow.hpp:86
MyGUI::Button * mEventBoxGlobal
Definition: mapwindow.hpp:267
virtual void notifyPlayerUpdate()
Definition: mapwindow.hpp:146
virtual void updateCustomMarkers()
Definition: mapwindow.cpp:887
std::vector< MyGUI::Widget * > mCustomMarkerWidgets
Definition: mapwindow.hpp:138
void setGlobalMapPlayerDir(const float x, const float y)
Definition: mapwindow.cpp:987
EventHandle_Void eventDeleteClicked
Definition: mapwindow.hpp:181
MyGUI::ScrollView * mGlobalMap
Definition: mapwindow.hpp:246
std::vector< MyGUI::ImageBox * > mFogWidgets
Definition: mapwindow.hpp:129
bool mGlobal
Definition: mapwindow.hpp:255
void onNoteEditDeleteConfirm()
Definition: mapwindow.cpp:712
void onNoteEditDelete()
Definition: mapwindow.cpp:703
Definition: windowbase.hpp:61
MWRender::GlobalMap * mGlobalMapRender
Definition: mapwindow.hpp:270
const char * name
Definition: crashcatcher.cpp:67
Definition: globalmap.hpp:32