summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-30 12:46:49 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-30 12:46:49 +0300
commit9bb11133522836a9c5e251550ac88c9a4e091c0e (patch)
treef65703ac1a51b79a0766c48420769d28d0847f41 /src/gui
parente55ed9a138e97f6fba5e3b6858a755f8a50197d2 (diff)
downloadmanaverse-9bb11133522836a9c5e251550ac88c9a4e091c0e.tar.gz
manaverse-9bb11133522836a9c5e251550ac88c9a4e091c0e.tar.bz2
manaverse-9bb11133522836a9c5e251550ac88c9a4e091c0e.tar.xz
manaverse-9bb11133522836a9c5e251550ac88c9a4e091c0e.zip
Move main window related code into windowmanager.
Diffstat (limited to 'src/gui')
-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
30 files changed, 565 insertions, 41 deletions
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();
}
}