summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client.cpp338
-rw-r--r--src/client.h64
-rw-r--r--src/commands.cpp22
-rw-r--r--src/eventsmanager.cpp31
-rw-r--r--src/game.cpp9
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/gui/skin.cpp3
-rw-r--r--src/gui/widgets/button.cpp3
-rw-r--r--src/gui/widgets/checkbox.cpp3
-rw-r--r--src/gui/widgets/desktop.cpp2
-rw-r--r--src/gui/widgets/desktop.h2
-rw-r--r--src/gui/widgets/dropdown.cpp3
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/guitable.cpp5
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/listbox.cpp3
-rw-r--r--src/gui/widgets/playerbox.cpp5
-rw-r--r--src/gui/widgets/progressbar.cpp3
-rw-r--r--src/gui/widgets/radiobutton.cpp3
-rw-r--r--src/gui/widgets/scrollarea.cpp3
-rw-r--r--src/gui/widgets/shoplistbox.cpp5
-rw-r--r--src/gui/widgets/slider.cpp3
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/tabs/chattab.cpp9
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp6
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp6
-rw-r--r--src/gui/widgets/tabs/tab.cpp3
-rw-r--r--src/gui/widgets/textfield.cpp3
-rw-r--r--src/gui/widgets/textpreview.cpp5
-rw-r--r--src/gui/widgets/window.cpp1
-rw-r--r--src/gui/windowmanager.cpp405
-rw-r--r--src/gui/windowmanager.h81
-rw-r--r--src/gui/windows/minimap.cpp3
-rw-r--r--src/gui/windows/serverdialog.cpp6
-rw-r--r--src/input/joystick.cpp7
-rw-r--r--src/settings.h10
39 files changed, 678 insertions, 413 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8e8de9371..0607b5de3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -467,6 +467,8 @@ SET(SRCS
gui/userpalette.h
gui/viewport.cpp
gui/viewport.h
+ gui/windowmanager.cpp
+ gui/windowmanager.h
gui/windows/whoisonline.cpp
gui/windows/whoisonline.h
gui/windowmenu.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 842b0e17d..94eb513ce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -587,6 +587,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/userpalette.h \
gui/viewport.cpp \
gui/viewport.h \
+ gui/windowmanager.cpp \
+ gui/windowmanager.h \
gui/windows/whoisonline.cpp \
gui/windows/whoisonline.h \
gui/windowmenu.cpp \
diff --git a/src/client.cpp b/src/client.cpp
index 86369030a..03c13a8cf 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -57,6 +57,7 @@
#include "gui/gui.h"
#include "gui/skin.h"
#include "gui/theme.h"
+#include "gui/windowmanager.h"
#include "gui/windows/buyselldialog.h"
#include "gui/windows/buydialog.h"
@@ -173,6 +174,8 @@ LoginData loginData;
Client *client = nullptr;
+extern FPSmanager fpsManager;
+
volatile bool runCounters;
bool isSafeMode = false;
int serverVersion = 0;
@@ -209,7 +212,6 @@ Client::Client() :
mGame(nullptr),
mCurrentDialog(nullptr),
mQuitDialog(nullptr),
- mDesktop(nullptr),
mSetupButton(nullptr),
mVideoButton(nullptr),
mHelpButton(nullptr),
@@ -221,25 +223,12 @@ Client::Client() :
#endif
mState(STATE_CHOOSE_SERVER),
mOldState(STATE_START),
- mIcon(nullptr),
- mFpsManager(),
mSkin(nullptr),
- mGuiAlpha(1.0F),
mButtonPadding(1),
mButtonSpacing(3),
- mKeyboardHeight(0),
- mLimitFps(false),
- mConfigAutoSaved(false),
- mIsMinimized(false),
- mInputFocused(true),
- mMouseFocused(true),
- mNewMessageFlag(false)
+ mConfigAutoSaved(false)
{
- // Initialize frame limiting
- mFpsManager.framecount = 0;
- mFpsManager.rateticks = 0;
- mFpsManager.lastticks = 0;
- mFpsManager.rate = 0;
+ WindowManager::init();
}
void Client::testsInit()
@@ -333,7 +322,7 @@ void Client::gameInit()
#ifndef USE_SDL2
SDL_EnableUNICODE(1);
#endif
- applyKeyRepeat();
+ WindowManager::applyKeyRepeat();
// disable unused SDL events
#ifndef USE_SDL2
@@ -347,7 +336,7 @@ void Client::gameInit()
Dirs::mountDataDir();
#endif
- setIcon();
+ WindowManager::setIcon();
ConfigManager::checkConfigVersion();
logVars();
Cpu::detect();
@@ -378,7 +367,7 @@ void Client::gameInit()
resman->addToSearchPath(settings.localDataDir, false);
TranslationManager::loadCurrentLang();
- initTitle();
+ WindowManager::initTitle();
theme = new Theme;
Theme::selectSkin();
@@ -403,7 +392,7 @@ void Client::gameInit()
// Initialise player relations
player_relations.init();
Joystick::init();
- createWindows();
+ WindowManager::createWindows();
keyboard.update();
if (joystick)
@@ -444,13 +433,13 @@ void Client::gameInit()
startTimers();
const int fpsLimit = config.getIntValue("fpslimit");
- mLimitFps = fpsLimit > 0;
+ settings.limitFps = fpsLimit > 0;
- SDL_initFramerate(&mFpsManager);
- setFramerate(fpsLimit);
+ SDL_initFramerate(&fpsManager);
+ WindowManager::setFramerate(fpsLimit);
initConfigListeners();
- setGuiAlpha(config.getFloatValue("guialpha"));
+ settings.guiAlpha = config.getFloatValue("guialpha");
optionChanged("fpslimit");
start_time = static_cast<int>(time(nullptr));
@@ -507,16 +496,6 @@ void Client::initSoundManager()
"loginMusic", "Magick - Real.ogg"));
}
-void Client::createWindows()
-{
- userPalette = new UserPalette;
- setupWindow = new SetupWindow;
- setupWindow->postInit();
- helpWindow = new HelpWindow;
- didYouKnowWindow = new DidYouKnowWindow;
- didYouKnowWindow->postInit();
-}
-
void Client::updateEnv()
{
#if defined(WIN32) || defined(__APPLE__)
@@ -537,37 +516,15 @@ void Client::initGraphics()
graphicsManager.initGraphics(settings.options.noOpenGL);
runCounters = config.getBoolValue("packetcounters");
- applyVSync();
+ WindowManager::applyVSync();
graphicsManager.setVideoMode();
getConfigDefaults2(config.getDefaultValues());
- applyGrabMode();
- applyGamma();
+ WindowManager::applyGrabMode();
+ WindowManager::applyGamma();
mainGraphics->beginDraw();
}
-void Client::initTitle()
-{
- if (settings.options.test.empty())
- {
- settings.windowCaption = strprintf("%s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION);
- }
- else
- {
- settings.windowCaption = strprintf(
- "Please wait - VIDEO MODE TEST - %s %s - Please wait",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION);
- }
-
- SDL::SetWindowTitle(mainGraphics->getWindow(), settings.windowCaption.c_str());
-#ifndef WIN32
- setIcon();
-#endif
-}
-
#ifdef ANDROID
#ifdef USE_SDL2
static void updateProgress(int cnt)
@@ -705,7 +662,7 @@ void Client::gameClear()
if (logger)
logger->log1("Quitting8");
- MSDL_FreeSurface(mIcon);
+ WindowManager::deleteIcon();
if (logger)
logger->log1("Quitting9");
@@ -826,7 +783,7 @@ int Client::gameExec()
lastTickTime = tick_time;
// Update the screen when application is visible, delay otherwise.
- if (!mIsMinimized)
+ if (!WindowManager::getIsMinimized())
{
frame_count++;
if (gui)
@@ -839,8 +796,8 @@ int Client::gameExec()
}
BLOCK_START("~Client::SDL_framerateDelay")
- if (mLimitFps)
- SDL_framerateDelay(&mFpsManager);
+ if (settings.limitFps)
+ SDL_framerateDelay(&fpsManager);
BLOCK_END("~Client::SDL_framerateDelay")
BLOCK_START("Client::gameExec 6")
@@ -935,34 +892,34 @@ int Client::gameExec()
if (!top)
break;
- mDesktop = new Desktop(nullptr);
- mDesktop->postInit();
- top->add(mDesktop);
+ desktop = new Desktop(nullptr);
+ desktop->postInit();
+ top->add(desktop);
int x = top->getWidth() - mButtonPadding;
- ADDBUTTON(mSetupButton, new Button(mDesktop,
+ ADDBUTTON(mSetupButton, new Button(desktop,
// TRANSLATORS: setup tab quick button
_("Setup"), "Setup", this))
- ADDBUTTON(mPerfomanceButton, new Button(mDesktop,
+ ADDBUTTON(mPerfomanceButton, new Button(desktop,
// TRANSLATORS: perfoamance tab quick button
_("Performance"), "Perfomance", this))
- ADDBUTTON(mVideoButton, new Button(mDesktop,
+ ADDBUTTON(mVideoButton, new Button(desktop,
// TRANSLATORS: video tab quick button
_("Video"), "Video", this))
- ADDBUTTON(mThemesButton, new Button(mDesktop,
+ ADDBUTTON(mThemesButton, new Button(desktop,
// TRANSLATORS: theme tab quick button
_("Theme"), "Themes", this))
- ADDBUTTON(mAboutButton, new Button(mDesktop,
+ ADDBUTTON(mAboutButton, new Button(desktop,
// TRANSLATORS: theme tab quick button
_("About"), "about", this))
- ADDBUTTON(mHelpButton, new Button(mDesktop,
+ ADDBUTTON(mHelpButton, new Button(desktop,
// TRANSLATORS: theme tab quick button
_("Help"), "help", this))
#ifdef ANDROID
- ADDBUTTON(mCloseButton, new Button(mDesktop,
+ ADDBUTTON(mCloseButton, new Button(desktop,
// TRANSLATORS: close quick button
_("Close"), "close", this))
#endif
- mDesktop->setSize(mainGraphics->getWidth(),
+ desktop->setSize(mainGraphics->getWidth(),
mainGraphics->getHeight());
}
BLOCK_END("Client::gameExec 6")
@@ -1285,8 +1242,8 @@ int Client::gameExec()
ActorSprite::load();
- if (mDesktop)
- mDesktop->reloadWallpaper();
+ if (desktop)
+ desktop->reloadWallpaper();
mState = STATE_GET_CHARACTERS;
BLOCK_END("Client::gameExec STATE_LOAD_DATA")
@@ -1389,7 +1346,7 @@ int Client::gameExec()
delete2(mAboutButton);
delete2(mHelpButton);
delete2(mPerfomanceButton);
- delete2(mDesktop);
+ delete2(desktop);
mCurrentDialog = nullptr;
@@ -1631,18 +1588,18 @@ void Client::optionChanged(const std::string &name)
if (name == "fpslimit")
{
const int fpsLimit = config.getIntValue("fpslimit");
- mLimitFps = fpsLimit > 0;
- setFramerate(fpsLimit);
+ settings.limitFps = fpsLimit > 0;
+ WindowManager::setFramerate(fpsLimit);
}
else if (name == "guialpha")
{
const float alpha = config.getFloatValue("guialpha");
- setGuiAlpha(alpha);
+ settings.guiAlpha = alpha;
ImageHelper::setEnableAlpha(alpha != 1.0F);
}
else if (name == "gamma" || name == "enableGamma")
{
- applyGamma();
+ WindowManager::applyGamma();
}
else if (name == "particleEmitterSkip")
{
@@ -1650,11 +1607,11 @@ void Client::optionChanged(const std::string &name)
}
else if (name == "vsync")
{
- applyVSync();
+ WindowManager::applyVSync();
}
else if (name == "repeateInterval" || name == "repeateDelay")
{
- applyKeyRepeat();
+ WindowManager::applyKeyRepeat();
}
}
@@ -1750,25 +1707,6 @@ void Client::initTradeFilter() const
}
}
-void Client::setFramerate(const int fpsLimit) const
-{
- if (!fpsLimit)
- return;
-
- if (!mLimitFps)
- return;
-
- SDL_setFramerate(&client->mFpsManager, fpsLimit);
-}
-
-int Client::getFramerate() const
-{
- if (!mLimitFps)
- return 0;
-
- return SDL_getFramerate(&client->mFpsManager);
-}
-
bool Client::isTmw() const
{
const std::string &name = settings.serverName;
@@ -1781,134 +1719,39 @@ bool Client::isTmw() const
return false;
}
-void Client::resizeVideo(int actualWidth,
- int actualHeight,
- const bool always)
+void Client::moveButtons(const int width)
{
- // Keep a minimum size. This isn't adhered to by the actual window, but
- // it keeps some window positions from getting messed up.
- actualWidth = std::max(470, actualWidth);
- actualHeight = std::max(320, actualHeight);
-
- if (!mainGraphics)
- return;
- if (!always
- && mainGraphics->mActualWidth == actualWidth
- && mainGraphics->mActualHeight == actualHeight)
+ if (mSetupButton)
{
- return;
- }
-
- if (mainGraphics->resizeScreen(actualWidth, actualHeight))
- {
- const int width = mainGraphics->mWidth;
- const int height = mainGraphics->mHeight;
- touchManager.resize(width, height);
-
- if (gui)
- gui->videoResized();
-
- if (mDesktop)
- mDesktop->setSize(width, height);
-
- if (mSetupButton)
- {
- int x = width - mSetupButton->getWidth() - mButtonPadding;
- mSetupButton->setPosition(x, mButtonPadding);
+ int x = width - mSetupButton->getWidth() - mButtonPadding;
+ mSetupButton->setPosition(x, mButtonPadding);
#ifndef WIN32
- x -= mPerfomanceButton->getWidth() + mButtonSpacing;
- mPerfomanceButton->setPosition(x, mButtonPadding);
+ x -= mPerfomanceButton->getWidth() + mButtonSpacing;
+ mPerfomanceButton->setPosition(x, mButtonPadding);
- x -= mVideoButton->getWidth() + mButtonSpacing;
- mVideoButton->setPosition(x, mButtonPadding);
+ x -= mVideoButton->getWidth() + mButtonSpacing;
+ mVideoButton->setPosition(x, mButtonPadding);
- x -= mThemesButton->getWidth() + mButtonSpacing;
- mThemesButton->setPosition(x, mButtonPadding);
+ x -= mThemesButton->getWidth() + mButtonSpacing;
+ mThemesButton->setPosition(x, mButtonPadding);
- x -= mAboutButton->getWidth() + mButtonSpacing;
- mAboutButton->setPosition(x, mButtonPadding);
+ x -= mAboutButton->getWidth() + mButtonSpacing;
+ mAboutButton->setPosition(x, mButtonPadding);
- x -= mHelpButton->getWidth() + mButtonSpacing;
- mHelpButton->setPosition(x, mButtonPadding);
+ x -= mHelpButton->getWidth() + mButtonSpacing;
+ mHelpButton->setPosition(x, mButtonPadding);
#ifdef ANDROID
- x -= mCloseButton->getWidth() + mButtonSpacing;
- mCloseButton->setPosition(x, mButtonPadding);
+ x -= mCloseButton->getWidth() + mButtonSpacing;
+ mCloseButton->setPosition(x, mButtonPadding);
#endif
#endif
- }
-
- if (mGame)
- mGame->videoResized(width, height);
-
- if (gui)
- gui->draw();
-
- config.setValue("screenwidth", actualWidth);
- config.setValue("screenheight", actualHeight);
}
}
-void Client::applyGrabMode()
-{
- SDL::grabInput(mainGraphics->getWindow(),
- config.getBoolValue("grabinput"));
-}
-
-void Client::applyGamma()
-{
- if (config.getFloatValue("enableGamma"))
- {
- SDL::setGamma(mainGraphics->getWindow(),
- config.getFloatValue("gamma"));
- }
-}
-
-void Client::applyVSync()
-{
- const int val = config.getIntValue("vsync");
- if (val > 0 && val < 2)
- SDL::setVsync(val);
-}
-
-void Client::applyKeyRepeat()
-{
-#ifndef USE_SDL2
- SDL_EnableKeyRepeat(config.getIntValue("repeateDelay"),
- config.getIntValue("repeateInterval"));
-#endif
-}
-
-void Client::applyScale()
-{
- const int scale = config.getIntValue("scale");
- if (mainGraphics->getScale() == scale)
- return;
- mainGraphics->setScale(scale);
- resizeVideo(mainGraphics->mActualWidth,
- mainGraphics->mActualHeight,
- true);
-}
-
-void Client::setIsMinimized(const bool n)
-{
- mIsMinimized = n;
- if (!n && mNewMessageFlag)
- {
- mNewMessageFlag = false;
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- settings.windowCaption.c_str());
- }
-}
-
-void Client::newChatMessage()
+void Client::windowRemoved(const Window *const window)
{
- if (!mNewMessageFlag && mIsMinimized)
- {
- // show * on window caption
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- ("*" + settings.windowCaption).c_str());
- mNewMessageFlag = true;
- }
+ if (mCurrentDialog == window)
+ mCurrentDialog = nullptr;
}
void Client::logVars()
@@ -1919,69 +1762,6 @@ void Client::logVars()
#endif
}
-void Client::windowRemoved(const Window *const window)
-{
- if (mCurrentDialog == window)
- mCurrentDialog = nullptr;
-}
-
-void Client::setIcon()
-{
- std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
-#ifdef WIN32
- iconFile.append(".ico");
-#else
- iconFile.append(".png");
-#endif
- iconFile = Files::getPath(iconFile);
- logger->log("Loading icon from file: %s", iconFile.c_str());
-
-#ifdef WIN32
- static SDL_SysWMinfo pInfo;
- if (mainGraphics)
- SDL::getWindowWMInfo(mainGraphics->getWindow(), &pInfo);
- else
- SDL::getWindowWMInfo(nullptr, &pInfo);
- // Attempt to load icon from .ico file
- HICON icon = (HICON) LoadImage(nullptr, iconFile.c_str(),
- IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
- // If it's failing, we load the default resource file.
- if (!icon)
- {
- logger->log("icon load error");
- icon = LoadIcon(GetModuleHandle(nullptr), "A");
- }
- if (icon)
- SetClassLong(pInfo.window, GCL_HICON, reinterpret_cast<LONG>(icon));
-#else
- mIcon = MIMG_Load(iconFile.c_str());
- if (mIcon)
- {
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
-#else
- SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
-#endif
- SDL::SetWindowIcon(mainGraphics->getWindow(), mIcon);
- }
-#endif
-}
-
-bool Client::isKeyboardVisible() const
-{
-#ifdef USE_SDL2
- return SDL_IsTextInputActive();
-#else
- return mKeyboardHeight > 1;
-#endif
-}
-
-void Client::reloadWallpaper()
-{
- if (mDesktop)
- mDesktop->reloadWallpaper();
-}
-
#ifdef ANDROID
#ifdef USE_SDL2
void Client::extractAssets()
diff --git a/src/client.h b/src/client.h
index 96ca7d2c8..10542a29c 100644
--- a/src/client.h
+++ b/src/client.h
@@ -89,69 +89,19 @@ public:
State getState() const A_WARN_UNUSED
{ return mState; }
- bool getIsMinimized() const A_WARN_UNUSED
- { return mIsMinimized; }
-
- void setIsMinimized(const bool n);
-
- void newChatMessage();
-
- bool getInputFocused() const A_WARN_UNUSED
- { return mInputFocused; }
-
- void setInputFocused(const bool n)
- { mInputFocused = n; }
-
- bool getMouseFocused() const A_WARN_UNUSED
- { return mMouseFocused; }
-
- void setMouseFocused(const bool n)
- { mMouseFocused = n; }
-
- bool isKeyboardVisible() const;
-
- void setGuiAlpha(const float n)
- { mGuiAlpha = n; }
-
- float getGuiAlpha() const A_WARN_UNUSED
- { return mGuiAlpha; }
-
- void setFramerate(const int fpsLimit) const;
-
- int getFramerate() const A_WARN_UNUSED;
-
bool isTmw() const A_WARN_UNUSED;
- static void applyGrabMode();
-
- static void applyGamma();
-
- static void applyVSync();
-
- static void applyKeyRepeat();
-
void optionChanged(const std::string &name) override final;
void action(const ActionEvent &event) override final;
void initTradeFilter() const;
- void resizeVideo(int actualWidth,
- int actualHeight,
- const bool always);
-
- void applyScale();
+ void moveButtons(const int width);
void windowRemoved(const Window *const window);
- void updateScreenKeyboard(const int height)
- { mKeyboardHeight = height; }
-
- void reloadWallpaper();
-
private:
- static void createWindows();
-
void initSoundManager();
void initConfigListeners();
@@ -160,8 +110,6 @@ private:
void updateEnv();
- void initTitle();
-
static void initFeatures();
void gameClear();
@@ -170,8 +118,6 @@ private:
static void logVars();
- void setIcon();
-
static void setEnv(const char *const name, const char *const value);
#ifdef ANDROID
@@ -199,20 +145,12 @@ private:
State mState;
State mOldState;
- SDL_Surface *mIcon;
-
- FPSmanager mFpsManager;
Skin *mSkin;
float mGuiAlpha;
int mButtonPadding;
int mButtonSpacing;
int mKeyboardHeight;
- bool mLimitFps;
bool mConfigAutoSaved;
- bool mIsMinimized;
- bool mInputFocused;
- bool mMouseFocused;
- bool mNewMessageFlag;
};
extern Client *client;
diff --git a/src/commands.cpp b/src/commands.cpp
index 46efeffbd..0db774ada 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1099,17 +1099,17 @@ impHandler2(dumpGraphics)
str.append(",0");
#endif
- str.append(strprintf(",%f,", static_cast<double>(client->getGuiAlpha())))
- .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
- .append(config.getBoolValue("alphaCache") ? "1" : "0")
- .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
- .append(config.getBoolValue("beingopacity") ? "1" : "0")
- .append(",")
- .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
- .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
- .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
- .append(config.getBoolValue("particleeffects") ? "1" : "0")
- .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
+ str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
+ .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
+ .append(config.getBoolValue("alphaCache") ? "1" : "0")
+ .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
+ .append(config.getBoolValue("beingopacity") ? "1" : "0")
+ .append(",")
+ .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
+ .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
+ .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
+ .append(config.getBoolValue("particleeffects") ? "1" : "0")
+ .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
outStringNormal(tab, str, str);
}
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index 9ae04d308..fb5ab6d36 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -28,6 +28,9 @@
#endif
#include "logger.h"
#include "mumblemanager.h"
+#include "settings.h"
+
+#include "gui/windowmanager.h"
#include "being/localplayer.h"
@@ -77,7 +80,9 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event) const
return true;
#else
case SDL_VIDEORESIZE:
- client->resizeVideo(event.resize.w, event.resize.h, false);
+ WindowManager::resizeVideo(event.resize.w,
+ event.resize.h,
+ false);
return true;
case SDL_ACTIVEEVENT:
handleActive(event);
@@ -404,22 +409,24 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
switch (eventType)
{
case SDL_WINDOWEVENT_RESIZED:
- client->resizeVideo(event.window.data1, event.window.data2, false);
+ WindowManager::resizeVideo(event.window.data1,
+ event.window.data2,
+ false);
break;
case SDL_WINDOWEVENT_ENTER:
- client->setMouseFocused(true);
+ settings.mouseFocused = true;
break;
case SDL_WINDOWEVENT_LEAVE:
- client->setMouseFocused(false);
+ settings.mouseFocused = false;
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
- client->setInputFocused(true);
+ settings.inputFocused = true;
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
- client->setInputFocused(false);
+ settings.inputFocused = false;
break;
case SDL_WINDOWEVENT_MINIMIZED:
- client->setIsMinimized(true);
+ WindowManager::setIsMinimized(true);
if (inGame)
{
if (player_node && !player_node->getAway())
@@ -432,7 +439,7 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
break;
case SDL_WINDOWEVENT_RESTORED:
case SDL_WINDOWEVENT_MAXIMIZED:
- client->setIsMinimized(false);
+ WindowManager::setIsMinimized(false);
if (inGame)
{
if (player_node)
@@ -472,7 +479,7 @@ void EventsManager::handleActive(const SDL_Event &event)
{
if (event.active.gain)
{ // window restore
- client->setIsMinimized(false);
+ WindowManager::setIsMinimized(false);
if (inGame && player_node)
{
if (!player_node->getAway())
@@ -486,7 +493,7 @@ void EventsManager::handleActive(const SDL_Event &event)
#ifdef ANDROID
client->setState(STATE_EXIT);
#else
- client->setIsMinimized(true);
+ WindowManager::setIsMinimized(true);
if (inGame && player_node && !player_node->getAway())
{
fpsLimit = config.getIntValue("altfpslimit");
@@ -502,9 +509,9 @@ void EventsManager::handleActive(const SDL_Event &event)
player_node->updateName();
if (event.active.state & SDL_APPINPUTFOCUS)
- client->setInputFocused(event.active.gain);
+ settings.inputFocused = event.active.gain;
if (event.active.state & SDL_APPMOUSEFOCUS)
- client->setMouseFocused(event.active.gain);
+ settings.mouseFocused = event.active.gain;
if (inGame)
Game::instance()->updateFrameRate(fpsLimit);
}
diff --git a/src/game.cpp b/src/game.cpp
index addc55ad3..20939a82c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -53,6 +53,7 @@
#include "gui/dialogsmanager.h"
#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/windowmanager.h"
#include "gui/windowmenu.h"
#include "gui/fonts/font.h"
@@ -644,7 +645,7 @@ void Game::slowLogic()
}
}
DialogsManager::closeDialogs();
- client->setFramerate(config.getIntValue("fpslimit"));
+ WindowManager::setFramerate(config.getIntValue("fpslimit"));
mNextAdjustTime = cur_time + adjustDelay;
if (client->getState() != STATE_ERROR)
errorMessage.clear();
@@ -687,7 +688,7 @@ void Game::adjustPerfomance()
return;
}
- int maxFps = client->getFramerate();
+ int maxFps = WindowManager::getFramerate();
if (maxFps != config.getIntValue("fpslimit"))
return;
@@ -895,7 +896,7 @@ void Game::updateFrameRate(int fpsLimit)
{
if (player_node && player_node->getAway())
{
- if (client->getInputFocused() || client->getMouseFocused())
+ if (settings.inputFocused || settings.mouseFocused)
fpsLimit = config.getIntValue("fpslimit");
else
fpsLimit = config.getIntValue("altfpslimit");
@@ -905,7 +906,7 @@ void Game::updateFrameRate(int fpsLimit)
fpsLimit = config.getIntValue("fpslimit");
}
}
- client->setFramerate(fpsLimit);
+ WindowManager::setFramerate(fpsLimit);
mNextAdjustTime = cur_time + adjustDelay;
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index c7d7fd8a1..52abd30b6 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -70,6 +70,7 @@
#include "gui/sdlinput.h"
#include "gui/theme.h"
#include "gui/viewport.h"
+#include "gui/windowmanager.h"
#include "gui/fonts/font.h"
@@ -78,6 +79,7 @@
#include "client.h"
#include "configuration.h"
#include "dragdrop.h"
+#include "settings.h"
#include "touchmanager.h"
#include "events/keyevent.h"
@@ -463,7 +465,7 @@ void Gui::draw()
int mouseY;
const MouseStateType button = getMouseState(&mouseX, &mouseY);
- if ((client->getMouseFocused() || button & SDL_BUTTON(1))
+ if ((settings.mouseFocused || button & SDL_BUTTON(1))
&& mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
{
const Image *const image = dragDrop.getItemImage();
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index 626f1b53f..46f790882 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -25,6 +25,7 @@
#include "gui/skin.h"
#include "client.h"
+#include "settings.h"
#include "resources/image.h"
#include "resources/imagerect.h"
@@ -101,7 +102,7 @@ void Skin::updateAlpha(const float minimumOpacityAllowed)
{
const float alpha = static_cast<float>(
std::max(static_cast<double>(minimumOpacityAllowed),
- static_cast<double>(client->getGuiAlpha())));
+ static_cast<double>(settings.guiAlpha)));
if (mBorder)
{
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index f9ea17516..e67f77056 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -67,6 +67,7 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "events/keyevent.h"
@@ -414,7 +415,7 @@ void Button::loadImageSet(const std::string &imageName)
void Button::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 86ebefd60..508bfead4 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -66,6 +66,7 @@
#include "gui/widgets/checkbox.h"
#include "client.h"
+#include "settings.h"
#include "input/inputaction.h"
@@ -165,7 +166,7 @@ void CheckBox::draw(Graphics *const graphics)
void CheckBox::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index bdda1a09f..c383bb8a2 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -39,6 +39,8 @@
#include "debug.h"
+Desktop *desktop = nullptr;
+
Desktop::Desktop(const Widget2 *const widget) :
Container(widget),
LinkHandler(),
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index b7b61d040..20bcb241f 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -82,4 +82,6 @@ class Desktop final : public Container,
bool mShowBackground;
};
+extern Desktop *desktop;
+
#endif // GUI_WIDGETS_DESKTOP_H
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 86e79b504..ab6b0dab0 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/dropdown.h"
#include "client.h"
+#include "settings.h"
#include "events/keyevent.h"
@@ -191,7 +192,7 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 6e4e0d90c..150c94f77 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "dragdrop.h"
#include "dropshortcut.h"
+#include "settings.h"
#include "being/playerinfo.h"
@@ -65,7 +66,7 @@ DropShortcutContainer::DropShortcutContainer(Widget2 *const widget) :
if (mBackgroundImg)
{
- mBackgroundImg->setAlpha(client->getGuiAlpha());
+ mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
}
@@ -101,9 +102,9 @@ void DropShortcutContainer::draw(Graphics *graphics)
return;
BLOCK_START("DropShortcutContainer::draw")
- if (client->getGuiAlpha() != mAlpha)
+ if (settings.guiAlpha != mAlpha)
{
- mAlpha = client->getGuiAlpha();
+ mAlpha = settings.guiAlpha;
if (mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 0f0fa2c1d..6c6c82b43 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -24,6 +24,7 @@
#include "animatedsprite.h"
#include "client.h"
#include "emoteshortcut.h"
+#include "settings.h"
#include "input/inputmanager.h"
@@ -59,7 +60,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *const widget) :
"item_shortcut_background.xml", "background.xml");
if (mBackgroundImg)
- mBackgroundImg->setAlpha(client->getGuiAlpha());
+ mBackgroundImg->setAlpha(settings.guiAlpha);
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
@@ -108,11 +109,11 @@ void EmoteShortcutContainer::draw(Graphics *graphics)
return;
BLOCK_START("EmoteShortcutContainer::draw")
- if (client->getGuiAlpha() != mAlpha)
+ if (settings.guiAlpha != mAlpha)
{
if (mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
- mAlpha = client->getGuiAlpha();
+ mAlpha = settings.guiAlpha;
}
Font *const font = getFont();
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 5374e8a7c..c3725b46f 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/guitable.h"
#include "client.h"
+#include "settings.h"
#include "gui/gui.h"
@@ -247,8 +248,8 @@ void GuiTable::draw(Graphics* graphics)
return;
BLOCK_START("GuiTable::draw")
- if (client->getGuiAlpha() != mAlpha)
- mAlpha = client->getGuiAlpha();
+ if (settings.guiAlpha != mAlpha)
+ mAlpha = settings.guiAlpha;
const Rect &rect = mDimension;
const int width = rect.width;
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 4cf0e76f7..e7e2455bb 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -27,6 +27,7 @@
#include "inventory.h"
#include "item.h"
#include "itemshortcut.h"
+#include "settings.h"
#include "spellshortcut.h"
#include "being/playerinfo.h"
@@ -80,7 +81,7 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
if (mBackgroundImg)
{
- mBackgroundImg->setAlpha(client->getGuiAlpha());
+ mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
}
@@ -124,11 +125,11 @@ void ItemShortcutContainer::draw(Graphics *graphics)
return;
}
- if (client->getGuiAlpha() != mAlpha)
+ if (settings.guiAlpha != mAlpha)
{
if (mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
- mAlpha = client->getGuiAlpha();
+ mAlpha = settings.guiAlpha;
}
Font *const font = getFont();
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 87a9f43cc..8953fc5e2 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -66,6 +66,7 @@
#include "gui/widgets/listbox.h"
#include "client.h"
+#include "settings.h"
#include "input/inputaction.h"
@@ -145,7 +146,7 @@ ListBox::~ListBox()
void ListBox::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index b7b5c8134..b77b1bc42 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/playerbox.h"
#include "client.h"
+#include "settings.h"
#include "being/being.h"
@@ -126,9 +127,9 @@ void PlayerBox::draw(Graphics *graphics)
mBeing->drawSpriteAt(graphics, x, y);
}
- if (client->getGuiAlpha() != mAlpha)
+ if (settings.guiAlpha != mAlpha)
{
- const float alpha = client->getGuiAlpha();
+ const float alpha = settings.guiAlpha;
for (int a = 0; a < 9; a++)
{
if (mBackground.grid[a])
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index b9675af7f..68db6ee1d 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -24,6 +24,7 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "gui/gui.h"
#include "gui/skin.h"
@@ -141,7 +142,7 @@ void ProgressBar::logic()
void ProgressBar::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
mAlpha = alpha;
}
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 9074a8a0c..e0d031908 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -66,6 +66,7 @@
#include "gui/widgets/radiobutton.h"
#include "client.h"
+#include "settings.h"
#include "input/inputaction.h"
@@ -152,7 +153,7 @@ RadioButton::~RadioButton()
void RadioButton::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index ca29c09fa..d439765af 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -67,6 +67,7 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "gui/gui.h"
#include "gui/skin.h"
@@ -288,7 +289,7 @@ void ScrollArea::logic()
void ScrollArea::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (alpha != mAlpha)
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index c259d187f..cd250d274 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/shoplistbox.h"
#include "client.h"
+#include "settings.h"
#include "shopitem.h"
#include "being/playerinfo.h"
@@ -92,8 +93,8 @@ void ShopListBox::draw(Graphics *graphics)
return;
}
- if (client->getGuiAlpha() != mAlpha)
- mAlpha = client->getGuiAlpha();
+ if (settings.guiAlpha != mAlpha)
+ mAlpha = settings.guiAlpha;
const int alpha = static_cast<int>(mAlpha * 255.0F);
Font *const font = getFont();
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c660648d8..444480ae1 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -67,6 +67,7 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "events/keyevent.h"
@@ -172,7 +173,7 @@ void Slider::init()
void Slider::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (alpha != mAlpha)
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 4a4a5beb5..1b3355265 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "dragdrop.h"
#include "itemshortcut.h"
+#include "settings.h"
#include "spellshortcut.h"
#include "gui/viewport.h"
@@ -64,7 +65,7 @@ SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
if (mBackgroundImg)
{
- mBackgroundImg->setAlpha(client->getGuiAlpha());
+ mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
}
@@ -97,9 +98,9 @@ void SpellShortcutContainer::draw(Graphics *graphics)
return;
BLOCK_START("SpellShortcutContainer::draw")
- if (client->getGuiAlpha() != mAlpha)
+ if (settings.guiAlpha != mAlpha)
{
- mAlpha = client->getGuiAlpha();
+ mAlpha = settings.guiAlpha;
if (mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp
index 893149a98..36e4b5437 100644
--- a/src/gui/widgets/tabs/chattab.cpp
+++ b/src/gui/widgets/tabs/chattab.cpp
@@ -27,12 +27,14 @@
#include "commands.h"
#include "commandhandler.h"
#include "configuration.h"
+#include "settings.h"
#include "soundconsts.h"
#include "soundmanager.h"
#include "being/localplayer.h"
#include "gui/chatlog.h"
+#include "gui/windowmanager.h"
#include "gui/windows/chatwindow.h"
#include "gui/windows/helpwindow.h"
@@ -320,8 +322,9 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own,
if ((getAllowHighlight() || own == ChatMsgType::BY_GM)
&& (this != tabArea->getSelectedTab()
- || (client->getIsMinimized() || (!client->getMouseFocused()
- && !client->getInputFocused()))))
+ || (WindowManager::getIsMinimized()
+ || (!settings.mouseFocused
+ && !settings.inputFocused))))
{
if (own == ChatMsgType::BY_GM)
{
@@ -335,7 +338,7 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own,
chatWindow->unHideWindow();
playNewMessageSound();
}
- client->newChatMessage();
+ WindowManager::newChatMessage();
}
}
}
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 439765260..54b17396a 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -27,6 +27,8 @@
#include "graphicsmanager.h"
+#include "gui/windowmanager.h"
+
#include "gui/windows/okdialog.h"
#include "gui/windows/textdialog.h"
@@ -360,7 +362,7 @@ void Setup_Video::action(const ActionEvent &event)
if (intToRenderType(config.getIntValue("opengl"))
== RENDER_SOFTWARE)
{
- client->resizeVideo(width, height, false);
+ WindowManager::resizeVideo(width, height, false);
}
else
{
@@ -385,7 +387,7 @@ void Setup_Video::action(const ActionEvent &event)
}
#else
mainGraphics->setWindowSize(width, height);
- client->resizeVideo(width, height, false);
+ WindowManager::resizeVideo(width, height, false);
#endif
}
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index d9f3ec4cf..e90008ac1 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -21,6 +21,8 @@
#include "gui/widgets/tabs/setup_visual.h"
+#include "gui/windowmanager.h"
+
#include "gui/models/namesmodel.h"
#include "gui/widgets/containerplacer.h"
@@ -228,8 +230,8 @@ Setup_Visual::~Setup_Visual()
void Setup_Visual::apply()
{
SetupTabScroll::apply();
- Client::applyGrabMode();
+ WindowManager::applyGrabMode();
#ifndef WIN32
- client->applyScale();
+ WindowManager::applyScale();
#endif
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 2ad0e8ac8..73c38343b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -67,6 +67,7 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "gui/gui.h"
#include "gui/skin.h"
@@ -178,7 +179,7 @@ void Tab::init()
void Tab::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (alpha != mAlpha)
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index dc8b107c4..0eb16867a 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -66,6 +66,7 @@
#include "gui/widgets/textfield.h"
#include "client.h"
+#include "settings.h"
#include "input/inputmanager.h"
@@ -173,7 +174,7 @@ TextField::~TextField()
void TextField::updateAlpha()
{
- const float alpha = std::max(client->getGuiAlpha(),
+ const float alpha = std::max(settings.guiAlpha,
theme->getMinimumOpacity());
if (alpha != mAlpha)
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index e215d21b3..febd1b6ba 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/textpreview.h"
#include "client.h"
+#include "settings.h"
#include "gui/gui.h"
#include "gui/skin.h"
@@ -85,8 +86,8 @@ void TextPreview::draw(Graphics* graphics)
return;
BLOCK_START("TextPreview::draw")
- if (client->getGuiAlpha() != mAlpha)
- mAlpha = client->getGuiAlpha();
+ if (settings.guiAlpha != mAlpha)
+ mAlpha = settings.guiAlpha;
const int intAlpha = static_cast<int>(mAlpha * 255.0F);
const int alpha = mTextAlpha ? intAlpha : 255;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 74c6d1cfc..453bb125c 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -76,6 +76,7 @@
#include "gui/gui.h"
#include "gui/skin.h"
#include "gui/viewport.h"
+#include "gui/windowmanager.h"
#include "gui/fonts/font.h"
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
new file mode 100644
index 000000000..eb3d244ea
--- /dev/null
+++ b/src/gui/windowmanager.cpp
@@ -0,0 +1,405 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 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/>.
+ */
+
+#include "gui/windowmanager.h"
+
+#include "auctionmanager.h"
+#include "chatlogger.h"
+#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
+#include "dropshortcut.h"
+#include "emoteshortcut.h"
+#include "eventsmanager.h"
+#include "game.h"
+#include "guild.h"
+#include "guildmanager.h"
+#include "graphicsmanager.h"
+#include "itemshortcut.h"
+#include "party.h"
+#include "settings.h"
+#include "soundconsts.h"
+#include "soundmanager.h"
+#include "statuseffect.h"
+#include "units.h"
+#include "touchmanager.h"
+
+#include "being/beingspeech.h"
+#include "being/playerinfo.h"
+#include "being/playerrelations.h"
+
+#include "input/inputmanager.h"
+#include "input/joystick.h"
+#include "input/keyboardconfig.h"
+
+#include "gui/dialogsmanager.h"
+#include "gui/gui.h"
+#include "gui/skin.h"
+#include "gui/theme.h"
+
+#include "gui/windows/buyselldialog.h"
+#include "gui/windows/buydialog.h"
+#include "gui/windows/changeemaildialog.h"
+#include "gui/windows/changepassworddialog.h"
+#include "gui/windows/charselectdialog.h"
+#include "gui/windows/confirmdialog.h"
+#include "gui/windows/connectiondialog.h"
+#include "gui/windows/didyouknowwindow.h"
+#include "gui/windows/helpwindow.h"
+#include "gui/windows/logindialog.h"
+#include "gui/windows/npcdialog.h"
+#include "gui/windows/okdialog.h"
+#include "gui/windows/registerdialog.h"
+#include "gui/windows/selldialog.h"
+#include "gui/windows/serverdialog.h"
+#include "gui/windows/setupwindow.h"
+#include "gui/windows/unregisterdialog.h"
+#include "gui/windows/updaterwindow.h"
+#include "gui/windows/quitdialog.h"
+#include "gui/windows/worldselectdialog.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/desktop.h"
+
+#include "net/chathandler.h"
+#include "net/download.h"
+#include "net/gamehandler.h"
+#include "net/generalhandler.h"
+#include "net/guildhandler.h"
+#include "net/inventoryhandler.h"
+#include "net/loginhandler.h"
+#include "net/net.h"
+#include "net/netconsts.h"
+#include "net/packetlimiter.h"
+#include "net/partyhandler.h"
+
+#include "particle/particle.h"
+
+#include "resources/imagehelper.h"
+#include "resources/openglimagehelper.h"
+#include "resources/resourcemanager.h"
+#include "resources/surfaceimagehelper.h"
+#include "resources/spritereference.h"
+
+#include "resources/db/avatardb.h"
+#include "resources/db/chardb.h"
+#include "resources/db/colordb.h"
+#include "resources/db/deaddb.h"
+#include "resources/db/emotedb.h"
+#include "resources/db/sounddb.h"
+#include "resources/db/itemdb.h"
+#include "resources/db/mapdb.h"
+#include "resources/db/moddb.h"
+#include "resources/db/monsterdb.h"
+#include "resources/db/npcdb.h"
+#include "resources/db/palettedb.h"
+#include "resources/db/petdb.h"
+#include "resources/db/weaponsdb.h"
+
+#include "utils/base64.h"
+#include "utils/cpu.h"
+#include "utils/delete2.h"
+#include "utils/files.h"
+#include "utils/fuzzer.h"
+#include "utils/gettext.h"
+#include "utils/gettexthelper.h"
+#include "utils/mkdir.h"
+#include "utils/paths.h"
+#include "utils/physfstools.h"
+#include "utils/sdlcheckutils.h"
+#include "utils/sdlhelper.h"
+#include "utils/timer.h"
+
+#include "utils/translation/translationmanager.h"
+
+#include "test/testlauncher.h"
+#include "test/testmain.h"
+
+#ifdef __APPLE__
+#include <CoreFoundation/CFBundle.h>
+#endif
+
+#include <SDL_image.h>
+
+#ifdef WIN32
+#include <SDL_syswm.h>
+#include "utils/specialfolder.h"
+#endif
+
+#ifdef ANDROID
+#ifndef USE_SDL2
+#include <SDL_screenkeyboard.h>
+#endif
+#endif
+
+#include <sys/stat.h>
+
+#include <climits>
+#include <fstream>
+
+#include "mumblemanager.h"
+
+#include "debug.h"
+
+FPSmanager fpsManager;
+
+namespace
+{
+ SDL_Surface *mIcon(nullptr);
+ int mKeyboardHeight(0);
+ bool mIsMinimized(false);
+ bool mNewMessageFlag(false);
+} // namespace
+
+void WindowManager::init()
+{
+ // Initialize frame limiting
+ fpsManager.framecount = 0;
+ fpsManager.rateticks = 0;
+ fpsManager.lastticks = 0;
+ fpsManager.rate = 0;
+}
+
+void WindowManager::createWindows()
+{
+ userPalette = new UserPalette;
+ setupWindow = new SetupWindow;
+ setupWindow->postInit();
+ helpWindow = new HelpWindow;
+ didYouKnowWindow = new DidYouKnowWindow;
+ didYouKnowWindow->postInit();
+}
+
+void WindowManager::initTitle()
+{
+ if (settings.options.test.empty())
+ {
+ settings.windowCaption = strprintf("%s %s",
+ branding.getStringValue("appName").c_str(),
+ SMALL_VERSION);
+ }
+ else
+ {
+ settings.windowCaption = strprintf(
+ "Please wait - VIDEO MODE TEST - %s %s - Please wait",
+ branding.getStringValue("appName").c_str(),
+ SMALL_VERSION);
+ }
+
+ SDL::SetWindowTitle(mainGraphics->getWindow(), settings.windowCaption.c_str());
+#ifndef WIN32
+ setIcon();
+#endif
+}
+
+void WindowManager::setFramerate(const int fpsLimit)
+{
+ if (!fpsLimit)
+ return;
+
+ if (!settings.limitFps)
+ return;
+
+ SDL_setFramerate(&fpsManager, fpsLimit);
+}
+
+int WindowManager::getFramerate()
+{
+ if (!settings.limitFps)
+ return 0;
+
+ return SDL_getFramerate(&fpsManager);
+}
+
+void WindowManager::resizeVideo(int actualWidth,
+ int actualHeight,
+ const bool always)
+{
+ // Keep a minimum size. This isn't adhered to by the actual window, but
+ // it keeps some window positions from getting messed up.
+ actualWidth = std::max(470, actualWidth);
+ actualHeight = std::max(320, actualHeight);
+
+ if (!mainGraphics)
+ return;
+ if (!always
+ && mainGraphics->mActualWidth == actualWidth
+ && mainGraphics->mActualHeight == actualHeight)
+ {
+ return;
+ }
+
+ if (mainGraphics->resizeScreen(actualWidth, actualHeight))
+ {
+ const int width = mainGraphics->mWidth;
+ const int height = mainGraphics->mHeight;
+ touchManager.resize(width, height);
+
+ if (gui)
+ gui->videoResized();
+
+ if (desktop)
+ desktop->setSize(width, height);
+
+ client->moveButtons(width);
+
+ Game *const game = Game::instance();
+ if (game)
+ game->videoResized(width, height);
+
+ if (gui)
+ gui->draw();
+
+ config.setValue("screenwidth", actualWidth);
+ config.setValue("screenheight", actualHeight);
+ }
+}
+
+void WindowManager::applyGrabMode()
+{
+ SDL::grabInput(mainGraphics->getWindow(),
+ config.getBoolValue("grabinput"));
+}
+
+void WindowManager::applyGamma()
+{
+ if (config.getFloatValue("enableGamma"))
+ {
+ SDL::setGamma(mainGraphics->getWindow(),
+ config.getFloatValue("gamma"));
+ }
+}
+
+void WindowManager::applyVSync()
+{
+ const int val = config.getIntValue("vsync");
+ if (val > 0 && val < 2)
+ SDL::setVsync(val);
+}
+
+void WindowManager::applyKeyRepeat()
+{
+#ifndef USE_SDL2
+ SDL_EnableKeyRepeat(config.getIntValue("repeateDelay"),
+ config.getIntValue("repeateInterval"));
+#endif
+}
+
+void WindowManager::applyScale()
+{
+ const int scale = config.getIntValue("scale");
+ if (mainGraphics->getScale() == scale)
+ return;
+ mainGraphics->setScale(scale);
+ resizeVideo(mainGraphics->mActualWidth,
+ mainGraphics->mActualHeight,
+ true);
+}
+
+void WindowManager::setIsMinimized(const bool n)
+{
+ mIsMinimized = n;
+ if (!n && mNewMessageFlag)
+ {
+ mNewMessageFlag = false;
+ SDL::SetWindowTitle(mainGraphics->getWindow(),
+ settings.windowCaption.c_str());
+ }
+}
+
+void WindowManager::newChatMessage()
+{
+ if (!mNewMessageFlag && mIsMinimized)
+ {
+ // show * on window caption
+ SDL::SetWindowTitle(mainGraphics->getWindow(),
+ ("*" + settings.windowCaption).c_str());
+ mNewMessageFlag = true;
+ }
+}
+
+void WindowManager::setIcon()
+{
+ std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
+#ifdef WIN32
+ iconFile.append(".ico");
+#else
+ iconFile.append(".png");
+#endif
+ iconFile = Files::getPath(iconFile);
+ logger->log("Loading icon from file: %s", iconFile.c_str());
+
+#ifdef WIN32
+ static SDL_SysWMinfo pInfo;
+ if (mainGraphics)
+ SDL::getWindowWMInfo(mainGraphics->getWindow(), &pInfo);
+ else
+ SDL::getWindowWMInfo(nullptr, &pInfo);
+ // Attempt to load icon from .ico file
+ HICON icon = (HICON) LoadImage(nullptr, iconFile.c_str(),
+ IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
+ // If it's failing, we load the default resource file.
+ if (!icon)
+ {
+ logger->log("icon load error");
+ icon = LoadIcon(GetModuleHandle(nullptr), "A");
+ }
+ if (icon)
+ SetClassLong(pInfo.window, GCL_HICON, reinterpret_cast<LONG>(icon));
+#else
+ mIcon = MIMG_Load(iconFile.c_str());
+ if (mIcon)
+ {
+#ifdef USE_SDL2
+ SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
+#else
+ SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
+#endif
+ SDL::SetWindowIcon(mainGraphics->getWindow(), mIcon);
+ }
+#endif
+}
+
+bool WindowManager::isKeyboardVisible()
+{
+#ifdef USE_SDL2
+ return SDL_IsTextInputActive();
+#else
+ return mKeyboardHeight > 1;
+#endif
+}
+
+bool WindowManager::getIsMinimized()
+{
+ return mIsMinimized;
+}
+
+void WindowManager::updateScreenKeyboard(const int height)
+{
+ mKeyboardHeight = height;
+}
+
+void WindowManager::deleteIcon()
+{
+ MSDL_FreeSurface(mIcon);
+}
diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h
new file mode 100644
index 000000000..8c3519b5c
--- /dev/null
+++ b/src/gui/windowmanager.h
@@ -0,0 +1,81 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 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 GUI_WINDOWMANAGER_H
+#define GUI_WINDOWMANAGER_H
+
+#ifdef USE_SDL2
+#include <SDL2_framerate.h>
+#else
+#include <SDL_framerate.h>
+#endif
+
+#include <string>
+
+#include "localconsts.h"
+
+class Window;
+
+namespace WindowManager
+{
+ void init();
+
+ bool getIsMinimized() A_WARN_UNUSED;
+
+ void setIsMinimized(const bool n);
+
+ void newChatMessage();
+
+ bool isKeyboardVisible();
+
+ void setFramerate(const int fpsLimit);
+
+ int getFramerate() A_WARN_UNUSED;
+
+ void applyGrabMode();
+
+ void applyGamma();
+
+ void applyVSync();
+
+ void applyKeyRepeat();
+
+ void resizeVideo(int actualWidth,
+ int actualHeight,
+ const bool always);
+
+ void applyScale();
+
+ void updateScreenKeyboard(const int height);
+
+ void reloadWallpaper();
+
+ void createWindows();
+
+ void initTitle();
+
+ void setIcon();
+
+ void deleteIcon();
+}
+
+#endif // GUI_WINDOWMANAGER_H
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 928098fea..f7b9a72a2 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -26,6 +26,7 @@
#include "client.h"
#include "configuration.h"
#include "party.h"
+#include "settings.h"
#include "being/localplayer.h"
@@ -159,7 +160,7 @@ void Minimap::setMap(const Map *const map)
SDL_UnlockSurface(surface);
mMapImage = imageHelper->load(surface);
- mMapImage->setAlpha(client->getGuiAlpha());
+ mMapImage->setAlpha(settings.guiAlpha);
mCustomMapImage = true;
MSDL_FreeSurface(surface);
}
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 3f537344f..0e249c8cb 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -33,13 +33,16 @@
#include "input/inputaction.h"
#include "net/download.h"
+
#include "gui/gui.h"
+#include "gui/windowmanager.h"
#include "gui/fonts/font.h"
#include "gui/models/serverslistmodel.h"
#include "gui/widgets/checkbox.h"
+#include "gui/widgets/desktop.h"
#include "gui/windows/editserverdialog.h"
#include "gui/windows/logindialog.h"
@@ -253,7 +256,8 @@ void ServerDialog::connectToSelectedServer()
if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
{
LoginDialog::savedPassword.clear();
- client->reloadWallpaper();
+ if (desktop)
+ desktop->reloadWallpaper();
}
}
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index c9f2a85e7..626321c69 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -25,8 +25,11 @@
#include "client.h"
#include "configuration.h"
#include "logger.h"
+#include "settings.h"
#include "sdlshared.h"
+#include "gui/windowmanager.h"
+
#include "input/inputmanager.h"
#include "input/inputtype.h"
@@ -169,7 +172,7 @@ void Joystick::logic()
mDirection = 0;
- if (mUseInactive || client->getInputFocused())
+ if (mUseInactive || settings.inputFocused)
{
// X-Axis
int position = SDL_JoystickGetAxis(mJoystick, 0);
@@ -338,7 +341,7 @@ bool Joystick::validate() const
if (mCalibrating || !mEnabled || !mCalibrated)
return false;
- return (mUseInactive || client->getInputFocused());
+ return (mUseInactive || settings.inputFocused);
}
void Joystick::handleRepeat(const int time)
diff --git a/src/settings.h b/src/settings.h
index 78f86a59f..15b26faae 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -50,7 +50,11 @@ class Settings final
windowCaption(),
updateMirrors(),
options(),
- persistentIp(true)
+ guiAlpha(1.0F),
+ persistentIp(true),
+ limitFps(false),
+ inputFocused(true),
+ mouseFocused(true)
{ }
std::string updateHost;
@@ -71,7 +75,11 @@ class Settings final
std::string windowCaption;
std::vector<std::string> updateMirrors;
Options options;
+ float guiAlpha;
bool persistentIp;
+ bool limitFps;
+ bool inputFocused;
+ bool mouseFocused;
};
extern Settings settings;