diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-05-13 17:52:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-05-13 17:52:35 +0300 |
commit | 12e311bd5261078e02bffe63e125f89ae1a57209 (patch) | |
tree | 9a71f8e4ca78ea6f5eb09ccdb3bd6cd95830c884 /src/gui | |
parent | 258f968327f6e790e11e809070c5ea5dc21a299c (diff) | |
download | plus-12e311bd5261078e02bffe63e125f89ae1a57209.tar.gz plus-12e311bd5261078e02bffe63e125f89ae1a57209.tar.bz2 plus-12e311bd5261078e02bffe63e125f89ae1a57209.tar.xz plus-12e311bd5261078e02bffe63e125f89ae1a57209.zip |
Move some code from logic queue to separate calls.
It can improve perfomance in slow systems.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/beingpopup.cpp | 1 | ||||
-rw-r--r-- | src/gui/botcheckerwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/botcheckerwindow.h | 2 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/debugwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/debugwindow.h | 2 | ||||
-rw-r--r-- | src/gui/didyouknowwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/gui.cpp | 44 | ||||
-rw-r--r-- | src/gui/gui.h | 21 | ||||
-rw-r--r-- | src/gui/helpwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/itempopup.cpp | 1 | ||||
-rw-r--r-- | src/gui/killstats.cpp | 2 | ||||
-rw-r--r-- | src/gui/sdlfont.cpp | 23 | ||||
-rw-r--r-- | src/gui/sdlfont.h | 2 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup_colors.cpp | 1 | ||||
-rw-r--r-- | src/gui/socialwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/socialwindow.h | 2 | ||||
-rw-r--r-- | src/gui/speechbubble.cpp | 1 | ||||
-rw-r--r-- | src/gui/spellpopup.cpp | 1 | ||||
-rw-r--r-- | src/gui/tradewindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/whoisonline.cpp | 3 | ||||
-rw-r--r-- | src/gui/whoisonline.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/sliderlist.cpp | 3 |
28 files changed, 83 insertions, 49 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index eff4652ce..c58cca626 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -28,6 +28,7 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "gui/widgets/label.h" diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 6ed6a2a3d..2a811fc3a 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -343,7 +343,7 @@ BotCheckerWindow::~BotCheckerWindow() config.removeListener("enableBotCheker", this); } -void BotCheckerWindow::logic() +void BotCheckerWindow::slowLogic() { if (mEnabled && mTableModel) { @@ -361,8 +361,6 @@ void BotCheckerWindow::logic() mLastUpdateTime = nowTime; } } - - Window::logic(); } void BotCheckerWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index b1075686f..dfae55627 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -62,7 +62,7 @@ class BotCheckerWindow : public Window, public gcn::ActionListener, void update(); - void logic(); + void slowLogic(); void updateList(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index bc8bd1f83..75a9b5fbc 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -39,6 +39,7 @@ #include "gui/gui.h" #include "gui/setup.h" +#include "gui/sdlfont.h" #include "gui/sdlinput.h" #include "gui/theme.h" #include "gui/viewport.h" diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index aa551df24..0976f73b5 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -92,7 +92,7 @@ DebugWindow::~DebugWindow() mNetWidget = nullptr; } -void DebugWindow::logic() +void DebugWindow::slowLogic() { if (!isVisible() || !mTabs) return; diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index dfbaa82be..1a5339cba 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -125,7 +125,7 @@ class DebugWindow : public Window /** * Logic (updates components' size and infos) */ - void logic(); + void slowLogic(); void draw(gcn::Graphics *g); diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index e68f5ab22..0dcc01091 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -26,6 +26,7 @@ #include "logger.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/setup.h" #include "gui/widgets/button.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ea6112262..d8cc42011 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -56,7 +56,7 @@ Gui *gui = nullptr; SDLInput *guiInput = nullptr; // Bolded font -gcn::Font *boldFont = nullptr; +SDLFont *boldFont = nullptr; class GuiConfigListener : public ConfigListener { @@ -244,19 +244,6 @@ void Gui::logic() ResourceManager *resman = ResourceManager::getInstance(); resman->clearScheduled(); - // Fade out mouse cursor after extended inactivity - if (mMouseInactivityTimer < 100 * 15) - { - ++mMouseInactivityTimer; - mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f); - } - else - { - mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); - } - - Palette::advanceGradients(); - if (!mTop) return; @@ -264,14 +251,37 @@ void Gui::logic() handleModalMouseInputFocus(); if (mInput) - { -// mInput->_pollInput(); handleMouseInput(); - } mTop->logic(); } +void Gui::slowLogic() +{ + Palette::advanceGradients(); + + // Fade out mouse cursor after extended inactivity + if (mMouseInactivityTimer < 100 * 15) + { + ++mMouseInactivityTimer; + mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f); + } + else + { + mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); + } + if (mGuiFont) + mGuiFont->slowLogic(); + if (mInfoParticleFont) + mInfoParticleFont->slowLogic(); + if (mHelpFont) + mHelpFont->slowLogic(); + if (mSecureFont) + mSecureFont->slowLogic(); + if (boldFont) + boldFont->slowLogic(); +} + bool Gui::handleInput() { if (mInput) diff --git a/src/gui/gui.h b/src/gui/gui.h index 33940ba5e..59a832e8b 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -30,6 +30,7 @@ class Graphics; class GuiConfigListener; class ImageSet; +class SDLFont; class SDLInput; /** @@ -64,6 +65,8 @@ class Gui : public gcn::Gui */ void logic(); + void slowLogic(); + /** * Draws the whole Gui by calling draw functions down in the * Gui hierarchy. It also draws the mouse pointer. @@ -81,26 +84,26 @@ class Gui : public gcn::Gui /** * Return game font. */ - gcn::Font *getFont() const + SDLFont *getFont() const { return mGuiFont; } /** * Return help font. */ - gcn::Font *getHelpFont() const + SDLFont *getHelpFont() const { return mHelpFont; } /** * Return secure font. */ - gcn::Font *getSecureFont() const + SDLFont *getSecureFont() const { return mSecureFont; } /** * Return the Font used for "Info Particles", i.e. ones showing, what * you picked up, etc. */ - gcn::Font *getInfoParticleFont() const + SDLFont *getInfoParticleFont() const { return mInfoParticleFont; } /** @@ -147,10 +150,10 @@ class Gui : public gcn::Gui private: GuiConfigListener *mConfigListener; - gcn::Font *mGuiFont; /**< The global GUI font */ - gcn::Font *mInfoParticleFont; /**< Font for Info Particles*/ - gcn::Font *mHelpFont; /**< Font for Help Window*/ - gcn::Font *mSecureFont; /**< Font for secure labels*/ + SDLFont *mGuiFont; /**< The global GUI font */ + SDLFont *mInfoParticleFont; /**< Font for Info Particles*/ + SDLFont *mHelpFont; /**< Font for Help Window*/ + SDLFont *mSecureFont; /**< Font for secure labels*/ bool mCustomCursor; /**< Show custom cursor */ ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; @@ -164,6 +167,6 @@ extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font */ -extern gcn::Font *boldFont; +extern SDLFont *boldFont; #endif // GUI_H diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index 3ae025514..d58490491 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -26,6 +26,7 @@ #include "logger.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/setup.h" #include "gui/widgets/button.h" diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index f33f77e83..192a5e116 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -29,6 +29,7 @@ #include "units.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "gui/widgets/icon.h" diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 230549908..faf25f27f 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -347,7 +347,7 @@ void KillStats::update() } void KillStats::draw(gcn::Graphics *g) { - update(); +// update(); Window::draw(g); } diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 63688fa29..cc76790d1 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -255,16 +255,6 @@ void SDLFont::drawString(gcn::Graphics *graphics, if (data.img) g->drawImage(data.img, x, y); - - if (!mCleanTime) - { - mCleanTime = cur_time + CLEAN_TIME; - } - else if (mCleanTime < cur_time) - { - doClean(); - mCleanTime = cur_time + CLEAN_TIME; - } } else if (cache->front().img) { @@ -275,6 +265,19 @@ void SDLFont::drawString(gcn::Graphics *graphics, } +void SDLFont::slowLogic() +{ + if (!mCleanTime) + { + mCleanTime = cur_time + CLEAN_TIME; + } + else if (mCleanTime < cur_time) + { + doClean(); + mCleanTime = cur_time + CLEAN_TIME; + } +} + void SDLFont::createSDLTextChunk(SDLTextChunk *chunk) { if (!chunk || chunk->text.empty()) diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index 77e3761e7..c2cf1025f 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -82,6 +82,8 @@ class SDLFont : public gcn::Font void doClean(); + void slowLogic(); + int getCreateCounter() const { return mCreateCounter; } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index f646e4ee1..838e52c84 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -34,6 +34,7 @@ #include "gui/gui.h" #include "gui/logindialog.h" #include "gui/okdialog.h" +#include "gui/sdlfont.h" #include "gui/sdlinput.h" #include "gui/theme.h" diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index d5885143c..800b38337 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -24,6 +24,7 @@ #include "configuration.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "gui/userpalette.h" diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index a2aa36ed4..f0e332529 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1599,7 +1599,7 @@ void SocialWindow::updateActiveList() mNeedUpdate = true; } -void SocialWindow::logic() +void SocialWindow::slowLogic() { unsigned int nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) @@ -1615,8 +1615,6 @@ void SocialWindow::logic() mNeedUpdate = false; mLastUpdateTime = nowTime; } - - Window::logic(); } void SocialWindow::updateAvatar(std::string name) diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 9536ee3d7..e4eac29ae 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -85,7 +85,7 @@ public: void resetDamage(std::string name); - void logic(); + void slowLogic(); void updatePortals(); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 6dc528a0d..970b18ddb 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -26,6 +26,7 @@ #include "graphics.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "gui/widgets/label.h" diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 9446f7515..969a92dc8 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -25,6 +25,7 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/sdlfont.h" #include "gui/widgets/label.h" diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 1d3d7ef39..5ad8e33f6 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -33,6 +33,7 @@ #include "gui/gui.h" #include "gui/inventorywindow.h" #include "gui/itemamountwindow.h" +#include "gui/sdlfont.h" #include "gui/setup.h" #include "gui/theme.h" diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index a7cbca7cc..d3f316021 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -599,7 +599,10 @@ void WhoIsOnline::logic() { // Update Scroll logic mScrollArea->logic(); +} +void WhoIsOnline::slowLogic() +{ if (!mAllowUpdate) return; diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 4b5b52fe4..7b7f9c790 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -121,6 +121,8 @@ public: void logic(); + void slowLogic(); + void action(const gcn::ActionEvent &event); void widgetResized(const gcn::Event &event); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 685be7f4c..377ddac2c 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -31,8 +31,9 @@ #include "gui/chatwindow.h" #include "gui/gui.h" #include "gui/palette.h" -#include "gui/viewport.h" +#include "gui/sdlfont.h" #include "gui/theme.h" +#include "gui/viewport.h" #include "resources/image.h" #include "resources/resourcemanager.h" diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 30a5e72b6..6954f781f 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -31,6 +31,7 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "gui/widgets/linkhandler.h" diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 4be421db4..1052f924e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -30,6 +30,7 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/sdlfont.h" #include "gui/theme.h" #include "resources/image.h" diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 1cb007eae..7f539d79f 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -27,6 +27,7 @@ #include "gui/editdialog.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index bc30bbe38..9dba00cee 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -24,6 +24,7 @@ #include "logger.h" #include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -203,7 +204,7 @@ int SliderList::getMaxLabelWidth() return 1; int maxWidth = 0; - gcn::Font *font = gui->getFont(); + SDLFont *font = gui->getFont(); for (int f = 0; f < mListModel->getNumberOfElements(); f ++) { |