1/*
2 * Copyright (c) 2010-2017 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
29class UIMinimap : public UIWidget {
30public:
31 UIMinimap();
32
33 void drawSelf(Fw::DrawPane drawPane);
34
35 bool zoomIn() { return setZoom(m_zoom + 1); }
36 bool zoomOut() { return setZoom(m_zoom - 1); }
37
38 bool setZoom(int zoom);
39 void setMinZoom(int minZoom) { m_minZoom = minZoom; }
40 void setMaxZoom(int maxZoom) { m_maxZoom = maxZoom; }
41 void setCameraPosition(const Position &pos);
42 bool floorUp();
43 bool floorDown();
44
45 Point getTilePoint(const Position &pos);
46 Rect getTileRect(const Position &pos);
47 Position getTilePosition(const Point &mousePos);
48
49 Position getCameraPosition() { return m_cameraPosition; }
50 int getMinZoom() { return m_minZoom; }
51 int getMaxZoom() { return m_maxZoom; }
52 int getZoom() { return m_zoom; }
53 float getScale() { return m_scale; }
54
55 void anchorPosition(const UIWidgetPtr &anchoredWidget,
56 Fw::AnchorEdge anchoredEdge,
57 const Position &hookedPosition,
58 Fw::AnchorEdge hookedEdge);
59 void fillPosition(const UIWidgetPtr &anchoredWidget,
60 const Position &hookedPosition);
61 void centerInPosition(const UIWidgetPtr &anchoredWidget,
62 const Position &hookedPosition);
63
64protected:
65 virtual void onZoomChange(int zoom, int oldZoom);
66 virtual void onCameraPositionChange(const Position &position,
67 const Position &oldPosition);
68 virtual void onStyleApply(const std::string &styleName,
69 const OTMLNodePtr &styleNode);
70
71private:
72 void update();
73
74 Rect m_mapArea;
75 Position m_cameraPosition;
76 float m_scale;
77 int m_zoom;
78 int m_minZoom;
79 int m_maxZoom;
80};
81
82#endif
83