57 #include "resources/map/map.h"
77 mScrollRadius(
config.getIntValue(
"ScrollRadius")),
78 mScrollLaziness(
config.getIntValue(
"ScrollLaziness")),
79 mScrollCenterOffsetX(
config.getIntValue(
"ScrollCenterOffsetX")),
80 mScrollCenterOffsetY(
config.getIntValue(
"ScrollCenterOffsetY")),
92 mShowBeingPopup(
config.getBoolValue(
"showBeingPopup")),
93 mSelfMouseHeal(
config.getBoolValue(
"selfMouseHeal")),
94 mEnableLazyScrolling(
config.getBoolValue(
"enableLazyScrolling")),
95 mMouseDirectionMove(
config.getBoolValue(
"mouseDirectionMove")),
96 mLongMouseClick(
config.getBoolValue(
"longmouseclick")),
97 mAllowMoveByMouse(
config.getBoolValue(
"allowMoveByMouse")),
99 mPlayerFollowMouse(false)
102 addMouseListener(
this);
125 if ((
mMap !=
nullptr) && (map !=
nullptr))
167 static_cast<float>(player_x
174 static_cast<float>(player_x
181 static_cast<float>(player_y
188 static_cast<float>(player_y
200 - player_y > graphics->
getHeight() / 2 || player_y
203 if (player_x <= 0 || player_y <= 0)
205 logger->
log(
"incorrect player position: %d, %d, %d, %d",
320 static Path debugPath;
321 static Vector lastMouseDestination =
Vector(0.0F, 0.0F, 0.0F);
324 Vector mouseDestination(mousePosX, mousePosY, 0.0F);
326 if (mouseDestination.x != lastMouseDestination.
x
327 || mouseDestination.y != lastMouseDestination.
y)
336 lastMouseDestination = mouseDestination;
344 const Being *
const being =
dynamic_cast<const Being*
>(*it);
356 const Color &color)
const
362 FOR_EACH (Path::const_iterator, i, path)
370 const std::string str =
toString(cnt);
374 squareX + 4 - font->
getWidth(str) / 2,
384 const int eventX =
event.getX();
385 const int eventY =
event.getY();
393 STD_VECTOR<ActorSprite*> beings;
397 if (beings.size() > 1)
527 strprintf(
"%d %d", mouseTileX, mouseTileY),
608 if (target !=
nullptr)
620 int &destX,
int &destY)
const
627 /
static_cast<float>(tw);
631 const int th2 = th / 2;
634 int newDiffY = 1000000;
637 for (
int f = tileViewY; f < tileViewY + heightTiles; f ++)
651 const int pixelF = f * th;
652 const int diff = abs(clickY + offset - pixelF);
687 const float wh =
static_cast<float>(width)
688 /
static_cast<float>(height);
689 int x =
event.getX() - width;
690 int y =
event.getY() - height;
691 if ((
x == 0) && (
y == 0))
693 const int x2 = abs(
x);
694 const int y2 = abs(
y);
695 const float diff = 2;
701 static_cast<float>(x2) /
static_cast<float>(y2) /
709 if ((x2 != 0) && y2 * wh / x2 > diff)
732 if ((dx != 0) && (dy != 0))
823 if (playerX != destX || playerY != destY)
829 else if (playerX < destX)
833 else if (playerY < destY)
899 if (name ==
"ScrollLaziness")
901 else if (name ==
"ScrollRadius")
903 else if (name ==
"showBeingPopup")
905 else if (name ==
"selfMouseHeal")
907 else if (name ==
"enableLazyScrolling")
909 else if (name ==
"mouseDirectionMove")
911 else if (name ==
"longmouseclick")
913 else if (name ==
"allowMoveByMouse")
920 if (
mMap ==
nullptr ||
959 if (specialLayer !=
nullptr)
1036 if (
mMap !=
nullptr)
1078 const int x,
const int y)
1084 if (actor ==
nullptr)
1139 if (
mMap ==
nullptr)
1151 if (
mMap !=
nullptr)
ActorManager * actorManager
std::set< ActorSprite * > ActorSprites
ActorSprites::const_iterator ActorSpritesConstIterator
ActorSprites::iterator ActorSpritesIterator
const bool AllPlayers_true
#define reportAlways(...)
Being * findNearestLivingBeing(const int x, const int y, int maxTileDist, const ActorTypeT type, const Being *const excluded) const
void findBeingsByPixel(std::vector< ActorSprite * > &beings, const int x, const int y, const AllPlayers allPlayers) const
Being * findBeing(const BeingId id) const
void heal(const Being *const target) const
FloorItem * findItem(const BeingId id) const
Being * findBeingByPixel(const int x, const int y, const AllPlayers allPlayers) const
const ActorSprites & getAll() const A_CONST
void draw(Graphics *const graphics)
void drawEmotion(Graphics *const graphics, const int offsetX, const int offsetY) const
const Path & getPath() const
int getActionTime() const
void drawSpeech(const int offsetX, const int offsetY)
void setName(const std::string &name)
const std::string & getName() const
CursorT getHoverCursor() const
ActorTypeT getType() const
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
int getIntValue(const std::string &key) const
Widget * getSource() const
CursorT getHoverCursor() const
int getWidth(const std::string &text) const
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
static uint8_t getMouseState(int &x, int &y)
void setCursorType(const CursorT index)
bool getCheckNameSetting() const
void setTarget(Being *const target)
void setCheckNameSetting(const bool checked)
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
bool navigateTo(const int x, const int y)
void stopAttack(const bool keepAttack)
bool withinAttackRange(const Being *const target, const bool fixDistance, const int addRange) const
void setGotoTarget(Being *const target)
unsigned char getBlockWalkMask() const A_CONST
bool pickUp(FloorItem *const item)
void log(const char *const log_text,...)
const std::string & getComment() const
uint8_t getHeightOffset(const int x, const int y) const
void setDrawLayersFlags(const MapTypeT &n)
bool isHeightsPresent() const
int getTileHeight() const
void draw(Graphics *const graphics, int scrollX, int scrollY)
bool getWalk(const int x, const int y, const unsigned char blockWalkMask) const
void drawCollision(Graphics *const graphics, const int scrollX, const int scrollY, const MapTypeT drawFlags) const
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
MapTypeT getDrawLayersFlags() const
SpecialLayer * getSpecialLayer() const
void drawIcons(Graphics *const graphics)
MapItem * getTile(const int x, const int y) const
void draw(Graphics *const graphics, const int xOff, const int yOff)
static void distributeEvent()
const Color & getColorWithAlpha(const UserColorIdT type)
void clearHover(const ActorSprite *const actor)
Clears any matching hovers.
void getMouseTile(int &destX, int &destY) const
void moveCameraToActor(const BeingId actorId, const int x, const int y)
bool openContextMenu(const MouseEvent &event)
void moveCamera(const int dx, const int dy)
static void validateSpeed()
bool mEnableLazyScrolling
void optionChanged(const std::string &name)
void drawPath(Graphics *const graphics, const Path &path, const Color &color) const
void mouseMoved(MouseEvent &event)
void mousePressed(MouseEvent &event)
void moveCameraRelative(const int x, const int y)
void draw(Graphics *const graphics)
void walkByMouse(const MouseEvent &event)
void mouseDragged(MouseEvent &event)
void setMap(Map *const map)
void drawDebugPath(Graphics *const graphics)
void safeDraw(Graphics *const graphics)
void moveCameraToPosition(const int x, const int y)
void mouseReleased(MouseEvent &event)
static const int mapTileSize
#define FOR_EACH(type, iter, array)
LocalPlayer * localPlayer
MiniStatusWindow * miniStatusWindow
bool stopAttack(InputEvent &event)
std::string toString(T const &value)
converts any type to a string
#define BLOCK_START(name)
std::list< Position > Path
std::string strprintf(const char *const format,...)
TextManager * textManager
UserPalette * userPalette