2023-07-07 00:08:29 +02:00
|
|
|
/*
|
|
|
|
* RadialMenu.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/CIntObject.h"
|
|
|
|
|
|
|
|
class IImage;
|
|
|
|
|
|
|
|
class CGarrisonInt;
|
|
|
|
class CGarrisonSlot;
|
2023-07-16 13:49:48 +02:00
|
|
|
class CFilledTexture;
|
|
|
|
class CGStatusBar;
|
|
|
|
|
2023-07-07 00:08:29 +02:00
|
|
|
|
|
|
|
class RadialMenuItem : public CIntObject
|
|
|
|
{
|
|
|
|
std::shared_ptr<IImage> image;
|
|
|
|
std::shared_ptr<CPicture> picture;
|
|
|
|
public:
|
|
|
|
std::function<void()> callback;
|
|
|
|
|
2023-07-16 13:49:48 +02:00
|
|
|
RadialMenuItem(const std::string& imageName, const std::function<void()>& callback);
|
2023-07-07 00:08:29 +02:00
|
|
|
|
|
|
|
bool isInside(const Point & position);
|
|
|
|
|
|
|
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
|
|
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RadialMenu : public CIntObject
|
|
|
|
{
|
2023-07-16 13:49:48 +02:00
|
|
|
static constexpr Point ITEM_NW = Point( -40, -70);
|
|
|
|
static constexpr Point ITEM_NE = Point( +40, -70);
|
|
|
|
static constexpr Point ITEM_WW = Point( -80, 0);
|
|
|
|
static constexpr Point ITEM_EE = Point( +80, 0);
|
|
|
|
static constexpr Point ITEM_SW = Point( -40, +70);
|
|
|
|
static constexpr Point ITEM_SE = Point( +40, +70);
|
2023-07-07 00:08:29 +02:00
|
|
|
|
|
|
|
std::vector<std::shared_ptr<RadialMenuItem>> items;
|
|
|
|
|
2023-07-16 13:49:48 +02:00
|
|
|
std::shared_ptr<CFilledTexture> statusBarBackground;
|
|
|
|
std::shared_ptr<CGStatusBar> statusBar;
|
|
|
|
|
|
|
|
void addItem(const Point & offset, const std::string & path, const std::function<void()>& callback );
|
2023-07-07 00:08:29 +02:00
|
|
|
public:
|
2023-07-16 13:49:48 +02:00
|
|
|
RadialMenu(const Point & positionToCenter, CGarrisonInt * army, CGarrisonSlot * slot);
|
2023-07-07 00:08:29 +02:00
|
|
|
|
|
|
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
|
|
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
|
|
|
void show(Canvas & to) override;
|
|
|
|
};
|