mapDisplay.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Copyright (C) 2015 Marien Raat
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <SFML/Graphics.hpp>
  15. #include <lightingGenerator.h>
  16. #include <string>
  17. #define ONE_LAND_COLOR false
  18. #define COLOR_WATER sf::Color(0, 0, 200)
  19. #define COLOR_BEACH sf::Color(255, 255, 0)
  20. #define COLOR_GRASS sf::Color(0, 255, 0)
  21. #define COLOR_FOREST sf::Color(0, 150, 0)
  22. #define COLOR_MOUNTAIN sf::Color(150, 150, 150)
  23. #define COLOR_ICE sf::Color(255, 255, 255)
  24. enum MapDisplayType {
  25. MAP_DISPLAY_TYPE_HEIGHTMAP,
  26. MAP_DISPLAY_TYPE_SIMPLE_MAP,
  27. MAP_DISPLAY_TYPE_LAND_MAP,
  28. MAP_DISPLAY_TYPE_LIGHTED_MAP
  29. };
  30. enum SmoothingType {
  31. SMOOTHING_TYPE_INTERPOLATE,
  32. SMOOTHING_TYPE_AVERAGE
  33. };
  34. class MapDisplayer {
  35. public:
  36. MapDisplayer(sf::Vector2u size
  37. , MapDisplayType mapDisplayType);
  38. void setMapDisplayType(MapDisplayType mapDisplayType);
  39. MapDisplayType getMapDisplayType();
  40. void updateDisplay();
  41. void setHeightmap(double *heightmap);
  42. void setHeightmapPassSize(int passSize);
  43. void setSmoothingType(SmoothingType smoothingType);
  44. double *normalizedHeightmap;
  45. void setNamesFont(sf::Font *namesFont);
  46. void setIslandName(std::string islandName);
  47. void setLandMap(bool *landMap);
  48. void setLightMap(Vec3f *lightmap);
  49. void updateHeightmapDisplay();
  50. void updateSimpleMapDisplay();
  51. void updateLandMapDisplay();
  52. void updateLightMapDisplay();
  53. void draw(sf::RenderWindow *window);
  54. private:
  55. MapDisplayType mapDisplayType;
  56. SmoothingType smoothingType;
  57. double *heightmap;
  58. bool *landMap;
  59. Vec3f *lightmap;
  60. int passSize;
  61. sf::Vector2u size;
  62. sf::Image heightmapImage, simpleMapImage, landMapImage,
  63. lightMapImage;
  64. sf::Texture displayTexture;
  65. sf::Sprite displaySprite;
  66. sf::Text islandNameText;
  67. sf::Color getSimpleMapColor(double value);
  68. };