2017-07-13 11:26:03 +03:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CTerrainRect.h, part of VCMI engine
|
2017-07-13 11:26:03 +03:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2011-12-13 21:23:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../gui/CIntObject.h"
|
|
|
|
#include "../../lib/int3.h"
|
2015-02-26 17:15:17 +03:00
|
|
|
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2009-09-07 02:29:44 +00:00
|
|
|
struct CGPath;
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2015-01-30 23:37:28 +01:00
|
|
|
enum class EMapAnimRedrawStatus;
|
|
|
|
class CFadeAnimation;
|
2010-07-13 05:25:40 +00:00
|
|
|
|
2011-02-22 11:52:36 +00:00
|
|
|
/// Holds information about which tiles of the terrain are shown/not shown at the screen
|
2018-04-07 14:34:11 +03:00
|
|
|
class CTerrainRect : public CIntObject
|
2008-12-27 01:01:59 +00:00
|
|
|
{
|
2015-01-30 23:37:28 +01:00
|
|
|
SDL_Surface * fadeSurface;
|
|
|
|
EMapAnimRedrawStatus lastRedrawStatus;
|
2018-04-07 14:34:11 +03:00
|
|
|
std::shared_ptr<CFadeAnimation> fadeAnim;
|
2017-05-25 19:57:20 +02:00
|
|
|
|
|
|
|
int3 swipeInitialMapPos;
|
2023-02-02 15:49:23 +02:00
|
|
|
Point swipeInitialRealPos;
|
2017-05-25 19:57:20 +02:00
|
|
|
bool isSwiping;
|
|
|
|
static constexpr float SwipeTouchSlop = 16.0f;
|
|
|
|
|
2023-02-02 15:49:23 +02:00
|
|
|
void handleHover(const Point & cursorPosition);
|
|
|
|
void handleSwipeMove(const Point & cursorPosition);
|
2017-06-07 22:42:41 +02:00
|
|
|
/// handles start/finish of swipe (press/release of corresponding button); returns true if state change was handled
|
|
|
|
bool handleSwipeStateChange(bool btnPressed);
|
2008-12-27 01:01:59 +00:00
|
|
|
public:
|
|
|
|
int tilesw, tilesh; //width and height of terrain to blit in tiles
|
|
|
|
int3 curHoveredTile;
|
|
|
|
int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
|
2018-04-07 14:34:11 +03:00
|
|
|
CGPath * currentPath;
|
2008-12-27 01:01:59 +00:00
|
|
|
|
|
|
|
CTerrainRect();
|
2015-01-30 23:37:28 +01:00
|
|
|
virtual ~CTerrainRect();
|
2015-10-12 16:47:10 +03:00
|
|
|
void deactivate() override;
|
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
2017-06-07 22:42:41 +02:00
|
|
|
void clickMiddle(tribool down, bool previousState) override;
|
2015-10-12 16:47:10 +03:00
|
|
|
void hover(bool on) override;
|
2023-02-02 15:49:23 +02:00
|
|
|
void mouseMoved (const Point & cursorPosition) override;
|
2015-10-12 16:47:10 +03:00
|
|
|
void show(SDL_Surface * to) override;
|
|
|
|
void showAll(SDL_Surface * to) override;
|
2015-01-30 23:37:28 +01:00
|
|
|
void showAnim(SDL_Surface * to);
|
2023-01-17 22:01:35 +02:00
|
|
|
void showPath(const Rect &extRect, SDL_Surface * to);
|
2016-01-09 15:32:42 +03:00
|
|
|
int3 whichTileIsIt(const int x, const int y); //x,y are cursor position
|
2008-12-27 01:01:59 +00:00
|
|
|
int3 whichTileIsIt(); //uses current cursor pos
|
2015-01-13 20:57:41 +01:00
|
|
|
/// @returns number of visible tiles on screen respecting current map scaling
|
|
|
|
int3 tileCountOnScreen();
|
2015-01-30 23:37:28 +01:00
|
|
|
/// animates view by caching current surface and crossfading it with normal screen
|
|
|
|
void fadeFromCurrentView();
|
|
|
|
bool needsAnimUpdate();
|
2008-12-27 01:01:59 +00:00
|
|
|
};
|
2011-02-22 11:52:36 +00:00
|
|
|
|