diff options
author | madcamel@gmail.com <madcamel@gmail.com> | 2010-10-16 14:35:24 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-10-17 00:35:41 +0200 |
commit | 9824ccf5946c86df1cf497b797c5f3da5d481d28 (patch) | |
tree | e4fde49c98b6352c5336e4a16d551417fcf256cd /src | |
parent | bc409be3aa785f3646ad0f2372a3da9cf0783c77 (diff) | |
download | mana-client-9824ccf5946c86df1cf497b797c5f3da5d481d28.tar.gz mana-client-9824ccf5946c86df1cf497b797c5f3da5d481d28.tar.bz2 mana-client-9824ccf5946c86df1cf497b797c5f3da5d481d28.tar.xz mana-client-9824ccf5946c86df1cf497b797c5f3da5d481d28.zip |
Added Low CPU Mode toggle in video setup. Defaults to On.
This disables the Image::setAlpha() function, which
uses 60% of the client's CPU cycles.
When enabled, visual quality is slightly decreased,
especially with the particle system.
Toggling this setting On from an Off state requires
a client restart or the graphics look quite funny.
Bertram's addition:
- Renamed 'Low CPU' to 'Disable transparency (Low CPU)' in the gui
for better understanding.
- Removed the sprite display with 30% opacity when disabling
transparency since it made monsters and drops be drawn above all layers
at full opacity.
- Made the OpenGL mode disable the 'low CPU mode'.
- Fixed the GUI logic as much as possible. Please note that the GUI opacity
slider stays enabled when transparency is disabled even if told to be disabled
in that case.
Reviewed-by: CodyMartin, 4144, MadCamel.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 55 | ||||
-rw-r--r-- | src/gui/setup_video.h | 3 | ||||
-rw-r--r-- | src/map.cpp | 24 | ||||
-rw-r--r-- | src/resources/image.cpp | 4 |
5 files changed, 74 insertions, 13 deletions
diff --git a/src/client.cpp b/src/client.cpp index 2d5bdc3f..0b62a48d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1107,6 +1107,7 @@ void Client::initConfiguration() config.setValue("customcursor", true); config.setValue("useScreenshotDirectorySuffix", true); config.setValue("ChatLogLength", 128); + config.setValue("lowcpu", true); // Checking if the configuration file exists... otherwise create it with // default options. diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index ba967275..1a3d15bf 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -211,6 +211,7 @@ Setup_Video::Setup_Video(): mPickupParticleEnabled(config.getValue("showpickupparticle", false)), mOpacity(config.getValue("guialpha", 0.8)), mFps((int) config.getValue("fpslimit", 60)), + mLowCPUEnabled(config.getValue("lowcpu", true)), mSpeechMode(static_cast<Being::Speech>( config.getValue("speech", Being::TEXT_OVERHEAD))), mModeListModel(new ModeListModel), @@ -243,7 +244,9 @@ Setup_Video::Setup_Video(): mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)), mParticleDetailSlider(new Slider(0, 3)), mParticleDetailField(new Label), - mFontSize((int) config.getValue("fontSize", 11)) + mFontSize((int) config.getValue("fontSize", 11)), + mLowCPUCheckBox(new CheckBox(_("Disable transparency (Low CPU mode)"), + mLowCPUEnabled)) { setName(_("Video")); @@ -277,6 +280,10 @@ Setup_Video::Setup_Video(): mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setSelected(mFps > 0); + // If the openGL Mode is enabled, disabling the transaprency + // is irrelelvant. + mLowCPUCheckBox->setEnabled(!mOpenGLEnabled); + // Pre-select the current video mode. std::string videoMode = toString(graphics->getWidth()) + "x" + toString(graphics->getHeight()); @@ -297,6 +304,7 @@ Setup_Video::Setup_Video(): mFpsSlider->setActionEventId("fpslimitslider"); mOverlayDetailSlider->setActionEventId("overlaydetailslider"); mOverlayDetailField->setActionEventId("overlaydetailfield"); + mOpenGLCheckBox->setActionEventId("opengl"); mParticleDetailSlider->setActionEventId("particledetailslider"); mParticleDetailField->setActionEventId("particledetailfield"); @@ -304,6 +312,7 @@ Setup_Video::Setup_Video(): mCustomCursorCheckBox->addActionListener(this); mShowMonsterDamageCheckBox->addActionListener(this); mVisibleNamesCheckBox->addActionListener(this); + mOpenGLCheckBox->addActionListener(this); mParticleEffectsCheckBox->addActionListener(this); mPickupChatCheckBox->addActionListener(this); mPickupParticleCheckBox->addActionListener(this); @@ -317,6 +326,7 @@ Setup_Video::Setup_Video(): mOverlayDetailField->addKeyListener(this); mParticleDetailSlider->addActionListener(this); mParticleDetailField->addKeyListener(this); + mLowCPUCheckBox->addActionListener(this); mSpeechLabel->setCaption(speechModeToString(mSpeechMode)); mSpeechSlider->setValue(mSpeechMode); @@ -374,6 +384,8 @@ Setup_Video::Setup_Video(): place(1, 11, particleDetailLabel); place(2, 11, mParticleDetailField, 3).setPadding(2); + place(0, 12, mLowCPUCheckBox, 4); + setDimension(gcn::Rectangle(0, 0, 365, 300)); } @@ -444,8 +456,9 @@ void Setup_Video::apply() { new OkDialog(_("Changing to OpenGL"), _("Applying change to OpenGL requires restart. " - "In case OpenGL messes up your game graphics, restart " - "the game with the command line option \"--no-opengl\".")); + "In case OpenGL messes up your game graphics, " + "restart the game with the command line option " + "\"--no-opengl\".")); } else { @@ -454,6 +467,30 @@ void Setup_Video::apply() } } + // If LowCPU is enabled from a disabled state we warn the user + if (mLowCPUCheckBox->isSelected()) + { + if (config.getValue("lowcpu", true) == false) + { + new OkDialog(_("Low CPU Mode Enabled"), + _("You must restart to prevent graphical errors.")); + } + + mLowCPUEnabled = true; + config.setValue("lowcpu", true); + } + else + { + if (config.getValue("lowcpu", true) == true) + { + new OkDialog(_("Low CPU Mode Disabled"), + _("You must restart to apply changes.")); + } + + mLowCPUEnabled = false; + config.setValue("lowcpu", false); + } + mFps = mFpsCheckBox->isSelected() ? (int) mFpsSlider->getValue() : 0; mFpsSlider->setEnabled(mFps > 0); @@ -476,6 +513,7 @@ void Setup_Video::apply() mOpenGLEnabled = config.getValue("opengl", false); mPickupChatEnabled = config.getValue("showpickupchat", true); mPickupParticleEnabled = config.getValue("showpickupparticle", false); + mLowCPUEnabled = config.getValue("lowcpu", true); } void Setup_Video::cancel() @@ -497,6 +535,7 @@ void Setup_Video::cancel() mParticleDetailSlider->setValue(mParticleDetail); std::string text = mFpsCheckBox->isSelected() ? toString(mFps) : _("None"); mFpsLabel->setCaption(text); + mLowCPUCheckBox->setSelected(mLowCPUEnabled); config.setValue("screen", mFullScreenEnabled); @@ -628,4 +667,14 @@ void Setup_Video::action(const gcn::ActionEvent &event) mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); } + else if (id == "opengl") + { + // Disable low cpu mode when in OpenGL. + mLowCPUCheckBox->setEnabled(!mOpenGLCheckBox->isSelected()); + // Disable gui opacity slider when disabling transparency. + if (mLowCPUCheckBox->isEnabled()) + mAlphaSlider->setEnabled(!mLowCPUCheckBox->isSelected()); + else + mAlphaSlider->setEnabled(true); + } } diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index ae0786b1..0f8a1e70 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -62,6 +62,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, bool mPickupParticleEnabled; double mOpacity; int mFps; + bool mLowCPUEnabled; Being::Speech mSpeechMode; ModeListModel *mModeListModel; @@ -106,6 +107,8 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, int mFontSize; gcn::DropDown *mFontSizeDropDown; + + gcn::CheckBox *mLowCPUCheckBox; }; #endif diff --git a/src/map.cpp b/src/map.cpp index f1f8d091..2de0a4a8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -330,21 +330,25 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) mSprites, mDebugFlags); } - // Draws beings with a lower opacity to make them visible - // even when covered by a wall or some other elements... - MapSprites::const_iterator si = mSprites.begin(); - while (si != mSprites.end()) + // If the transparency hasn't been disabled, + if (config.getValue("opengl", false) || !config.getValue("lowcpu", true)) { - if (Sprite *sprite = *si) + // We draw beings with a lower opacity to make them visible + // even when covered by a wall or some other elements... + MapSprites::const_iterator si = mSprites.begin(); + while (si != mSprites.end()) { - // For now, just draw sprites with only one layer. - if (sprite->getNumberOfLayers() == 1) + if (Sprite *sprite = *si) { - sprite->setAlpha(0.3f); - sprite->draw(graphics, -scrollX, -scrollY); + // For now, just draw sprites with only one layer. + if (sprite->getNumberOfLayers() == 1) + { + sprite->setAlpha(0.3f); + sprite->draw(graphics, -scrollX, -scrollY); + } } + si++; } - si++; } drawAmbientLayers(graphics, FOREGROUND_LAYERS, scrollX, scrollY, diff --git a/src/resources/image.cpp b/src/resources/image.cpp index cd6bda15..42a6ab56 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -29,6 +29,7 @@ #endif #include "log.h" +#include "configuration.h" #include <SDL_image.h> #include <SDL_rotozoom.h> @@ -242,6 +243,9 @@ SDL_Surface *Image::getByAlpha(float alpha) void Image::setAlpha(float alpha) { + if (config.getValue("lowcpu", true) == true) + return; + if (mAlpha == alpha) return; |