|
|
@@ -53,74 +53,77 @@ enum class EAdvMapMode
|
|
|
/// can get to the towns and heroes.
|
|
|
class CAdvMapInt : public CIntObject
|
|
|
{
|
|
|
- //Return object that must be active at this tile (=clickable)
|
|
|
- const CGObjectInstance *getActiveObject(const int3 &tile);
|
|
|
-
|
|
|
- boost::optional<Point> keyToMoveDirection(const SDL_Keycode & key);
|
|
|
+ //TODO: remove
|
|
|
+ friend class CPlayerInterface;
|
|
|
+ friend class CTerrainRect;
|
|
|
|
|
|
-public:
|
|
|
- CAdvMapInt();
|
|
|
-
|
|
|
- int3 position; //top left corner of visible map part
|
|
|
- PlayerColor player;
|
|
|
+private:
|
|
|
+ enum EDirections {LEFT=1, RIGHT=2, UP=4, DOWN=8};
|
|
|
+ enum EGameStates {NA, INGAME, WAITING};
|
|
|
|
|
|
- bool duringAITurn;
|
|
|
+ struct WorldViewOptions
|
|
|
+ {
|
|
|
+ bool showAllTerrain; //for expert viewEarth
|
|
|
+ std::vector<ObjectPosInfo> iconPositions;
|
|
|
+ WorldViewOptions();
|
|
|
+ void clear();
|
|
|
+ void adjustDrawingInfo(MapDrawingInfo & info);
|
|
|
+ };
|
|
|
|
|
|
- enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
|
|
|
- ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
|
|
|
- bool scrollingState;
|
|
|
bool swipeEnabled;
|
|
|
bool swipeMovementRequested;
|
|
|
int3 swipeTargetPosition;
|
|
|
|
|
|
- enum{NA, INGAME, WAITING} state;
|
|
|
+ EGameStates state;
|
|
|
|
|
|
- bool updateScreen;
|
|
|
ui8 anim, animValHitCount; //animation frame
|
|
|
ui8 heroAnim, heroAnimValHitCount; //animation frame
|
|
|
|
|
|
+ /// top left corner of visible map part
|
|
|
+ int3 position;
|
|
|
+
|
|
|
EAdvMapMode mode;
|
|
|
float worldViewScale;
|
|
|
|
|
|
- struct WorldViewOptions
|
|
|
- {
|
|
|
- bool showAllTerrain; //for expert viewEarth
|
|
|
+ WorldViewOptions worldViewOptions;
|
|
|
|
|
|
- std::vector<ObjectPosInfo> iconPositions;
|
|
|
+ /// Currently selected object, can be town, hero or null
|
|
|
+ const CArmedInstance *selection;
|
|
|
|
|
|
- WorldViewOptions();
|
|
|
+ /// currently acting player
|
|
|
+ PlayerColor player;
|
|
|
|
|
|
- void clear();
|
|
|
+ bool duringAITurn;
|
|
|
|
|
|
- void adjustDrawingInfo(MapDrawingInfo & info);
|
|
|
- };
|
|
|
+ /// uses EDirections enum
|
|
|
+ ui8 scrollingDir;
|
|
|
+ bool scrollingState;
|
|
|
|
|
|
- WorldViewOptions worldViewOptions;
|
|
|
+ const CSpell *spellBeingCasted; //nullptr if none
|
|
|
|
|
|
- std::shared_ptr<IImage> bg;
|
|
|
- std::shared_ptr<IImage> bgWorldView;
|
|
|
std::vector<std::shared_ptr<CAnimImage>> gems;
|
|
|
- std::shared_ptr<CMinimap> minimap;
|
|
|
- std::shared_ptr<CGStatusBar> statusbar;
|
|
|
|
|
|
+ std::shared_ptr<IImage> bg;
|
|
|
+ std::shared_ptr<IImage> bgWorldView;
|
|
|
std::shared_ptr<CButton> kingOverview;
|
|
|
+ std::shared_ptr<CButton> sleepWake;
|
|
|
std::shared_ptr<CButton> underground;
|
|
|
std::shared_ptr<CButton> questlog;
|
|
|
- std::shared_ptr<CButton> sleepWake;
|
|
|
std::shared_ptr<CButton> moveHero;
|
|
|
std::shared_ptr<CButton> spellbook;
|
|
|
std::shared_ptr<CButton> advOptions;
|
|
|
std::shared_ptr<CButton> sysOptions;
|
|
|
std::shared_ptr<CButton> nextHero;
|
|
|
std::shared_ptr<CButton> endTurn;
|
|
|
-
|
|
|
std::shared_ptr<CButton> worldViewUnderground;
|
|
|
|
|
|
- std::shared_ptr<CTerrainRect> terrain; //visible terrain
|
|
|
- std::shared_ptr<CResDataBar> resdatabar;
|
|
|
+ std::shared_ptr<CTerrainRect> terrain;
|
|
|
+ std::shared_ptr<CMinimap> minimap;
|
|
|
std::shared_ptr<CHeroList> heroList;
|
|
|
std::shared_ptr<CTownList> townList;
|
|
|
std::shared_ptr<CInfoBar> infoBar;
|
|
|
+ std::shared_ptr<CGStatusBar> statusbar;
|
|
|
+ std::shared_ptr<CResDataBar> resdatabar;
|
|
|
|
|
|
std::shared_ptr<CAdvMapPanel> panelMain; // panel that holds all right-side buttons in normal view
|
|
|
std::shared_ptr<CAdvMapWorldViewPanel> panelWorldView; // panel that holds all buttons and other ui in world view
|
|
|
@@ -128,10 +131,7 @@ public:
|
|
|
|
|
|
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
|
|
|
|
|
- const CSpell *spellBeingCasted; //nullptr if none
|
|
|
-
|
|
|
- const CArmedInstance *selection; //currently selected town/hero
|
|
|
-
|
|
|
+private:
|
|
|
//functions bound to buttons
|
|
|
void fshowOverview();
|
|
|
void fworldViewBack();
|
|
|
@@ -148,21 +148,49 @@ public:
|
|
|
void fnextHero();
|
|
|
void fendTurn();
|
|
|
|
|
|
+ void setScrollingCursor(ui8 direction) const;
|
|
|
+ void selectionChanged();
|
|
|
+ bool isActive();
|
|
|
+ void adjustActiveness(bool aiTurnStart); //should be called every time at AI/human turn transition; blocks GUI during AI turn
|
|
|
+
|
|
|
+ const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else
|
|
|
+ //button updates
|
|
|
+ void updateSleepWake(const CGHeroInstance *h);
|
|
|
+ void updateSpellbook(const CGHeroInstance *h);
|
|
|
+
|
|
|
+ void handleMapScrollingUpdate();
|
|
|
+ void handleSwipeUpdate();
|
|
|
+
|
|
|
+ void showMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
|
|
|
+
|
|
|
+ const CGObjectInstance *getActiveObject(const int3 &tile);
|
|
|
+
|
|
|
+ boost::optional<Point> keyToMoveDirection(const SDL_Keycode & key);
|
|
|
+
|
|
|
+ bool redrawOnNextFrame;
|
|
|
+public:
|
|
|
+ CAdvMapInt();
|
|
|
+
|
|
|
+ // CIntObject interface implementation
|
|
|
+
|
|
|
void activate() override;
|
|
|
void deactivate() override;
|
|
|
|
|
|
- void show(SDL_Surface * to) override; //redraws terrain
|
|
|
- void showAll(SDL_Surface * to) override; //shows and activates adv. map interface
|
|
|
+ void show(SDL_Surface * to) override;
|
|
|
+ void showAll(SDL_Surface * to) override;
|
|
|
+
|
|
|
+ void keyPressed(const SDL_Keycode & key) override;
|
|
|
+ void keyReleased(const SDL_Keycode & key) override;
|
|
|
+ void mouseMoved (const Point & cursorPosition) override;
|
|
|
+
|
|
|
+ // public interface
|
|
|
+
|
|
|
+ void requestRedrawMapOnNextFrame();
|
|
|
|
|
|
void select(const CArmedInstance *sel, bool centerView = true);
|
|
|
- void selectionChanged();
|
|
|
void centerOn(int3 on, bool fade = false);
|
|
|
void centerOn(const CGObjectInstance *obj, bool fade = false);
|
|
|
int3 verifyPos(int3 ver);
|
|
|
- void keyPressed(const SDL_Keycode & key) override;
|
|
|
- void keyReleased(const SDL_Keycode & key) override;
|
|
|
- void mouseMoved (const Point & cursorPosition) override;
|
|
|
- bool isActive();
|
|
|
|
|
|
bool isHeroSleeping(const CGHeroInstance *hero);
|
|
|
void setHeroSleeping(const CGHeroInstance *hero, bool sleep);
|
|
|
@@ -171,34 +199,34 @@ public:
|
|
|
void setPlayer(PlayerColor Player);
|
|
|
void startHotSeatWait(PlayerColor Player);
|
|
|
void startTurn();
|
|
|
+ void initializeNewTurn();
|
|
|
void endingTurn();
|
|
|
void aiTurnStarted();
|
|
|
|
|
|
- void adjustActiveness(bool aiTurnStart); //should be called every time at AI/human turn transition; blocks GUI during AI turn
|
|
|
void quickCombatLock(); //should be called when quick battle started
|
|
|
void quickCombatUnlock();
|
|
|
+
|
|
|
void tileLClicked(const int3 &mapPos);
|
|
|
void tileHovered(const int3 &mapPos);
|
|
|
void tileRClicked(const int3 &mapPos);
|
|
|
+
|
|
|
void enterCastingMode(const CSpell * sp);
|
|
|
void leaveCastingMode(bool cast = false, int3 dest = int3(-1, -1, -1));
|
|
|
const CGHeroInstance * curHero() const;
|
|
|
const CGTownInstance * curTown() const;
|
|
|
- const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else
|
|
|
- //button updates
|
|
|
- void updateSleepWake(const CGHeroInstance *h);
|
|
|
+ const CArmedInstance * curArmy() const;
|
|
|
+
|
|
|
void updateMoveHero(const CGHeroInstance *h, tribool hasPath = boost::logic::indeterminate);
|
|
|
- void updateSpellbook(const CGHeroInstance *h);
|
|
|
void updateNextHero(const CGHeroInstance *h);
|
|
|
|
|
|
- /// changes current adventure map mode; used to switch between default view and world view; scale is ignored if EAdvMapMode == NORMAL
|
|
|
- void changeMode(EAdvMapMode newMode, float newScale = 0.36f);
|
|
|
+ /// returns area of screen covered by terrain (main game area)
|
|
|
+ Rect terrainAreaPixels() const;
|
|
|
|
|
|
- void handleMapScrollingUpdate();
|
|
|
- void handleSwipeUpdate();
|
|
|
+ /// returs visible section of game map, in tiles
|
|
|
+ Rect terrainAreaTiles() const;
|
|
|
|
|
|
-private:
|
|
|
- void showMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
|
|
|
+ /// changes current adventure map mode; used to switch between default view and world view; scale is ignored if EAdvMapMode == NORMAL
|
|
|
+ void changeMode(EAdvMapMode newMode, float newScale);
|
|
|
};
|
|
|
|
|
|
extern std::shared_ptr<CAdvMapInt> adventureInt;
|