No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uimap.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef UIMAP_H
  23. #define UIMAP_H
  24. #include "declarations.h"
  25. #include <framework/ui/uiwidget.h>
  26. #include "tile.h"
  27. #include "mapview.h"
  28. class UIMap : public UIWidget
  29. {
  30. public:
  31. UIMap();
  32. ~UIMap();
  33. void drawSelf(Fw::DrawPane drawPane);
  34. void movePixels(int x, int y);
  35. bool setZoom(int zoom);
  36. bool zoomIn();
  37. bool zoomOut();
  38. void followCreature(const CreaturePtr& creature) { m_mapView->followCreature(creature); }
  39. void setCameraPosition(const Position& pos) { m_mapView->setCameraPosition(pos); }
  40. void setMaxZoomIn(int maxZoomIn) { m_maxZoomIn = maxZoomIn; }
  41. void setMaxZoomOut(int maxZoomOut) { m_maxZoomOut = maxZoomOut; }
  42. void setMultifloor(bool enable) { m_mapView->setMultifloor(enable); }
  43. void lockVisibleFloor(int floor) { m_mapView->lockFirstVisibleFloor(floor); }
  44. void unlockVisibleFloor() { m_mapView->unlockFirstVisibleFloor(); }
  45. void setVisibleDimension(const Size& visibleDimension);
  46. void setViewMode(MapView::ViewMode viewMode) { m_mapView->setViewMode(viewMode); }
  47. void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); }
  48. void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); }
  49. void setDrawTexts(bool enable) { m_mapView->setDrawTexts(enable); }
  50. void setDrawNames(bool enable) { m_mapView->setDrawNames(enable); }
  51. void setDrawHealthBars(bool enable) { m_mapView->setDrawHealthBars(enable); }
  52. void setDrawLights(bool enable) { m_mapView->setDrawLights(enable); }
  53. void setDrawManaBar(bool enable) { m_mapView->setDrawManaBar(enable); }
  54. void setAnimated(bool enable) { m_mapView->setAnimated(enable); }
  55. void setKeepAspectRatio(bool enable);
  56. void setMapShader(const PainterShaderProgramPtr& shader, float fadeout, float fadein) { m_mapView->setShader(shader, fadein, fadeout); }
  57. void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); }
  58. void setLimitVisibleRange(bool limitVisibleRange) { m_limitVisibleRange = limitVisibleRange; updateVisibleDimension(); }
  59. void setAddLightMethod(bool add) { m_mapView->setAddLightMethod(add); }
  60. bool isMultifloor() { return m_mapView->isMultifloor(); }
  61. bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
  62. bool isDrawingTexts() { return m_mapView->isDrawingTexts(); }
  63. bool isDrawingNames() { return m_mapView->isDrawingNames(); }
  64. bool isDrawingHealthBars() { return m_mapView->isDrawingHealthBars(); }
  65. bool isDrawingLights() { return m_mapView->isDrawingLights(); }
  66. bool isDrawingManaBar() { return m_mapView->isDrawingManaBar(); }
  67. bool isAnimating() { return m_mapView->isAnimating(); }
  68. bool isKeepAspectRatioEnabled() { return m_keepAspectRatio; }
  69. bool isLimitVisibleRangeEnabled() { return m_limitVisibleRange; }
  70. Size getVisibleDimension() { return m_mapView->getVisibleDimension(); }
  71. MapView::ViewMode getViewMode() { return m_mapView->getViewMode(); }
  72. CreaturePtr getFollowingCreature() { return m_mapView->getFollowingCreature(); }
  73. Otc::DrawFlags getDrawFlags() { return m_mapView->getDrawFlags(); }
  74. Position getCameraPosition() { return m_mapView->getCameraPosition(); }
  75. Position getPosition(const Point& mousePos);
  76. TilePtr getTile(const Point& mousePos);
  77. int getMaxZoomIn() { return m_maxZoomIn; }
  78. int getMaxZoomOut() { return m_maxZoomOut; }
  79. int getZoom() { return m_zoom; }
  80. PainterShaderProgramPtr getMapShader() { return m_mapView->getShader(); }
  81. float getMinimumAmbientLight() { return m_mapView->getMinimumAmbientLight(); }
  82. protected:
  83. virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
  84. virtual void onGeometryChange(const Rect& oldRect, const Rect& newRect);
  85. private:
  86. void updateVisibleDimension();
  87. void updateMapSize();
  88. int m_zoom;
  89. MapViewPtr m_mapView;
  90. Rect m_mapRect;
  91. float m_aspectRatio;
  92. bool m_keepAspectRatio;
  93. bool m_limitVisibleRange;
  94. int m_maxZoomIn;
  95. int m_maxZoomOut;
  96. };
  97. #endif