Otclient  14/8/2020
uiminimap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef UIMINIMAP_H
24 #define UIMINIMAP_H
25 
26 #include "declarations.h"
27 #include <framework/ui/uiwidget.h>
28 
29 class UIMinimap : public UIWidget
30 {
31 public:
32  UIMinimap();
33 
34  void drawSelf(Fw::DrawPane drawPane);
35 
36  bool zoomIn() { return setZoom(m_zoom+1); }
37  bool zoomOut() { return setZoom(m_zoom-1); }
38 
39  bool setZoom(int zoom);
40  void setMinZoom(int minZoom) { m_minZoom = minZoom; }
41  void setMaxZoom(int maxZoom) { m_maxZoom = maxZoom; }
42  void setCameraPosition(const Position& pos);
43  bool floorUp();
44  bool floorDown();
45 
46  Point getTilePoint(const Position& pos);
47  Rect getTileRect(const Position& pos);
48  Position getTilePosition(const Point& mousePos);
49 
50  Position getCameraPosition() { return m_cameraPosition; }
51  int getMinZoom() { return m_minZoom; }
52  int getMaxZoom() { return m_maxZoom; }
53  int getZoom() { return m_zoom; }
54  float getScale() { return m_scale; }
55 
56  void anchorPosition(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge, const Position& hookedPosition, Fw::AnchorEdge hookedEdge);
57  void fillPosition(const UIWidgetPtr& anchoredWidget, const Position& hookedPosition);
58  void centerInPosition(const UIWidgetPtr& anchoredWidget, const Position& hookedPosition);
59 
60 protected:
61  virtual void onZoomChange(int zoom, int oldZoom);
62  virtual void onCameraPositionChange(const Position& position, const Position& oldPosition);
63  virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
64 
65 private:
66  void update();
67 
68  Rect m_mapArea;
69  Position m_cameraPosition;
70  float m_scale;
71  int m_zoom;
72  int m_minZoom;
73  int m_maxZoom;
74 };
75 
76 #endif
UIMinimap::zoomIn
bool zoomIn()
Definition: uiminimap.h:36
UIWidget
Definition: uiwidget.h:47
UIMinimap::getTilePosition
Position getTilePosition(const Point &mousePos)
Definition: uiminimap.cpp:110
TRect< int >
UIMinimap::fillPosition
void fillPosition(const UIWidgetPtr &anchoredWidget, const Position &hookedPosition)
Definition: uiminimap.cpp:122
UIMinimap::getScale
float getScale()
Definition: uiminimap.h:54
UIMinimap::setZoom
bool setZoom(int zoom)
Definition: uiminimap.cpp:51
UIMinimap::getTileRect
Rect getTileRect(const Position &pos)
Definition: uiminimap.cpp:105
UIMinimap::getMaxZoom
int getMaxZoom()
Definition: uiminimap.h:52
Fw::AnchorEdge
AnchorEdge
Definition: const.h:211
UIMinimap::setMaxZoom
void setMaxZoom(int maxZoom)
Definition: uiminimap.h:41
UIMinimap::floorDown
bool floorDown()
Definition: uiminimap.cpp:91
UIMinimap::anchorPosition
void anchorPosition(const UIWidgetPtr &anchoredWidget, Fw::AnchorEdge anchoredEdge, const Position &hookedPosition, Fw::AnchorEdge hookedEdge)
Definition: uiminimap.cpp:115
uiwidget.h
UIMinimap::UIMinimap
UIMinimap()
Definition: uiminimap.cpp:32
UIMinimap::setMinZoom
void setMinZoom(int minZoom)
Definition: uiminimap.h:40
UIMinimap::getTilePoint
Point getTilePoint(const Position &pos)
Definition: uiminimap.cpp:100
declarations.h
UIMinimap::onStyleApply
virtual void onStyleApply(const std::string &styleName, const OTMLNodePtr &styleNode)
Definition: uiminimap.cpp:146
Position
Definition: position.h:33
UIMinimap::getMinZoom
int getMinZoom()
Definition: uiminimap.h:51
UIMinimap::getZoom
int getZoom()
Definition: uiminimap.h:53
UIMinimap::onZoomChange
virtual void onZoomChange(int zoom, int oldZoom)
Definition: uiminimap.cpp:136
UIMinimap::centerInPosition
void centerInPosition(const UIWidgetPtr &anchoredWidget, const Position &hookedPosition)
Definition: uiminimap.cpp:129
Fw::DrawPane
DrawPane
Definition: const.h:285
stdext::shared_object_ptr< UIWidget >
UIMinimap::getCameraPosition
Position getCameraPosition()
Definition: uiminimap.h:50
UIMinimap::setCameraPosition
void setCameraPosition(const Position &pos)
Definition: uiminimap.cpp:73
UIMinimap::zoomOut
bool zoomOut()
Definition: uiminimap.h:37
TPoint< int >
UIMinimap::drawSelf
void drawSelf(Fw::DrawPane drawPane)
Definition: uiminimap.cpp:41
UIMinimap::floorUp
bool floorUp()
Definition: uiminimap.cpp:82
UIMinimap
Definition: uiminimap.h:29
UIMinimap::onCameraPositionChange
virtual void onCameraPositionChange(const Position &position, const Position &oldPosition)
Definition: uiminimap.cpp:141