2011-08-29 05:04:23 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
2011-08-29 05:04:23 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UIMAP_H
|
|
|
|
#define UIMAP_H
|
|
|
|
|
|
|
|
#include "declarations.h"
|
|
|
|
#include <framework/ui/uiwidget.h>
|
2012-07-14 03:10:24 +02:00
|
|
|
#include "tile.h"
|
2011-08-29 05:04:23 +02:00
|
|
|
|
2012-07-14 03:10:24 +02:00
|
|
|
#include "mapview.h"
|
2012-04-07 01:12:46 +02:00
|
|
|
|
2011-08-29 05:04:23 +02:00
|
|
|
class UIMap : public UIWidget
|
|
|
|
{
|
|
|
|
public:
|
2012-01-20 03:33:11 +01:00
|
|
|
UIMap();
|
2012-01-30 01:00:12 +01:00
|
|
|
~UIMap();
|
|
|
|
|
2012-06-08 18:58:08 +02:00
|
|
|
void drawSelf(Fw::DrawPane drawPane);
|
2011-08-29 05:04:23 +02:00
|
|
|
|
2012-04-07 01:12:46 +02:00
|
|
|
bool setZoom(int zoom);
|
|
|
|
bool zoomIn();
|
|
|
|
bool zoomOut();
|
|
|
|
void followCreature(const CreaturePtr& creature) { m_mapView->followCreature(creature); }
|
|
|
|
|
|
|
|
void setCameraPosition(const Position& pos) { m_mapView->setCameraPosition(pos); }
|
|
|
|
void setMaxZoomIn(int maxZoomIn) { m_maxZoomIn = maxZoomIn; }
|
|
|
|
void setMaxZoomOut(int maxZoomOut) { m_maxZoomOut = maxZoomOut; }
|
|
|
|
void setMultifloor(bool enable) { m_mapView->setMultifloor(enable); }
|
|
|
|
void setVisibleDimension(const Size& visibleDimension);
|
|
|
|
void setViewMode(MapView::ViewMode viewMode) { m_mapView->setViewMode(viewMode); }
|
|
|
|
void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); }
|
|
|
|
void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); }
|
|
|
|
void setDrawTexts(bool enable) { m_mapView->setDrawTexts(enable); }
|
|
|
|
void setDrawMinimapColors(bool enable) { m_mapView->setDrawMinimapColors(enable); }
|
|
|
|
void setAnimated(bool enable) { m_mapView->setAnimated(enable); }
|
|
|
|
void setKeepAspectRatio(bool enable);
|
2012-06-14 20:26:55 +02:00
|
|
|
void setMapShader(const PainterShaderProgramPtr& shader) { m_mapView->setShader(shader); }
|
2012-01-30 01:00:12 +01:00
|
|
|
|
2012-04-07 01:12:46 +02:00
|
|
|
bool isMultifloor() { return m_mapView->isMultifloor(); }
|
|
|
|
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
|
|
|
|
bool isDrawingTexts() { return m_mapView->isDrawingTexts(); }
|
|
|
|
bool isDrawingMinimapColors() { return m_mapView->isDrawingMinimapColors(); }
|
|
|
|
bool isAnimating() { return m_mapView->isAnimating(); }
|
2012-06-22 07:26:22 +02:00
|
|
|
bool isKeepAspectRatioEnabled() { return m_aspectRatio != 0.0f; }
|
2012-04-07 01:12:46 +02:00
|
|
|
|
|
|
|
Size getVisibleDimension() { return m_mapView->getVisibleDimension(); }
|
|
|
|
MapView::ViewMode getViewMode() { return m_mapView->getViewMode(); }
|
|
|
|
CreaturePtr getFollowingCreature() { return m_mapView->getFollowingCreature(); }
|
|
|
|
Otc::DrawFlags getDrawFlags() { return m_mapView->getDrawFlags(); }
|
|
|
|
Position getCameraPosition() { return m_mapView->getCameraPosition(); }
|
2012-08-21 03:03:30 +02:00
|
|
|
Position getPosition(const Point& mousePos);
|
2012-01-09 19:06:16 +01:00
|
|
|
TilePtr getTile(const Point& mousePos);
|
2012-04-07 01:12:46 +02:00
|
|
|
int getMaxZoomIn() { return m_maxZoomIn; }
|
|
|
|
int getMaxZoomOut() { return m_maxZoomOut; }
|
|
|
|
int getZoom() { return m_zoom; }
|
2012-06-14 20:26:55 +02:00
|
|
|
PainterShaderProgramPtr getMapShader() { return m_mapView->getShader(); }
|
2012-01-09 19:06:16 +01:00
|
|
|
|
2011-08-29 05:04:23 +02:00
|
|
|
protected:
|
2012-04-07 01:12:46 +02:00
|
|
|
virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
2012-01-05 03:42:17 +01:00
|
|
|
virtual void onGeometryChange(const Rect& oldRect, const Rect& newRect);
|
2011-08-29 05:04:23 +02:00
|
|
|
|
|
|
|
private:
|
2012-04-07 01:12:46 +02:00
|
|
|
void updateVisibleDimension();
|
|
|
|
void updateMapSize();
|
|
|
|
|
|
|
|
int m_zoom;
|
2012-01-30 01:00:12 +01:00
|
|
|
MapViewPtr m_mapView;
|
2011-11-03 10:59:11 +01:00
|
|
|
Rect m_mapRect;
|
2012-04-07 01:12:46 +02:00
|
|
|
float m_aspectRatio;
|
|
|
|
int m_maxZoomIn;
|
|
|
|
int m_maxZoomOut;
|
2011-08-29 05:04:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|