summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt24
-rw-r--r--src/Makefile.am50
-rw-r--r--src/client.h146
-rw-r--r--src/gui/viewport.h229
-rw-r--r--src/progs/dyecmd/client.cpp2
-rw-r--r--src/progs/manaplus/actions/actions.cpp (renamed from src/actions/actions.cpp)0
-rw-r--r--src/progs/manaplus/actions/chat.cpp (renamed from src/actions/chat.cpp)0
-rw-r--r--src/progs/manaplus/actions/commands.cpp (renamed from src/actions/commands.cpp)0
-rw-r--r--src/progs/manaplus/actions/move.cpp (renamed from src/actions/move.cpp)0
-rw-r--r--src/progs/manaplus/actions/pets.cpp (renamed from src/actions/pets.cpp)0
-rw-r--r--src/progs/manaplus/actions/statusbar.cpp (renamed from src/actions/statusbar.cpp)0
-rw-r--r--src/progs/manaplus/actions/tabs.cpp (renamed from src/actions/tabs.cpp)0
-rw-r--r--src/progs/manaplus/actions/target.cpp (renamed from src/actions/target.cpp)0
-rw-r--r--src/progs/manaplus/actions/windows.cpp (renamed from src/actions/windows.cpp)0
-rw-r--r--src/progs/manaplus/client.cpp (renamed from src/client.cpp)2
-rw-r--r--src/progs/manaplus/client.h167
-rw-r--r--src/progs/manaplus/gui/viewport.cpp (renamed from src/gui/viewport.cpp)2
-rw-r--r--src/progs/manaplus/gui/viewport.h249
18 files changed, 461 insertions, 410 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 62ba63ffd..37389a0c2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -530,7 +530,8 @@ SET(SRCS
gui/windows/updaterwindow.h
gui/userpalette.cpp
gui/userpalette.h
- gui/viewport.cpp
+ progs/manaplus/gui/viewport.cpp
+ progs/manaplus/gui/viewport.h
gui/viewport.h
gui/windowmanager.cpp
gui/windowmanager.h
@@ -980,23 +981,23 @@ SET(SRCS
test/testmain.h
actions/actiondef.h
actions/actionfuncptr.h
- actions/actions.cpp
+ progs/manaplus/actions/actions.cpp
actions/actions.h
- actions/chat.cpp
+ progs/manaplus/actions/chat.cpp
actions/chat.h
- actions/commands.cpp
+ progs/manaplus/actions/commands.cpp
actions/commands.h
- actions/move.cpp
+ progs/manaplus/actions/move.cpp
actions/move.h
- actions/pets.cpp
+ progs/manaplus/actions/pets.cpp
actions/pets.h
- actions/statusbar.cpp
+ progs/manaplus/actions/statusbar.cpp
actions/statusbar.h
- actions/tabs.cpp
+ progs/manaplus/actions/tabs.cpp
actions/tabs.h
- actions/target.cpp
+ progs/manaplus/actions/target.cpp
actions/target.h
- actions/windows.cpp
+ progs/manaplus/actions/windows.cpp
actions/windows.h
being/actor.cpp
being/actor.h
@@ -1046,7 +1047,8 @@ SET(SRCS
spellmanager.h
chatlogger.cpp
chatlogger.h
- client.cpp
+ progs/manaplus/client.cpp
+ progs/manaplus/client.h
client.h
commandline.cpp
commandline.h
diff --git a/src/Makefile.am b/src/Makefile.am
index f8b7cf8a6..9497c7943 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -182,7 +182,8 @@ manaplus_CXXFLAGS += -DUSE_SDL2
endif
endif
-BASE_SRC += events/actionevent.h \
+BASE_SRC += client.h \
+ events/actionevent.h \
listeners/actionlistener.h \
listeners/attributelistener.cpp \
listeners/attributelistener.h \
@@ -251,6 +252,7 @@ BASE_SRC += events/actionevent.h \
listeners/widgetlistener.h \
listeners/wrongdatanoticelistener.cpp \
listeners/wrongdatanoticelistener.h \
+ gui/viewport.h \
gui/widgets/basiccontainer2.h \
gui/widgets/basiccontainer.cpp \
gui/colorpair.h \
@@ -660,6 +662,15 @@ BASE_SRC += events/actionevent.h \
test/testmain.h \
actions/actiondef.h \
actions/actionfuncptr.h \
+ actions/actions.h \
+ actions/chat.h \
+ actions/commands.h \
+ actions/move.h \
+ actions/pets.h \
+ actions/statusbar.h \
+ actions/tabs.h \
+ actions/target.h \
+ actions/windows.h \
listeners/baselistener.hpp \
commandline.cpp \
commandline.h \
@@ -944,26 +955,6 @@ SRC = ${BASE_SRC} \
resources/sprite/animatedsprite.h \
resources/sprite/animationdelayload.cpp \
resources/sprite/animationdelayload.h \
- actions/actions.cpp \
- actions/actions.h \
- actions/chat.cpp \
- actions/chat.h \
- actions/commands.cpp \
- actions/commands.h \
- actions/move.cpp \
- actions/move.h \
- actions/pets.cpp \
- actions/pets.h \
- actions/statusbar.cpp \
- actions/statusbar.h \
- actions/tabs.cpp \
- actions/tabs.h \
- actions/target.cpp \
- actions/target.h \
- actions/windows.cpp \
- actions/windows.h \
- client.cpp \
- client.h \
resources/dbmanager.cpp \
resources/dbmanager.h \
resources/sprite/imagesprite.cpp \
@@ -1083,8 +1074,6 @@ SRC = ${BASE_SRC} \
listeners/awaylistener.h \
listeners/charrenamelistener.cpp \
listeners/charrenamelistener.h \
- gui/viewport.cpp \
- gui/viewport.h \
gui/popups/itempopup.cpp \
gui/popups/itempopup.h \
gui/popups/spellpopup.cpp \
@@ -1643,7 +1632,20 @@ SRC = ${BASE_SRC} \
net/ea/tradehandler.cpp \
net/ea/tradehandler.h \
net/ea/traderecv.cpp \
- net/ea/traderecv.h
+ net/ea/traderecv.h \
+ progs/manaplus/actions/actions.cpp \
+ progs/manaplus/actions/chat.cpp \
+ progs/manaplus/actions/commands.cpp \
+ progs/manaplus/actions/move.cpp \
+ progs/manaplus/actions/pets.cpp \
+ progs/manaplus/actions/statusbar.cpp \
+ progs/manaplus/actions/tabs.cpp \
+ progs/manaplus/actions/target.cpp \
+ progs/manaplus/actions/windows.cpp \
+ progs/manaplus/client.cpp \
+ progs/manaplus/client.h \
+ progs/manaplus/gui/viewport.cpp \
+ progs/manaplus/gui/viewport.h
if ENABLE_TMWA
manaplus_CXXFLAGS += -DTMWA_SUPPORT
diff --git a/src/client.h b/src/client.h
index 6c6888f52..feead38e4 100644
--- a/src/client.h
+++ b/src/client.h
@@ -1,7 +1,5 @@
/*
* The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2017 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
@@ -25,149 +23,7 @@
#ifdef DYECMD
#include "progs/dyecmd/client.h"
-
#else // DYECMD
-
-#include "enums/state.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/configlistener.h"
-
-#include "net/serverinfo.h"
-
-#include "localconsts.h"
-
-class Button;
-class Game;
-class LoginData;
-class Skin;
-class Window;
-class QuitDialog;
-
-extern bool isSafeMode;
-extern int serverVersion;
-extern unsigned int tmwServerVersion;
-extern time_t start_time;
-extern int textures_count;
-
-extern std::string errorMessage;
-extern LoginData loginData;
-
-/**
- * The core part of the client. This class initializes all subsystems, runs
- * the event loop, and shuts everything down again.
- */
-class Client final : public ConfigListener,
- public ActionListener
-{
- public:
- Client();
-
- A_DELETE_COPY(Client)
-
- ~Client();
-
- void gameInit();
-
- void testsInit();
-
- int gameExec();
-
- static int testsExec();
-
- void setState(const StateT state)
- { mState = state; }
-
- StateT getState() const noexcept2 A_WARN_UNUSED
- { return mState; }
-
- static bool isTmw() A_WARN_UNUSED;
-
- void optionChanged(const std::string &name) override final;
-
- void action(const ActionEvent &event) override final;
-
- static void initTradeFilter();
-
- void moveButtons(const int width);
-
- void windowRemoved(const Window *const window);
-
- void slowLogic();
-
- ServerInfo &getCurrentServer()
- { return mCurrentServer; }
-
- private:
- void initSoundManager();
-
- void initConfigListeners();
-
- static void initGraphics();
-
- static void initFeatures();
-
- static void initPaths();
-
- void gameClear();
-
- void testsClear();
-
-#ifdef ANDROID
- static void logVars();
-#else // ANDROID
-
- static void logVars() A_CONST;
-#endif // ANDROID
-
- void stateConnectGame1();
-
- void stateConnectServer1();
-
- void stateWorldSelect1();
-
- void stateGame1();
-
- void stateSwitchLogin1();
-
- void loadData();
-
- void unloadData();
-
- void runValidate()
-#ifndef BAD_CILKPLUS
- __attribute__ ((noreturn))
-#endif // BAD_CILKPLUS
-;
-
- ServerInfo mCurrentServer;
-
- Game *mGame;
- Window *mCurrentDialog;
- QuitDialog *mQuitDialog;
- Button *mSetupButton;
- Button *mVideoButton;
- Button *mHelpButton;
- Button *mAboutButton;
- Button *mThemesButton;
- Button *mPerfomanceButton;
-#ifdef ANDROID
- Button *mCloseButton;
-#endif // ANDROID
-
- StateT mState;
- StateT mOldState;
-
- Skin *mSkin;
- int mButtonPadding;
- int mButtonSpacing;
- int mPing;
- bool mConfigAutoSaved;
-};
-
-extern Client *client;
-extern unsigned int mLastHost;
-extern unsigned long mSearchHash;
-
+#include "progs/manaplus/client.h"
#endif // DYECMD
#endif // CLIENT_H
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index f4e3d26be..70c918bf6 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -1,7 +1,5 @@
/*
* The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2017 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
@@ -25,231 +23,8 @@
#ifdef DYECMD
#include "progs/dyecmd/gui/viewport.h"
-
#else
-
-#include "position.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "listeners/mouselistener.h"
-
-class ActorSprite;
-class Being;
-class FloorItem;
-class Graphics;
-class Map;
-class MapItem;
-
-/**
- * The viewport on the map. Displays the current map and handles mouse input
- * and the popup menu.
- */
-class Viewport final : public WindowContainer,
- public MouseListener,
- public ConfigListener
-{
- public:
- /**
- * Constructor.
- */
- Viewport();
-
- A_DELETE_COPY(Viewport)
-
- /**
- * Destructor.
- */
- ~Viewport();
-
- /**
- * Sets the map displayed by the viewport.
- */
- void setMap(Map *const map);
-
- /**
- * Draws the viewport.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Implements player to keep following mouse.
- */
- void logic() override final;
-
- /**
- * Toggles whether the path debug graphics are shown. normal,
- * debug with all images and grid, debug with out big images
- * and with out grid.
- */
- void toggleMapDrawType();
-
- void toggleCameraMode();
-
- /**
- * Handles mouse press on map.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse button release on map.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map.
- */
- void mouseMoved(MouseEvent &event) override final;
-
- /**
- * A relevant config option changed.
- */
- void optionChanged(const std::string &name) override final;
-
- /**
- * Returns camera x offset in pixels.
- */
- int getCameraX() const noexcept2 A_WARN_UNUSED
- { return mPixelViewX; }
-
- /**
- * Returns camera y offset in pixels.
- */
- int getCameraY() const noexcept2 A_WARN_UNUSED
- { return mPixelViewY; }
-
- /**
- * Changes viewpoint by relative pixel coordinates.
- */
- void scrollBy(const int x, const int y)
- { mPixelViewX += x; mPixelViewY += y; }
-
- /**
- * Clear all hover item, being etc
- */
- void cleanHoverItems();
-
- Map *getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- void moveCamera(const int dx, const int dy);
-
- int getCameraRelativeX() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeX; }
-
- int getCameraRelativeY() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeY; }
-
- void setCameraRelativeX(const int n)
- { mCameraRelativeX = n; updateMidVars(); }
-
- void setCameraRelativeY(const int n)
- { mCameraRelativeY = n; updateMidVars(); }
-
- void moveCameraToActor(const BeingId actorId,
- const int x = 0,
- const int y = 0);
-
- void moveCameraToPosition(const int x, const int y);
-
- void moveCameraRelative(const int x, const int y);
-
- void returnCamera();
-
- void getMouseTile(int &destX, int &destY) const;
-
- void videoResized();
-
- int mMouseX; /**< Current mouse position in pixels. */
- int mMouseY; /**< Current mouse position in pixels. */
-
- protected:
- friend class ActorManager;
-
- /// Clears any matching hovers
- void clearHover(const ActorSprite *const actor);
-
- void updateMidVars();
-
- void updateMaxVars();
-
- static void validateSpeed();
-
- private:
- /**
- * Finds a path from the player to the mouse, and draws it. This is for
- * debug purposes.
- */
- void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Draws the given path.
- */
- void drawPath(Graphics *const graphics,
- const Path &path,
- const Color &color = Color(255, 0, 0))
- const A_NONNULL(2);
-
- bool leftMouseAction();
-
- bool openContextMenu(const MouseEvent &event);
-
- void walkByMouse(const MouseEvent &event);
-
- void getMouseTile(const int x,
- const int y,
- int &destX,
- int &destY) const;
-
- /**
- * Make the player go to the mouse position.
- */
- void followMouse();
-
- Map *mMap; /**< The current map. */
-
- Being *mHoverBeing; /**< Being mouse is currently over. */
- FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */
- MapItem *mHoverSign; /**< Map sign mouse is currently over. */
-
- int mScrollRadius;
- int mScrollLaziness;
- int mScrollCenterOffsetX;
- int mScrollCenterOffsetY;
- int mMousePressX;
- int mMousePressY;
- int mPixelViewX; /**< Current viewpoint in pixels. */
- int mPixelViewY; /**< Current viewpoint in pixels. */
- int mMidTileX;
- int mMidTileY;
- int mViewXmax;
- int mViewYmax;
-
- time_t mLocalWalkTime;
-
- int mCameraRelativeX;
- int mCameraRelativeY;
-
- bool mShowBeingPopup;
- bool mSelfMouseHeal;
- bool mEnableLazyScrolling;
- bool mMouseDirectionMove;
- bool mLongMouseClick;
- bool mAllowMoveByMouse;
- bool mMouseClicked;
- bool mPlayerFollowMouse;
-};
-
-extern Viewport *viewport; /**< The viewport. */
-
+#include "progs/manaplus/gui/viewport.h"
#endif // DYECMD
+
#endif // GUI_VIEWPORT_H
diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp
index 42b570a6b..7f75f4cd5 100644
--- a/src/progs/dyecmd/client.cpp
+++ b/src/progs/dyecmd/client.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "client.h"
+#include "progs/dyecmd/client.h"
#include "configmanager.h"
#include "dirs.h"
diff --git a/src/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp
index b958f8f62..b958f8f62 100644
--- a/src/actions/actions.cpp
+++ b/src/progs/manaplus/actions/actions.cpp
diff --git a/src/actions/chat.cpp b/src/progs/manaplus/actions/chat.cpp
index 307e4556e..307e4556e 100644
--- a/src/actions/chat.cpp
+++ b/src/progs/manaplus/actions/chat.cpp
diff --git a/src/actions/commands.cpp b/src/progs/manaplus/actions/commands.cpp
index f2d49b13b..f2d49b13b 100644
--- a/src/actions/commands.cpp
+++ b/src/progs/manaplus/actions/commands.cpp
diff --git a/src/actions/move.cpp b/src/progs/manaplus/actions/move.cpp
index d2be4de7e..d2be4de7e 100644
--- a/src/actions/move.cpp
+++ b/src/progs/manaplus/actions/move.cpp
diff --git a/src/actions/pets.cpp b/src/progs/manaplus/actions/pets.cpp
index 25c5f1411..25c5f1411 100644
--- a/src/actions/pets.cpp
+++ b/src/progs/manaplus/actions/pets.cpp
diff --git a/src/actions/statusbar.cpp b/src/progs/manaplus/actions/statusbar.cpp
index 0d5ba68cd..0d5ba68cd 100644
--- a/src/actions/statusbar.cpp
+++ b/src/progs/manaplus/actions/statusbar.cpp
diff --git a/src/actions/tabs.cpp b/src/progs/manaplus/actions/tabs.cpp
index 99d964b40..99d964b40 100644
--- a/src/actions/tabs.cpp
+++ b/src/progs/manaplus/actions/tabs.cpp
diff --git a/src/actions/target.cpp b/src/progs/manaplus/actions/target.cpp
index a72cbe502..a72cbe502 100644
--- a/src/actions/target.cpp
+++ b/src/progs/manaplus/actions/target.cpp
diff --git a/src/actions/windows.cpp b/src/progs/manaplus/actions/windows.cpp
index 7c9b57d0a..7c9b57d0a 100644
--- a/src/actions/windows.cpp
+++ b/src/progs/manaplus/actions/windows.cpp
diff --git a/src/client.cpp b/src/progs/manaplus/client.cpp
index c9c1ad976..6e245029d 100644
--- a/src/client.cpp
+++ b/src/progs/manaplus/client.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "client.h"
+#include "progs/manaplus/client.h"
#include "chatlogger.h"
#include "configmanager.h"
diff --git a/src/progs/manaplus/client.h b/src/progs/manaplus/client.h
new file mode 100644
index 000000000..af537bb68
--- /dev/null
+++ b/src/progs/manaplus/client.h
@@ -0,0 +1,167 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PROGS_MANAPLUS_CLIENT_H
+#define PROGS_MANAPLUS_CLIENT_H
+
+#include "enums/state.h"
+
+#include "listeners/actionlistener.h"
+#include "listeners/configlistener.h"
+
+#include "net/serverinfo.h"
+
+#include "localconsts.h"
+
+class Button;
+class Game;
+class LoginData;
+class Skin;
+class Window;
+class QuitDialog;
+
+extern bool isSafeMode;
+extern int serverVersion;
+extern unsigned int tmwServerVersion;
+extern time_t start_time;
+extern int textures_count;
+
+extern std::string errorMessage;
+extern LoginData loginData;
+
+/**
+ * The core part of the client. This class initializes all subsystems, runs
+ * the event loop, and shuts everything down again.
+ */
+class Client final : public ConfigListener,
+ public ActionListener
+{
+ public:
+ Client();
+
+ A_DELETE_COPY(Client)
+
+ ~Client();
+
+ void gameInit();
+
+ void testsInit();
+
+ int gameExec();
+
+ static int testsExec();
+
+ void setState(const StateT state)
+ { mState = state; }
+
+ StateT getState() const noexcept2 A_WARN_UNUSED
+ { return mState; }
+
+ static bool isTmw() A_WARN_UNUSED;
+
+ void optionChanged(const std::string &name) override final;
+
+ void action(const ActionEvent &event) override final;
+
+ static void initTradeFilter();
+
+ void moveButtons(const int width);
+
+ void windowRemoved(const Window *const window);
+
+ void slowLogic();
+
+ ServerInfo &getCurrentServer()
+ { return mCurrentServer; }
+
+ private:
+ void initSoundManager();
+
+ void initConfigListeners();
+
+ static void initGraphics();
+
+ static void initFeatures();
+
+ static void initPaths();
+
+ void gameClear();
+
+ void testsClear();
+
+#ifdef ANDROID
+ static void logVars();
+#else // ANDROID
+
+ static void logVars() A_CONST;
+#endif // ANDROID
+
+ void stateConnectGame1();
+
+ void stateConnectServer1();
+
+ void stateWorldSelect1();
+
+ void stateGame1();
+
+ void stateSwitchLogin1();
+
+ void loadData();
+
+ void unloadData();
+
+ void runValidate()
+#ifndef BAD_CILKPLUS
+ __attribute__ ((noreturn))
+#endif // BAD_CILKPLUS
+;
+
+ ServerInfo mCurrentServer;
+
+ Game *mGame;
+ Window *mCurrentDialog;
+ QuitDialog *mQuitDialog;
+ Button *mSetupButton;
+ Button *mVideoButton;
+ Button *mHelpButton;
+ Button *mAboutButton;
+ Button *mThemesButton;
+ Button *mPerfomanceButton;
+#ifdef ANDROID
+ Button *mCloseButton;
+#endif // ANDROID
+
+ StateT mState;
+ StateT mOldState;
+
+ Skin *mSkin;
+ int mButtonPadding;
+ int mButtonSpacing;
+ int mPing;
+ bool mConfigAutoSaved;
+};
+
+extern Client *client;
+extern unsigned int mLastHost;
+extern unsigned long mSearchHash;
+
+#endif // PROGS_MANAPLUS_CLIENT_H
diff --git a/src/gui/viewport.cpp b/src/progs/manaplus/gui/viewport.cpp
index 5715eae3a..de7571c7c 100644
--- a/src/gui/viewport.cpp
+++ b/src/progs/manaplus/gui/viewport.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/viewport.h"
+#include "progs/manaplus/gui/viewport.h"
#include "actormanager.h"
#include "configuration.h"
diff --git a/src/progs/manaplus/gui/viewport.h b/src/progs/manaplus/gui/viewport.h
new file mode 100644
index 000000000..62982fc89
--- /dev/null
+++ b/src/progs/manaplus/gui/viewport.h
@@ -0,0 +1,249 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PROGS_MANAPLUS_GUI_VIEWPORT_H
+#define PROGS_MANAPLUS_GUI_VIEWPORT_H
+
+#include "position.h"
+
+#include "enums/simpletypes/beingid.h"
+
+#include "gui/widgets/windowcontainer.h"
+
+#include "listeners/mouselistener.h"
+
+class ActorSprite;
+class Being;
+class FloorItem;
+class Graphics;
+class Map;
+class MapItem;
+
+/**
+ * The viewport on the map. Displays the current map and handles mouse input
+ * and the popup menu.
+ */
+class Viewport final : public WindowContainer,
+ public MouseListener,
+ public ConfigListener
+{
+ public:
+ /**
+ * Constructor.
+ */
+ Viewport();
+
+ A_DELETE_COPY(Viewport)
+
+ /**
+ * Destructor.
+ */
+ ~Viewport();
+
+ /**
+ * Sets the map displayed by the viewport.
+ */
+ void setMap(Map *const map);
+
+ /**
+ * Draws the viewport.
+ */
+ void draw(Graphics *const graphics) override final A_NONNULL(2);
+
+ void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
+
+ /**
+ * Implements player to keep following mouse.
+ */
+ void logic() override final;
+
+ /**
+ * Toggles whether the path debug graphics are shown. normal,
+ * debug with all images and grid, debug with out big images
+ * and with out grid.
+ */
+ void toggleMapDrawType();
+
+ void toggleCameraMode();
+
+ /**
+ * Handles mouse press on map.
+ */
+ void mousePressed(MouseEvent &event) override final;
+
+ /**
+ * Handles mouse move on map
+ */
+ void mouseDragged(MouseEvent &event) override final;
+
+ /**
+ * Handles mouse button release on map.
+ */
+ void mouseReleased(MouseEvent &event) override final;
+
+ /**
+ * Handles mouse move on map.
+ */
+ void mouseMoved(MouseEvent &event) override final;
+
+ /**
+ * A relevant config option changed.
+ */
+ void optionChanged(const std::string &name) override final;
+
+ /**
+ * Returns camera x offset in pixels.
+ */
+ int getCameraX() const noexcept2 A_WARN_UNUSED
+ { return mPixelViewX; }
+
+ /**
+ * Returns camera y offset in pixels.
+ */
+ int getCameraY() const noexcept2 A_WARN_UNUSED
+ { return mPixelViewY; }
+
+ /**
+ * Changes viewpoint by relative pixel coordinates.
+ */
+ void scrollBy(const int x, const int y)
+ { mPixelViewX += x; mPixelViewY += y; }
+
+ /**
+ * Clear all hover item, being etc
+ */
+ void cleanHoverItems();
+
+ Map *getMap() const noexcept2 A_WARN_UNUSED
+ { return mMap; }
+
+ void moveCamera(const int dx, const int dy);
+
+ int getCameraRelativeX() const noexcept2 A_WARN_UNUSED
+ { return mCameraRelativeX; }
+
+ int getCameraRelativeY() const noexcept2 A_WARN_UNUSED
+ { return mCameraRelativeY; }
+
+ void setCameraRelativeX(const int n)
+ { mCameraRelativeX = n; updateMidVars(); }
+
+ void setCameraRelativeY(const int n)
+ { mCameraRelativeY = n; updateMidVars(); }
+
+ void moveCameraToActor(const BeingId actorId,
+ const int x = 0,
+ const int y = 0);
+
+ void moveCameraToPosition(const int x, const int y);
+
+ void moveCameraRelative(const int x, const int y);
+
+ void returnCamera();
+
+ void getMouseTile(int &destX, int &destY) const;
+
+ void videoResized();
+
+ int mMouseX; /**< Current mouse position in pixels. */
+ int mMouseY; /**< Current mouse position in pixels. */
+
+ protected:
+ friend class ActorManager;
+
+ /// Clears any matching hovers
+ void clearHover(const ActorSprite *const actor);
+
+ void updateMidVars();
+
+ void updateMaxVars();
+
+ static void validateSpeed();
+
+ private:
+ /**
+ * Finds a path from the player to the mouse, and draws it. This is for
+ * debug purposes.
+ */
+ void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
+
+ /**
+ * Draws the given path.
+ */
+ void drawPath(Graphics *const graphics,
+ const Path &path,
+ const Color &color = Color(255, 0, 0))
+ const A_NONNULL(2);
+
+ bool leftMouseAction();
+
+ bool openContextMenu(const MouseEvent &event);
+
+ void walkByMouse(const MouseEvent &event);
+
+ void getMouseTile(const int x,
+ const int y,
+ int &destX,
+ int &destY) const;
+
+ /**
+ * Make the player go to the mouse position.
+ */
+ void followMouse();
+
+ Map *mMap; /**< The current map. */
+
+ Being *mHoverBeing; /**< Being mouse is currently over. */
+ FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */
+ MapItem *mHoverSign; /**< Map sign mouse is currently over. */
+
+ int mScrollRadius;
+ int mScrollLaziness;
+ int mScrollCenterOffsetX;
+ int mScrollCenterOffsetY;
+ int mMousePressX;
+ int mMousePressY;
+ int mPixelViewX; /**< Current viewpoint in pixels. */
+ int mPixelViewY; /**< Current viewpoint in pixels. */
+ int mMidTileX;
+ int mMidTileY;
+ int mViewXmax;
+ int mViewYmax;
+
+ time_t mLocalWalkTime;
+
+ int mCameraRelativeX;
+ int mCameraRelativeY;
+
+ bool mShowBeingPopup;
+ bool mSelfMouseHeal;
+ bool mEnableLazyScrolling;
+ bool mMouseDirectionMove;
+ bool mLongMouseClick;
+ bool mAllowMoveByMouse;
+ bool mMouseClicked;
+ bool mPlayerFollowMouse;
+};
+
+extern Viewport *viewport; /**< The viewport. */
+
+#endif // PROGS_MANAPLUS_GUI_VIEWPORT_H