/* * CAdventureMapWidget.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #pragma once #include "../gui/InterfaceObjectConfigurable.h" class CHeroList; class CTownList; class CMinimap; class MapView; class CInfoBar; class IImage; class AdventureMapShortcuts; enum class EGameState { NOT_INITIALIZED, HOTSEAT_WAIT, MAKING_TURN, ENEMY_TURN, CASTING_SPELL, WORLD_VIEW }; /// Internal class of AdventureMapInterface that contains actual UI elements class CAdventureMapWidget : public InterfaceObjectConfigurable { EGameState state; /// temporary stack of sizes of currently building widgets std::vector subwidgetSizes; /// list of images on which player-colored palette will be applied std::vector playerColorerImages; /// list of named images shared between widgets std::map> images; std::map> animations; /// Widgets that require access from adventure map std::shared_ptr heroList; std::shared_ptr townList; std::shared_ptr minimap; std::shared_ptr mapView; std::shared_ptr infoBar; std::shared_ptr shortcuts; Rect readTargetArea(const JsonNode & source); Rect readSourceArea(const JsonNode & source, const JsonNode & sourceCommon); Rect readArea(const JsonNode & source, const Rect & boundingBox); std::shared_ptr loadImage(const std::string & name); std::shared_ptr loadAnimation(const std::string & name); std::shared_ptr buildInfobox(const JsonNode & input); std::shared_ptr buildMapImage(const JsonNode & input); std::shared_ptr buildMapButton(const JsonNode & input); std::shared_ptr buildMapContainer(const JsonNode & input); std::shared_ptr buildMapGameArea(const JsonNode & input); std::shared_ptr buildMapHeroList(const JsonNode & input); std::shared_ptr buildMapIcon(const JsonNode & input); std::shared_ptr buildMapTownList(const JsonNode & input); std::shared_ptr buildMinimap(const JsonNode & input); std::shared_ptr buildResourceDateBar(const JsonNode & input); std::shared_ptr buildStatusBar(const JsonNode & input); void setPlayerChildren(CIntObject * widget, const PlayerColor & player); public: explicit CAdventureMapWidget( std::shared_ptr shortcuts ); std::shared_ptr getHeroList(); std::shared_ptr getTownList(); std::shared_ptr getMinimap(); std::shared_ptr getMapView(); std::shared_ptr getInfoBar(); void setPlayer(const PlayerColor & player); void setState(EGameState newState); EGameState getState(); void setOptionHasQuests(bool on); void setOptionHasUnderground(bool on); void setOptionUndergroundLevel(bool on); void setOptionHeroSleeping(bool on); void setOptionHeroSelected(bool on); void setOptionHeroCanMove(bool on); void setOptionHasNextHero(bool on); }; /// Small helper class that provides ownership for shared_ptr's of child elements class CAdventureMapContainerWidget : public CIntObject { friend class CAdventureMapWidget; std::vector> ownedChildren; }; class CAdventureMapOverlayWidget : public CAdventureMapContainerWidget { public: void show(SDL_Surface * to) override; }; /// Small helper class that provides player-colorable icon using animation file class CAdventureMapIcon : public CIntObject { std::shared_ptr image; size_t index; size_t iconsPerPlayer; public: CAdventureMapIcon(const Point & position, std::shared_ptr image, size_t index, size_t iconsPerPlayer); void setPlayer(const PlayerColor & player); };