mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Remove duplicated code from changed files
This commit is contained in:
parent
18adcdda14
commit
bfea28b2b5
File diff suppressed because it is too large
Load Diff
@ -36,13 +36,6 @@ class CFadeAnimation;
|
||||
|
||||
struct MapDrawingInfo;
|
||||
|
||||
/*****************************/
|
||||
|
||||
enum class EAdvMapMode
|
||||
{
|
||||
NORMAL,
|
||||
WORLD_VIEW
|
||||
};
|
||||
|
||||
/// Adventure options dialog where you can view the world, dig, play the replay of the last turn,...
|
||||
class CAdventureOptions : public CWindowObject
|
||||
@ -59,218 +52,3 @@ public:
|
||||
static void showScenarioInfo();
|
||||
};
|
||||
|
||||
/// Holds information about which tiles of the terrain are shown/not shown at the screen
|
||||
class CTerrainRect : public CIntObject
|
||||
{
|
||||
SDL_Surface * fadeSurface;
|
||||
EMapAnimRedrawStatus lastRedrawStatus;
|
||||
std::shared_ptr<CFadeAnimation> fadeAnim;
|
||||
|
||||
int3 swipeInitialMapPos;
|
||||
int3 swipeInitialRealPos;
|
||||
bool isSwiping;
|
||||
static constexpr float SwipeTouchSlop = 16.0f;
|
||||
|
||||
void handleHover(const SDL_MouseMotionEvent & sEvent);
|
||||
void handleSwipeMove(const SDL_MouseMotionEvent & sEvent);
|
||||
/// handles start/finish of swipe (press/release of corresponding button); returns true if state change was handled
|
||||
bool handleSwipeStateChange(bool btnPressed);
|
||||
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)
|
||||
CGPath * currentPath;
|
||||
|
||||
CTerrainRect();
|
||||
virtual ~CTerrainRect();
|
||||
void deactivate() override;
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
void clickMiddle(tribool down, bool previousState) override;
|
||||
void hover(bool on) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
void showAnim(SDL_Surface * to);
|
||||
void showPath(const Rect &extRect, SDL_Surface * to);
|
||||
int3 whichTileIsIt(const int x, const int y); //x,y are cursor position
|
||||
int3 whichTileIsIt(); //uses current cursor pos
|
||||
/// @returns number of visible tiles on screen respecting current map scaling
|
||||
int3 tileCountOnScreen();
|
||||
/// animates view by caching current surface and crossfading it with normal screen
|
||||
void fadeFromCurrentView();
|
||||
bool needsAnimUpdate();
|
||||
};
|
||||
|
||||
/// Resources bar which shows information about how many gold, crystals,... you have
|
||||
/// Current date is displayed too
|
||||
class CResDataBar : public CIntObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CPicture> background;
|
||||
|
||||
std::vector<std::pair<int,int> > txtpos;
|
||||
std::string datetext;
|
||||
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
CResDataBar();
|
||||
CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
|
||||
~CResDataBar();
|
||||
|
||||
void draw(SDL_Surface * to);
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
||||
/// That's a huge class which handles general adventure map actions and
|
||||
/// shows the right menu(questlog, spellbook, end turn,..) from where you
|
||||
/// 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);
|
||||
|
||||
public:
|
||||
CAdvMapInt();
|
||||
|
||||
int3 position; //top left corner of visible map part
|
||||
PlayerColor player;
|
||||
|
||||
bool duringAITurn;
|
||||
|
||||
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;
|
||||
|
||||
bool updateScreen;
|
||||
ui8 anim, animValHitCount; //animation frame
|
||||
ui8 heroAnim, heroAnimValHitCount; //animation frame
|
||||
|
||||
EAdvMapMode mode;
|
||||
float worldViewScale;
|
||||
|
||||
struct WorldViewOptions
|
||||
{
|
||||
bool showAllTerrain; //for expert viewEarth
|
||||
|
||||
std::vector<ObjectPosInfo> iconPositions;
|
||||
|
||||
WorldViewOptions();
|
||||
|
||||
void clear();
|
||||
|
||||
void adjustDrawingInfo(MapDrawingInfo & info);
|
||||
};
|
||||
|
||||
WorldViewOptions worldViewOptions;
|
||||
|
||||
std::shared_ptr<IImage> bg;
|
||||
std::shared_ptr<IImage> bgWorldView;
|
||||
std::vector<std::shared_ptr<CAnimImage>> gems;
|
||||
CMinimap minimap;
|
||||
std::shared_ptr<CGStatusBar> statusbar;
|
||||
|
||||
std::shared_ptr<CButton> kingOverview;
|
||||
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;
|
||||
|
||||
CTerrainRect terrain; //visible terrain
|
||||
CResDataBar resdatabar;
|
||||
CHeroList heroList;
|
||||
CTownList townList;
|
||||
CInfoBar infoBar;
|
||||
|
||||
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
|
||||
std::shared_ptr<CAdvMapPanel> activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
||||
|
||||
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
||||
|
||||
const CSpell *spellBeingCasted; //nullptr if none
|
||||
|
||||
const CArmedInstance *selection; //currently selected town/hero
|
||||
|
||||
//functions bound to buttons
|
||||
void fshowOverview();
|
||||
void fworldViewBack();
|
||||
void fworldViewScale1x();
|
||||
void fworldViewScale2x();
|
||||
void fworldViewScale4x();
|
||||
void fswitchLevel();
|
||||
void fshowQuestlog();
|
||||
void fsleepWake();
|
||||
void fmoveHero();
|
||||
void fshowSpellbok();
|
||||
void fadventureOPtions();
|
||||
void fsystemOptions();
|
||||
void fnextHero();
|
||||
void fendTurn();
|
||||
|
||||
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 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 handleRightClick(std::string text, tribool down);
|
||||
void keyPressed(const SDL_KeyboardEvent & key) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
bool isActive();
|
||||
|
||||
bool isHeroSleeping(const CGHeroInstance *hero);
|
||||
void setHeroSleeping(const CGHeroInstance *hero, bool sleep);
|
||||
int getNextHeroIndex(int startIndex); //for Next Hero button - cycles awake heroes with movement only
|
||||
|
||||
void setPlayer(PlayerColor Player);
|
||||
void startHotSeatWait(PlayerColor Player);
|
||||
void startTurn();
|
||||
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);
|
||||
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);
|
||||
|
||||
void handleMapScrollingUpdate();
|
||||
void handleSwipeUpdate();
|
||||
|
||||
private:
|
||||
void ShowMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
|
||||
};
|
||||
|
||||
extern std::shared_ptr<CAdvMapInt> adventureInt;
|
||||
|
@ -89,467 +89,6 @@ static void setScrollingCursor(ui8 direction)
|
||||
CCS->curh->set(Cursor::Map::SCROLL_SOUTH);
|
||||
}
|
||||
|
||||
CTerrainRect::CTerrainRect()
|
||||
: fadeSurface(nullptr),
|
||||
lastRedrawStatus(EMapAnimRedrawStatus::OK),
|
||||
fadeAnim(std::make_shared<CFadeAnimation>()),
|
||||
curHoveredTile(-1,-1,-1),
|
||||
currentPath(nullptr)
|
||||
{
|
||||
tilesw=(ADVOPT.advmapW+31)/32;
|
||||
tilesh=(ADVOPT.advmapH+31)/32;
|
||||
pos.x=ADVOPT.advmapX;
|
||||
pos.y=ADVOPT.advmapY;
|
||||
pos.w=ADVOPT.advmapW;
|
||||
pos.h=ADVOPT.advmapH;
|
||||
moveX = moveY = 0;
|
||||
addUsedEvents(LCLICK | RCLICK | MCLICK | HOVER | MOVE);
|
||||
}
|
||||
|
||||
CTerrainRect::~CTerrainRect()
|
||||
{
|
||||
if(fadeSurface)
|
||||
SDL_FreeSurface(fadeSurface);
|
||||
}
|
||||
|
||||
void CTerrainRect::deactivate()
|
||||
{
|
||||
CIntObject::deactivate();
|
||||
curHoveredTile = int3(-1,-1,-1); //we lost info about hovered tile when disabling
|
||||
}
|
||||
|
||||
void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
||||
return;
|
||||
if(indeterminate(down))
|
||||
return;
|
||||
|
||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||
if(adventureInt->swipeEnabled)
|
||||
{
|
||||
if(handleSwipeStateChange((bool)down == true))
|
||||
{
|
||||
return; // if swipe is enabled, we don't process "down" events and wait for "up" (to make sure this wasn't a swiping gesture)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
if(down == false)
|
||||
return;
|
||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||
}
|
||||
#endif
|
||||
int3 mp = whichTileIsIt();
|
||||
if(mp.x < 0 || mp.y < 0 || mp.x >= LOCPLINT->cb->getMapSize().x || mp.y >= LOCPLINT->cb->getMapSize().y)
|
||||
return;
|
||||
|
||||
adventureInt->tileLClicked(mp);
|
||||
}
|
||||
|
||||
void CTerrainRect::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||
if(adventureInt->swipeEnabled && isSwiping)
|
||||
return;
|
||||
#endif
|
||||
if(adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
||||
return;
|
||||
int3 mp = whichTileIsIt();
|
||||
|
||||
if(CGI->mh->map->isInTheMap(mp) && down)
|
||||
adventureInt->tileRClicked(mp);
|
||||
}
|
||||
|
||||
void CTerrainRect::clickMiddle(tribool down, bool previousState)
|
||||
{
|
||||
handleSwipeStateChange((bool)down == true);
|
||||
}
|
||||
|
||||
void CTerrainRect::mouseMoved(const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
handleHover(sEvent);
|
||||
|
||||
if(!adventureInt->swipeEnabled)
|
||||
return;
|
||||
|
||||
handleSwipeMove(sEvent);
|
||||
}
|
||||
|
||||
void CTerrainRect::handleSwipeMove(const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||
if(sEvent.state == 0 || GH.multifinger) // any "button" is enough on mobile
|
||||
#else
|
||||
if((sEvent.state & SDL_BUTTON_MMASK) == 0) // swipe only works with middle mouse on other platforms
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isSwiping)
|
||||
{
|
||||
// try to distinguish if this touch was meant to be a swipe or just fat-fingering press
|
||||
if(abs(sEvent.x - swipeInitialRealPos.x) > SwipeTouchSlop ||
|
||||
abs(sEvent.y - swipeInitialRealPos.y) > SwipeTouchSlop)
|
||||
{
|
||||
isSwiping = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(isSwiping)
|
||||
{
|
||||
adventureInt->swipeTargetPosition.x =
|
||||
swipeInitialMapPos.x + static_cast<si32>(swipeInitialRealPos.x - sEvent.x) / 32;
|
||||
adventureInt->swipeTargetPosition.y =
|
||||
swipeInitialMapPos.y + static_cast<si32>(swipeInitialRealPos.y - sEvent.y) / 32;
|
||||
adventureInt->swipeMovementRequested = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CTerrainRect::handleSwipeStateChange(bool btnPressed)
|
||||
{
|
||||
if(btnPressed)
|
||||
{
|
||||
swipeInitialRealPos = int3(GH.getCursorPosition().x, GH.getCursorPosition().y, 0);
|
||||
swipeInitialMapPos = int3(adventureInt->position);
|
||||
return true;
|
||||
}
|
||||
else if(isSwiping) // only accept this touch if it wasn't a swipe
|
||||
{
|
||||
isSwiping = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CTerrainRect::handleHover(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
int3 tHovered = whichTileIsIt(sEvent.x, sEvent.y);
|
||||
int3 pom = adventureInt->verifyPos(tHovered);
|
||||
|
||||
if(tHovered != pom) //tile outside the map
|
||||
{
|
||||
CCS->curh->set(Cursor::Map::POINTER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pom != curHoveredTile)
|
||||
{
|
||||
curHoveredTile = pom;
|
||||
adventureInt->tileHovered(pom);
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrainRect::hover(bool on)
|
||||
{
|
||||
if (!on)
|
||||
{
|
||||
adventureInt->statusbar->clear();
|
||||
CCS->curh->set(Cursor::Map::POINTER);
|
||||
}
|
||||
//Hoverable::hover(on);
|
||||
}
|
||||
void CTerrainRect::showPath(const Rect & extRect, SDL_Surface * to)
|
||||
{
|
||||
const static int pns[9][9] = {
|
||||
{16, 17, 18, 7, -1, 19, 6, 5, -1},
|
||||
{ 8, 9, 18, 7, -1, 19, 6, -1, 20},
|
||||
{ 8, 1, 10, 7, -1, 19, -1, 21, 20},
|
||||
{24, 17, 18, 15, -1, -1, 6, 5, 4},
|
||||
{-1, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
{ 8, 1, 2, -1, -1, 11, 22, 21, 20},
|
||||
{24, 17, -1, 23, -1, 3, 14, 5, 4},
|
||||
{24, -1, 2, 23, -1, 3, 22, 13, 4},
|
||||
{-1, 1, 2, 23, -1, 3, 22, 21, 12}
|
||||
}; //table of magic values TODO meaning, change variable name
|
||||
|
||||
for (int i = 0; i < -1 + (int)currentPath->nodes.size(); ++i)
|
||||
{
|
||||
const int3 &curPos = currentPath->nodes[i].coord, &nextPos = currentPath->nodes[i+1].coord;
|
||||
if(curPos.z != adventureInt->position.z)
|
||||
continue;
|
||||
|
||||
int pn=-1;//number of picture
|
||||
if (i==0) //last tile
|
||||
{
|
||||
int x = 32*(curPos.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(curPos.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
pn=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int3 &prevPos = currentPath->nodes[i-1].coord;
|
||||
std::vector<CGPathNode> & cv = currentPath->nodes;
|
||||
|
||||
/* Vector directions
|
||||
* 0 1 2
|
||||
* \ | /
|
||||
* 3 - 4 - 5
|
||||
* / | \
|
||||
* 6 7 8
|
||||
*For example:
|
||||
* |
|
||||
* |__\
|
||||
* /
|
||||
* is id1=7, id2=5 (pns[7][5])
|
||||
*/
|
||||
bool pathContinuous = curPos.areNeighbours(nextPos) && curPos.areNeighbours(prevPos);
|
||||
if(pathContinuous && cv[i].action != CGPathNode::EMBARK && cv[i].action != CGPathNode::DISEMBARK)
|
||||
{
|
||||
int id1=(curPos.x-nextPos.x+1)+3*(curPos.y-nextPos.y+1); //Direction of entering vector
|
||||
int id2=(cv[i-1].coord.x-curPos.x+1)+3*(cv[i-1].coord.y-curPos.y+1); //Direction of exiting vector
|
||||
pn=pns[id1][id2];
|
||||
}
|
||||
else //path discontinuity or sea/land transition (eg. when moving through Subterranean Gate or Boat)
|
||||
{
|
||||
pn = 0;
|
||||
}
|
||||
}
|
||||
if (currentPath->nodes[i].turns)
|
||||
pn+=25;
|
||||
if (pn>=0)
|
||||
{
|
||||
const auto arrow = graphics->heroMoveArrows->getImage(pn);
|
||||
|
||||
int x = 32*(curPos.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(curPos.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
if (x< -32 || y< -32 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
int hvx = (x + arrow->width()) - (pos.x + pos.w),
|
||||
hvy = (y + arrow->height()) - (pos.y + pos.h);
|
||||
|
||||
Rect prevClip;
|
||||
CSDL_Ext::getClipRect(to, prevClip);
|
||||
CSDL_Ext::setClipRect(to, extRect); //preventing blitting outside of that rect
|
||||
|
||||
if(ADVOPT.smoothMove) //version for smooth hero move, with pos shifts
|
||||
{
|
||||
if (hvx<0 && hvy<0)
|
||||
{
|
||||
arrow->draw(to, x + moveX, y + moveY);
|
||||
}
|
||||
else if(hvx<0)
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height() - hvy, arrow->width(), 0, 0);
|
||||
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||
}
|
||||
else if (hvy<0)
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height(), arrow->width() - hvx, 0, 0);
|
||||
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
|
||||
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||
}
|
||||
}
|
||||
else //standard version
|
||||
{
|
||||
if (hvx<0 && hvy<0)
|
||||
{
|
||||
arrow->draw(to, x, y);
|
||||
}
|
||||
else if(hvx<0)
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height() - hvy, arrow->width(), 0, 0);
|
||||
arrow->draw(to, x, y, &srcRect);
|
||||
}
|
||||
else if (hvy<0)
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height(), arrow->width() - hvx, 0, 0);
|
||||
arrow->draw(to, x, y, &srcRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect srcRect = genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
|
||||
arrow->draw(to, x, y, &srcRect);
|
||||
}
|
||||
}
|
||||
CSDL_Ext::setClipRect(to, prevClip);
|
||||
|
||||
}
|
||||
} //for (int i=0;i<currentPath->nodes.size()-1;i++)
|
||||
}
|
||||
|
||||
void CTerrainRect::show(SDL_Surface * to)
|
||||
{
|
||||
if (adventureInt->mode == EAdvMapMode::NORMAL)
|
||||
{
|
||||
MapDrawingInfo info(adventureInt->position, LOCPLINT->cb->getVisibilityMap(), pos);
|
||||
info.otherheroAnim = true;
|
||||
info.anim = adventureInt->anim;
|
||||
info.heroAnim = adventureInt->heroAnim;
|
||||
if (ADVOPT.smoothMove)
|
||||
info.movement = int3(moveX, moveY, 0);
|
||||
|
||||
lastRedrawStatus = CGI->mh->drawTerrainRectNew(to, &info);
|
||||
if (fadeAnim->isFading())
|
||||
{
|
||||
Rect r(pos);
|
||||
fadeAnim->update();
|
||||
fadeAnim->draw(to, r.topLeft());
|
||||
}
|
||||
|
||||
if (currentPath/* && adventureInt->position.z==currentPath->startPos().z*/) //drawing path
|
||||
{
|
||||
showPath(pos, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrainRect::showAll(SDL_Surface * to)
|
||||
{
|
||||
// world view map is static and doesn't need redraw every frame
|
||||
if (adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
||||
{
|
||||
MapDrawingInfo info(adventureInt->position, LOCPLINT->cb->getVisibilityMap(), pos, adventureInt->worldViewIcons);
|
||||
info.scaled = true;
|
||||
info.scale = adventureInt->worldViewScale;
|
||||
adventureInt->worldViewOptions.adjustDrawingInfo(info);
|
||||
CGI->mh->drawTerrainRectNew(to, &info);
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrainRect::showAnim(SDL_Surface * to)
|
||||
{
|
||||
if (fadeAnim->isFading())
|
||||
show(to);
|
||||
else if (lastRedrawStatus == EMapAnimRedrawStatus::REDRAW_REQUESTED)
|
||||
show(to); // currently the same; maybe we should pass some flag to map handler so it redraws ONLY tiles that need redraw instead of full
|
||||
}
|
||||
|
||||
int3 CTerrainRect::whichTileIsIt(const int x, const int y)
|
||||
{
|
||||
int3 ret;
|
||||
ret.x = adventureInt->position.x + ((x-CGI->mh->offsetX-pos.x)/32);
|
||||
ret.y = adventureInt->position.y + ((y-CGI->mh->offsetY-pos.y)/32);
|
||||
ret.z = adventureInt->position.z;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int3 CTerrainRect::whichTileIsIt()
|
||||
{
|
||||
return whichTileIsIt(GH.getCursorPosition().x, GH.getCursorPosition().y);
|
||||
}
|
||||
|
||||
int3 CTerrainRect::tileCountOnScreen()
|
||||
{
|
||||
switch (adventureInt->mode)
|
||||
{
|
||||
default:
|
||||
logGlobal->error("Unknown map mode %d", (int)adventureInt->mode);
|
||||
return int3();
|
||||
case EAdvMapMode::NORMAL:
|
||||
return int3(tilesw, tilesh, 1);
|
||||
case EAdvMapMode::WORLD_VIEW:
|
||||
return int3((si32)(tilesw / adventureInt->worldViewScale), (si32)(tilesh / adventureInt->worldViewScale), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrainRect::fadeFromCurrentView()
|
||||
{
|
||||
if (!ADVOPT.screenFading)
|
||||
return;
|
||||
if (adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
||||
return;
|
||||
|
||||
if (!fadeSurface)
|
||||
fadeSurface = CSDL_Ext::newSurface(pos.w, pos.h);
|
||||
CSDL_Ext::blitSurface(screen, fadeSurface, Point(0,0));
|
||||
fadeAnim->init(CFadeAnimation::EMode::OUT, fadeSurface);
|
||||
}
|
||||
|
||||
bool CTerrainRect::needsAnimUpdate()
|
||||
{
|
||||
return fadeAnim->isFading() || lastRedrawStatus == EMapAnimRedrawStatus::REDRAW_REQUESTED;
|
||||
}
|
||||
|
||||
void CResDataBar::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
}
|
||||
|
||||
CResDataBar::CResDataBar(const std::string & defname, int x, int y, int offx, int offy, int resdist, int datedist)
|
||||
{
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
background = std::make_shared<CPicture>(defname, 0, 0);
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
|
||||
pos.w = background->pos.w;
|
||||
pos.h = background->pos.h;
|
||||
|
||||
txtpos.resize(8);
|
||||
for (int i = 0; i < 8 ; i++)
|
||||
{
|
||||
txtpos[i].first = pos.x + offx + resdist*i;
|
||||
txtpos[i].second = pos.y + offy;
|
||||
}
|
||||
txtpos[7].first = txtpos[6].first + datedist;
|
||||
datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, " + CGI->generaltexth->allTexts[64] + ": %s";
|
||||
addUsedEvents(RCLICK);
|
||||
}
|
||||
|
||||
CResDataBar::CResDataBar()
|
||||
{
|
||||
pos.x += ADVOPT.resdatabarX;
|
||||
pos.y += ADVOPT.resdatabarY;
|
||||
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
background = std::make_shared<CPicture>(ADVOPT.resdatabarG, 0, 0);
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
|
||||
pos.w = background->pos.w;
|
||||
pos.h = background->pos.h;
|
||||
|
||||
txtpos.resize(8);
|
||||
for (int i = 0; i < 8 ; i++)
|
||||
{
|
||||
txtpos[i].first = pos.x + ADVOPT.resOffsetX + ADVOPT.resDist*i;
|
||||
txtpos[i].second = pos.y + ADVOPT.resOffsetY;
|
||||
}
|
||||
txtpos[7].first = txtpos[6].first + ADVOPT.resDateDist;
|
||||
datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, " + CGI->generaltexth->allTexts[64] + ": %s";
|
||||
}
|
||||
|
||||
CResDataBar::~CResDataBar() = default;
|
||||
|
||||
void CResDataBar::draw(SDL_Surface * to)
|
||||
{
|
||||
//TODO: all this should be labels, but they require proper text update on change
|
||||
for (auto i=Res::WOOD; i<=Res::GOLD; vstd::advance(i, 1))
|
||||
{
|
||||
std::string text = boost::lexical_cast<std::string>(LOCPLINT->cb->getResourceAmount(i));
|
||||
|
||||
graphics->fonts[FONT_SMALL]->renderTextLeft(to, text, Colors::WHITE, Point(txtpos[i].first,txtpos[i].second));
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
|
||||
temp.push_back(boost::lexical_cast<std::string>(LOCPLINT->cb->getDate(Date::MONTH)));
|
||||
temp.push_back(boost::lexical_cast<std::string>(LOCPLINT->cb->getDate(Date::WEEK)));
|
||||
temp.push_back(boost::lexical_cast<std::string>(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK)));
|
||||
|
||||
graphics->fonts[FONT_SMALL]->renderTextLeft(to, processStr(datetext,temp), Colors::WHITE, Point(txtpos[7].first,txtpos[7].second));
|
||||
}
|
||||
|
||||
void CResDataBar::show(SDL_Surface * to)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CResDataBar::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
draw(to);
|
||||
}
|
||||
|
||||
CAdvMapInt::CAdvMapInt():
|
||||
mode(EAdvMapMode::NORMAL),
|
||||
worldViewScale(0.0f), //actual init later in changeMode
|
||||
@ -1965,42 +1504,6 @@ void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale)
|
||||
}
|
||||
}
|
||||
|
||||
CAdventureOptions::CAdventureOptions()
|
||||
: CWindowObject(PLAYER_COLORED, "ADVOPTS")
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
viewWorld = std::make_shared<CButton>(Point(24, 23), "ADVVIEW.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_v);
|
||||
viewWorld->addCallback(std::bind(&CPlayerInterface::viewWorldMap, LOCPLINT));
|
||||
|
||||
exit = std::make_shared<CButton>(Point(204, 313), "IOK6432.DEF", CButton::tooltip(), std::bind(&CAdventureOptions::close, this), SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
scenInfo = std::make_shared<CButton>(Point(24, 198), "ADVINFO.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_i);
|
||||
scenInfo->addCallback(CAdventureOptions::showScenarioInfo);
|
||||
|
||||
puzzle = std::make_shared<CButton>(Point(24, 81), "ADVPUZ.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_p);
|
||||
puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT));
|
||||
|
||||
dig = std::make_shared<CButton>(Point(24, 139), "ADVDIG.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_d);
|
||||
if(const CGHeroInstance *h = adventureInt->curHero())
|
||||
dig->addCallback(std::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h));
|
||||
else
|
||||
dig->block(true);
|
||||
}
|
||||
|
||||
void CAdventureOptions::showScenarioInfo()
|
||||
{
|
||||
if(LOCPLINT->cb->getStartInfo()->campState)
|
||||
{
|
||||
GH.pushIntT<CCampaignInfoScreen>();
|
||||
}
|
||||
else
|
||||
{
|
||||
GH.pushIntT<CScenarioInfoScreen>();
|
||||
}
|
||||
}
|
||||
|
||||
CAdvMapInt::WorldViewOptions::WorldViewOptions()
|
||||
{
|
||||
clear();
|
||||
@ -2019,3 +1522,4 @@ void CAdvMapInt::WorldViewOptions::adjustDrawingInfo(MapDrawingInfo& info)
|
||||
|
||||
info.additionalIcons = &iconPositions;
|
||||
}
|
||||
|
||||
|
@ -44,84 +44,6 @@ enum class EAdvMapMode
|
||||
WORLD_VIEW
|
||||
};
|
||||
|
||||
/// Adventure options dialog where you can view the world, dig, play the replay of the last turn,...
|
||||
class CAdventureOptions : public CWindowObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CButton> exit;
|
||||
std::shared_ptr<CButton> viewWorld;
|
||||
std::shared_ptr<CButton> puzzle;
|
||||
std::shared_ptr<CButton> dig;
|
||||
std::shared_ptr<CButton> scenInfo;
|
||||
/*std::shared_ptr<CButton> replay*/
|
||||
|
||||
CAdventureOptions();
|
||||
static void showScenarioInfo();
|
||||
};
|
||||
|
||||
/// Holds information about which tiles of the terrain are shown/not shown at the screen
|
||||
class CTerrainRect : public CIntObject
|
||||
{
|
||||
SDL_Surface * fadeSurface;
|
||||
EMapAnimRedrawStatus lastRedrawStatus;
|
||||
std::shared_ptr<CFadeAnimation> fadeAnim;
|
||||
|
||||
int3 swipeInitialMapPos;
|
||||
int3 swipeInitialRealPos;
|
||||
bool isSwiping;
|
||||
static constexpr float SwipeTouchSlop = 16.0f;
|
||||
|
||||
void handleHover(const SDL_MouseMotionEvent & sEvent);
|
||||
void handleSwipeMove(const SDL_MouseMotionEvent & sEvent);
|
||||
/// handles start/finish of swipe (press/release of corresponding button); returns true if state change was handled
|
||||
bool handleSwipeStateChange(bool btnPressed);
|
||||
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)
|
||||
CGPath * currentPath;
|
||||
|
||||
CTerrainRect();
|
||||
virtual ~CTerrainRect();
|
||||
void deactivate() override;
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
void clickMiddle(tribool down, bool previousState) override;
|
||||
void hover(bool on) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
void showAnim(SDL_Surface * to);
|
||||
void showPath(const Rect &extRect, SDL_Surface * to);
|
||||
int3 whichTileIsIt(const int x, const int y); //x,y are cursor position
|
||||
int3 whichTileIsIt(); //uses current cursor pos
|
||||
/// @returns number of visible tiles on screen respecting current map scaling
|
||||
int3 tileCountOnScreen();
|
||||
/// animates view by caching current surface and crossfading it with normal screen
|
||||
void fadeFromCurrentView();
|
||||
bool needsAnimUpdate();
|
||||
};
|
||||
|
||||
/// Resources bar which shows information about how many gold, crystals,... you have
|
||||
/// Current date is displayed too
|
||||
class CResDataBar : public CIntObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CPicture> background;
|
||||
|
||||
std::vector<std::pair<int,int> > txtpos;
|
||||
std::string datetext;
|
||||
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
CResDataBar();
|
||||
CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
|
||||
~CResDataBar();
|
||||
|
||||
void draw(SDL_Surface * to);
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
||||
/// That's a huge class which handles general adventure map actions and
|
||||
/// shows the right menu(questlog, spellbook, end turn,..) from where you
|
||||
/// can get to the towns and heroes.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,72 +36,6 @@ class CFadeAnimation;
|
||||
|
||||
struct MapDrawingInfo;
|
||||
|
||||
/*****************************/
|
||||
|
||||
enum class EAdvMapMode
|
||||
{
|
||||
NORMAL,
|
||||
WORLD_VIEW
|
||||
};
|
||||
|
||||
/// Adventure options dialog where you can view the world, dig, play the replay of the last turn,...
|
||||
class CAdventureOptions : public CWindowObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CButton> exit;
|
||||
std::shared_ptr<CButton> viewWorld;
|
||||
std::shared_ptr<CButton> puzzle;
|
||||
std::shared_ptr<CButton> dig;
|
||||
std::shared_ptr<CButton> scenInfo;
|
||||
/*std::shared_ptr<CButton> replay*/
|
||||
|
||||
CAdventureOptions();
|
||||
static void showScenarioInfo();
|
||||
};
|
||||
|
||||
/// Holds information about which tiles of the terrain are shown/not shown at the screen
|
||||
class CTerrainRect : public CIntObject
|
||||
{
|
||||
SDL_Surface * fadeSurface;
|
||||
EMapAnimRedrawStatus lastRedrawStatus;
|
||||
std::shared_ptr<CFadeAnimation> fadeAnim;
|
||||
|
||||
int3 swipeInitialMapPos;
|
||||
int3 swipeInitialRealPos;
|
||||
bool isSwiping;
|
||||
static constexpr float SwipeTouchSlop = 16.0f;
|
||||
|
||||
void handleHover(const SDL_MouseMotionEvent & sEvent);
|
||||
void handleSwipeMove(const SDL_MouseMotionEvent & sEvent);
|
||||
/// handles start/finish of swipe (press/release of corresponding button); returns true if state change was handled
|
||||
bool handleSwipeStateChange(bool btnPressed);
|
||||
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)
|
||||
CGPath * currentPath;
|
||||
|
||||
CTerrainRect();
|
||||
virtual ~CTerrainRect();
|
||||
void deactivate() override;
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
void clickMiddle(tribool down, bool previousState) override;
|
||||
void hover(bool on) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
void showAnim(SDL_Surface * to);
|
||||
void showPath(const Rect &extRect, SDL_Surface * to);
|
||||
int3 whichTileIsIt(const int x, const int y); //x,y are cursor position
|
||||
int3 whichTileIsIt(); //uses current cursor pos
|
||||
/// @returns number of visible tiles on screen respecting current map scaling
|
||||
int3 tileCountOnScreen();
|
||||
/// animates view by caching current surface and crossfading it with normal screen
|
||||
void fadeFromCurrentView();
|
||||
bool needsAnimUpdate();
|
||||
};
|
||||
|
||||
/// Resources bar which shows information about how many gold, crystals,... you have
|
||||
/// Current date is displayed too
|
||||
class CResDataBar : public CIntObject
|
||||
@ -122,155 +56,3 @@ public:
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
||||
/// That's a huge class which handles general adventure map actions and
|
||||
/// shows the right menu(questlog, spellbook, end turn,..) from where you
|
||||
/// 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);
|
||||
|
||||
public:
|
||||
CAdvMapInt();
|
||||
|
||||
int3 position; //top left corner of visible map part
|
||||
PlayerColor player;
|
||||
|
||||
bool duringAITurn;
|
||||
|
||||
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;
|
||||
|
||||
bool updateScreen;
|
||||
ui8 anim, animValHitCount; //animation frame
|
||||
ui8 heroAnim, heroAnimValHitCount; //animation frame
|
||||
|
||||
EAdvMapMode mode;
|
||||
float worldViewScale;
|
||||
|
||||
struct WorldViewOptions
|
||||
{
|
||||
bool showAllTerrain; //for expert viewEarth
|
||||
|
||||
std::vector<ObjectPosInfo> iconPositions;
|
||||
|
||||
WorldViewOptions();
|
||||
|
||||
void clear();
|
||||
|
||||
void adjustDrawingInfo(MapDrawingInfo & info);
|
||||
};
|
||||
|
||||
WorldViewOptions worldViewOptions;
|
||||
|
||||
std::shared_ptr<IImage> bg;
|
||||
std::shared_ptr<IImage> bgWorldView;
|
||||
std::vector<std::shared_ptr<CAnimImage>> gems;
|
||||
CMinimap minimap;
|
||||
std::shared_ptr<CGStatusBar> statusbar;
|
||||
|
||||
std::shared_ptr<CButton> kingOverview;
|
||||
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;
|
||||
|
||||
CTerrainRect terrain; //visible terrain
|
||||
CResDataBar resdatabar;
|
||||
CHeroList heroList;
|
||||
CTownList townList;
|
||||
CInfoBar infoBar;
|
||||
|
||||
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
|
||||
std::shared_ptr<CAdvMapPanel> activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
||||
|
||||
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
||||
|
||||
const CSpell *spellBeingCasted; //nullptr if none
|
||||
|
||||
const CArmedInstance *selection; //currently selected town/hero
|
||||
|
||||
//functions bound to buttons
|
||||
void fshowOverview();
|
||||
void fworldViewBack();
|
||||
void fworldViewScale1x();
|
||||
void fworldViewScale2x();
|
||||
void fworldViewScale4x();
|
||||
void fswitchLevel();
|
||||
void fshowQuestlog();
|
||||
void fsleepWake();
|
||||
void fmoveHero();
|
||||
void fshowSpellbok();
|
||||
void fadventureOPtions();
|
||||
void fsystemOptions();
|
||||
void fnextHero();
|
||||
void fendTurn();
|
||||
|
||||
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 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 handleRightClick(std::string text, tribool down);
|
||||
void keyPressed(const SDL_KeyboardEvent & key) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
bool isActive();
|
||||
|
||||
bool isHeroSleeping(const CGHeroInstance *hero);
|
||||
void setHeroSleeping(const CGHeroInstance *hero, bool sleep);
|
||||
int getNextHeroIndex(int startIndex); //for Next Hero button - cycles awake heroes with movement only
|
||||
|
||||
void setPlayer(PlayerColor Player);
|
||||
void startHotSeatWait(PlayerColor Player);
|
||||
void startTurn();
|
||||
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);
|
||||
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);
|
||||
|
||||
void handleMapScrollingUpdate();
|
||||
void handleSwipeUpdate();
|
||||
|
||||
private:
|
||||
void ShowMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
|
||||
};
|
||||
|
||||
extern std::shared_ptr<CAdvMapInt> adventureInt;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,29 +36,6 @@ class CFadeAnimation;
|
||||
|
||||
struct MapDrawingInfo;
|
||||
|
||||
/*****************************/
|
||||
|
||||
enum class EAdvMapMode
|
||||
{
|
||||
NORMAL,
|
||||
WORLD_VIEW
|
||||
};
|
||||
|
||||
/// Adventure options dialog where you can view the world, dig, play the replay of the last turn,...
|
||||
class CAdventureOptions : public CWindowObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CButton> exit;
|
||||
std::shared_ptr<CButton> viewWorld;
|
||||
std::shared_ptr<CButton> puzzle;
|
||||
std::shared_ptr<CButton> dig;
|
||||
std::shared_ptr<CButton> scenInfo;
|
||||
/*std::shared_ptr<CButton> replay*/
|
||||
|
||||
CAdventureOptions();
|
||||
static void showScenarioInfo();
|
||||
};
|
||||
|
||||
/// Holds information about which tiles of the terrain are shown/not shown at the screen
|
||||
class CTerrainRect : public CIntObject
|
||||
{
|
||||
@ -102,175 +79,3 @@ public:
|
||||
bool needsAnimUpdate();
|
||||
};
|
||||
|
||||
/// Resources bar which shows information about how many gold, crystals,... you have
|
||||
/// Current date is displayed too
|
||||
class CResDataBar : public CIntObject
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CPicture> background;
|
||||
|
||||
std::vector<std::pair<int,int> > txtpos;
|
||||
std::string datetext;
|
||||
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
CResDataBar();
|
||||
CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
|
||||
~CResDataBar();
|
||||
|
||||
void draw(SDL_Surface * to);
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
||||
/// That's a huge class which handles general adventure map actions and
|
||||
/// shows the right menu(questlog, spellbook, end turn,..) from where you
|
||||
/// 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);
|
||||
|
||||
public:
|
||||
CAdvMapInt();
|
||||
|
||||
int3 position; //top left corner of visible map part
|
||||
PlayerColor player;
|
||||
|
||||
bool duringAITurn;
|
||||
|
||||
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;
|
||||
|
||||
bool updateScreen;
|
||||
ui8 anim, animValHitCount; //animation frame
|
||||
ui8 heroAnim, heroAnimValHitCount; //animation frame
|
||||
|
||||
EAdvMapMode mode;
|
||||
float worldViewScale;
|
||||
|
||||
struct WorldViewOptions
|
||||
{
|
||||
bool showAllTerrain; //for expert viewEarth
|
||||
|
||||
std::vector<ObjectPosInfo> iconPositions;
|
||||
|
||||
WorldViewOptions();
|
||||
|
||||
void clear();
|
||||
|
||||
void adjustDrawingInfo(MapDrawingInfo & info);
|
||||
};
|
||||
|
||||
WorldViewOptions worldViewOptions;
|
||||
|
||||
std::shared_ptr<IImage> bg;
|
||||
std::shared_ptr<IImage> bgWorldView;
|
||||
std::vector<std::shared_ptr<CAnimImage>> gems;
|
||||
CMinimap minimap;
|
||||
std::shared_ptr<CGStatusBar> statusbar;
|
||||
|
||||
std::shared_ptr<CButton> kingOverview;
|
||||
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;
|
||||
|
||||
CTerrainRect terrain; //visible terrain
|
||||
CResDataBar resdatabar;
|
||||
CHeroList heroList;
|
||||
CTownList townList;
|
||||
CInfoBar infoBar;
|
||||
|
||||
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
|
||||
std::shared_ptr<CAdvMapPanel> activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
||||
|
||||
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
||||
|
||||
const CSpell *spellBeingCasted; //nullptr if none
|
||||
|
||||
const CArmedInstance *selection; //currently selected town/hero
|
||||
|
||||
//functions bound to buttons
|
||||
void fshowOverview();
|
||||
void fworldViewBack();
|
||||
void fworldViewScale1x();
|
||||
void fworldViewScale2x();
|
||||
void fworldViewScale4x();
|
||||
void fswitchLevel();
|
||||
void fshowQuestlog();
|
||||
void fsleepWake();
|
||||
void fmoveHero();
|
||||
void fshowSpellbok();
|
||||
void fadventureOPtions();
|
||||
void fsystemOptions();
|
||||
void fnextHero();
|
||||
void fendTurn();
|
||||
|
||||
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 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 handleRightClick(std::string text, tribool down);
|
||||
void keyPressed(const SDL_KeyboardEvent & key) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
|
||||
bool isActive();
|
||||
|
||||
bool isHeroSleeping(const CGHeroInstance *hero);
|
||||
void setHeroSleeping(const CGHeroInstance *hero, bool sleep);
|
||||
int getNextHeroIndex(int startIndex); //for Next Hero button - cycles awake heroes with movement only
|
||||
|
||||
void setPlayer(PlayerColor Player);
|
||||
void startHotSeatWait(PlayerColor Player);
|
||||
void startTurn();
|
||||
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);
|
||||
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);
|
||||
|
||||
void handleMapScrollingUpdate();
|
||||
void handleSwipeUpdate();
|
||||
|
||||
private:
|
||||
void ShowMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
|
||||
};
|
||||
|
||||
extern std::shared_ptr<CAdvMapInt> adventureInt;
|
||||
|
Loading…
Reference in New Issue
Block a user