From 2e84ac20fcf6ec69b40e19c4c6c428db04b70d85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 17 Feb 2012 02:40:14 +0300 Subject: Add branding option for server list file name. --- src/gui/serverdialog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index ce61f6572..55eda908e 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -484,13 +484,15 @@ void ServerDialog::downloadServerList() } mDownload = new Net::Download(this, listFile, &downloadUpdate); - mDownload->setFile(mDir + "/serverlist.xml"); + mDownload->setFile(mDir + "/" + branding.getStringValue( + "onlineServerFile")); mDownload->start(); } void ServerDialog::loadServers(bool addNew) { - XML::Document doc(mDir + "/serverlist.xml", false); + XML::Document doc(mDir + "/" + branding.getStringValue( + "onlineServerFile"), false); XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "serverlist")) -- cgit v1.2.3-70-g09d2 From 4cd44430deb5a7efc030839a133fe8510327fc24 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 17 Feb 2012 21:31:08 +0300 Subject: Update servers list once a day. --- src/gui/serverdialog.cpp | 15 ++++++++++++++- src/gui/serverdialog.h | 4 ++++ src/utils/stringutils.cpp | 14 ++++++++++++++ src/utils/stringutils.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 55eda908e..da61e105b 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -305,7 +305,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): loadServers(true); - if (mServers.empty()) + if (needUpdateServers()) downloadServerList(); } @@ -487,6 +487,8 @@ void ServerDialog::downloadServerList() mDownload->setFile(mDir + "/" + branding.getStringValue( "onlineServerFile")); mDownload->start(); + + config.setValue("serverslistupdate", getDateString()); } void ServerDialog::loadServers(bool addNew) @@ -742,3 +744,14 @@ void ServerDialog::updateServer(ServerInfo server, int index) { saveCustomServers(server, index); } + +bool ServerDialog::needUpdateServers() +{ + if (mServers.empty() || config.getStringValue("serverslistupdate") + != getDateString()) + { + return true; + } + + return false; +} diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index c23fb8776..61620364c 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -138,12 +138,16 @@ class ServerDialog : public Window, * Called to load a list of available server from an online xml file. */ void downloadServerList(); + void loadServers(bool addNew = true); void loadCustomServers(); + void saveCustomServers(const ServerInfo ¤tServer = ServerInfo(), int index = -1); + bool needUpdateServers(); + static int downloadUpdate(void *ptr, DownloadStatus status, size_t total, size_t remaining); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 9184ba79d..2be1e5b77 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -609,3 +609,17 @@ bool strStartWith(std::string str1, std::string str2) return false; return str1.substr(0, str2.size()) == str2; } + +std::string getDateString() +{ + char buffer[80]; + + time_t rawtime; + struct tm *timeinfo; + + time (&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer, 79, "%Y-%m-%d", timeinfo); + return std::string(buffer); +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 47d495dd0..31ee6d51f 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -206,4 +206,6 @@ std::string &removeProtocol(std::string &url); bool strStartWith(std::string str, std::string start); +std::string getDateString(); + #endif // UTILS_STRINGUTILS_H -- cgit v1.2.3-70-g09d2 From 2257406db0fd374e929def04525671c2826306c2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 Feb 2012 02:06:44 +0300 Subject: Fix code style. --- src/animatedsprite.cpp | 7 ++++++- src/game.cpp | 4 ++-- src/graphics.cpp | 2 +- src/gui/emotepopup.cpp | 9 ++++++--- src/gui/setup_video.cpp | 1 - src/gui/spellpopup.cpp | 2 -- src/gui/viewport.cpp | 2 +- src/gui/whoisonline.cpp | 2 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/textbox.cpp | 4 ++-- src/localplayer.cpp | 8 ++------ src/resources/dye.cpp | 2 +- src/resources/image.cpp | 18 ++++++++++++++---- src/resources/specialdb.cpp | 1 - src/utils/process.cpp | 2 +- 15 files changed, 38 insertions(+), 28 deletions(-) (limited to 'src/gui') diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 11329b321..6b791fdd4 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -214,7 +214,12 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) } } if (fail) - mFrameTime = mFrame->delay + 1; + { + if (mFrame) + mFrameTime = mFrame->delay + 1; + else + mFrameTime ++; + } } return true; } diff --git a/src/game.cpp b/src/game.cpp index 6adf62f12..e016d02ff 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1420,7 +1420,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) Net::getPlayerHandler()->setDirection(direction); } } - direction = 0; +// direction = 0; } else { @@ -1695,7 +1695,7 @@ void Game::handleInput() { if (emoteShortcut) emoteShortcut->useEmote(emotion); - used = true; +// used = true; setValidSpeed(); return; } diff --git a/src/graphics.cpp b/src/graphics.cpp index e98b1a283..5241bbcc6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -112,7 +112,7 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, if (mTarget->format) { logger->log("Bits per pixel: %d", mTarget->format->BytesPerPixel); - bpp = mTarget->format->BytesPerPixel; +// bpp = mTarget->format->BytesPerPixel; } const SDL_VideoInfo *vi = SDL_GetVideoInfo(); diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index a286f78e8..39017ac91 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -197,12 +197,15 @@ void EmotePopup::recalculateSize() ++mRowCount; if (mRowCount) + { mColumnCount = emoteCount / mRowCount; + if (emoteCount % mRowCount > 0) + ++ mColumnCount; + } else + { mColumnCount = 1; - - if (emoteCount % mRowCount > 0) - ++mColumnCount; + } setContentSize(mColumnCount * gridWidth, mRowCount * gridHeight); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 6b3d6d4d3..cc3063a68 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -228,7 +228,6 @@ static const char *speechModeToString(Being::Speech mode) case Being::NAME_IN_BUBBLE: return _("Bubbles with names"); } - return ""; } const char *Setup_Video::overlayDetailToString(int detail) diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 66d69b197..48037f03e 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -114,8 +114,6 @@ void SpellPopup::view(int x, int y) { if (y > getHeight() + distance) posY = y - getHeight() - distance; - else - y = 0; } setPosition(posX, posY); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 2e1e15c92..d4c188bfb 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -879,7 +879,7 @@ bool Viewport::isPopupMenuVisible() void Viewport::moveCameraToActor(int actorId, int x, int y) { - if (!player_node) + if (!player_node || !actorSpriteManager) return; Actor *actor = actorSpriteManager->findBeing(actorId); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 1efa9c22d..7e4f02426 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -230,7 +230,7 @@ void WhoIsOnline::updateWindow(std::vector &friends, if (addedFromSection == true && !disregard.empty()) { mBrowserBox->addRow("---"); - addedFromSection = false; +// addedFromSection = false; } for (int i = 0; i < static_cast(disregard.size()); i++) { diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 5856a91b1..49b73a76a 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -655,7 +655,7 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) return ""; // mouse position ourside of correct widget (outside of tab) textX = x - textX; - textY = y - textY; +// textY = y - textY; std::string str = ""; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index a4bc3bc09..575036612 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -116,14 +116,14 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) mMinWidth = minWidth; wrappedStream.clear(); wrappedStream.str(""); - spacePos = 0; +// spacePos = 0; lastNewlinePos = 0; newlinePos = text.find("\n", lastNewlinePos); if (newlinePos == std::string::npos) newlinePos = text.size(); line = text.substr(lastNewlinePos, newlinePos - lastNewlinePos); - width = 0; +// width = 0; break; } else diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0576c8ddb..4675f80cf 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3168,15 +3168,11 @@ void LocalPlayer::specialMove(unsigned char direction) && getInvertDirection() <= 4) && !mIsServerBuggy) { - int max; - if (getInvertDirection() == 2) - max = 10; - else - max = 30; - if (mAction == MOVE) return; + int max; + if (getInvertDirection() == 2) max = 5; else if (getInvertDirection() == 4) diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 6800c5170..eec5916c4 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -309,7 +309,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes) { s << palettes.substr(pal_pos); s << target.substr(next_pos); - pal_pos = std::string::npos; + //pal_pos = std::string::npos; break; } s << palettes.substr(pal_pos, pal_next_pos - pal_pos); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 0ac11f114..1e2bd6b51 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -885,10 +885,20 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, mBounds.y = static_cast(y); mBounds.w = static_cast(width); mBounds.h = static_cast(height); - mInternalBounds.x = mParent->mBounds.x; - mInternalBounds.y = mParent->mBounds.y; - mInternalBounds.w = mParent->mBounds.w; - mInternalBounds.h = mParent->mBounds.h; + if (mParent) + { + mInternalBounds.x = mParent->mBounds.x; + mInternalBounds.y = mParent->mBounds.y; + mInternalBounds.w = mParent->mBounds.w; + mInternalBounds.h = mParent->mBounds.h; + } + else + { + mInternalBounds.x = 0; + mInternalBounds.y = 0; + mInternalBounds.w = 1; + mInternalBounds.h = 1; + } mUseAlphaCache = false; } diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 664d2c73d..50ea773bc 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -129,5 +129,4 @@ SpecialInfo *SpecialDB::get(int id) return nullptr; else return i->second; - return nullptr; } diff --git a/src/utils/process.cpp b/src/utils/process.cpp index 4a2081514..fd0ec0fa8 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -130,7 +130,7 @@ int execFile(std::string pathName, std::string name, } else if (!sleep_pid) { // sleep pid - sleep (timeOut); + sleep (waitTime); // printf ("time out\n"); exit(-1); } -- cgit v1.2.3-70-g09d2 From 220c16d60b9ab983536a9d17d8237fef983ce534 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 Feb 2012 17:46:05 +0300 Subject: Fix selection problem from last commits in browser box. --- src/gui/widgets/browserbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 49b73a76a..5856a91b1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -655,7 +655,7 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) return ""; // mouse position ourside of correct widget (outside of tab) textX = x - textX; -// textY = y - textY; + textY = y - textY; std::string str = ""; -- cgit v1.2.3-70-g09d2 From c097592c3f05168499603901a19479cb07fc6cc1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 19 Feb 2012 19:36:11 +0300 Subject: Add visual page in settings. Move pickup particle settings to visual tab page. --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/gui/setup.cpp | 2 ++ src/gui/setup_video.cpp | 43 ++++++-------------------------- src/gui/setup_video.h | 6 ----- src/gui/setup_visual.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ src/gui/setup_visual.h | 40 ++++++++++++++++++++++++++++++ 7 files changed, 118 insertions(+), 41 deletions(-) create mode 100644 src/gui/setup_visual.cpp create mode 100644 src/gui/setup_visual.h (limited to 'src/gui') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3289aed66..982d9b5ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -327,6 +327,8 @@ SET(SRCS gui/setup_players.h gui/setup_video.cpp gui/setup_video.h + gui/setup_visual.cpp + gui/setup_visual.h gui/sdlfont.cpp gui/sdlfont.h gui/shopwindow.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3fad9f3ce..5b40ac447 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -330,6 +330,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/setup_relations.h \ gui/setup_video.cpp \ gui/setup_video.h \ + gui/setup_visual.cpp \ + gui/setup_visual.h \ gui/sdlfont.cpp \ gui/sdlfont.h \ gui/shopwindow.cpp \ diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 3408fba33..c7908a6ac 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -38,6 +38,7 @@ #include "gui/setup_players.h" #include "gui/setup_relations.h" #include "gui/setup_video.h" +#include "gui/setup_visual.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -92,6 +93,7 @@ Setup::Setup(): mPanel->enableScrollButtons(true); mTabs.push_back(new Setup_Video); + mTabs.push_back(new Setup_Visual); mTabs.push_back(new Setup_Audio); mTabs.push_back(new Setup_Perfomance); mTabs.push_back(new Setup_Joystick); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index cc3063a68..31060dcfd 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -275,8 +275,6 @@ Setup_Video::Setup_Video(): mOpenGLEnabled(config.getIntValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), mParticleEffectsEnabled(config.getBoolValue("particleeffects")), - mPickupChatEnabled(config.getBoolValue("showpickupchat")), - mPickupParticleEnabled(config.getBoolValue("showpickupparticle")), mOpacity(config.getFloatValue("guialpha")), mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), @@ -291,12 +289,6 @@ Setup_Video::Setup_Video(): mCustomCursorEnabled)), mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), mParticleEffectsEnabled)), - mPickupNotifyLabel(new Label(_("Show pickup notification"))), - // TRANSLATORS: Refers to "Show own name" - mPickupChatCheckBox(new CheckBox(_("in chat"), mPickupChatEnabled)), - // TRANSLATORS: Refers to "Show own name" - mPickupParticleCheckBox(new CheckBox(_("as particle"), - mPickupParticleEnabled)), mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)), mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)), mSpeechSlider(new Slider(0, 3)), @@ -358,8 +350,6 @@ Setup_Video::Setup_Video(): mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mParticleEffectsCheckBox->setActionEventId("particleeffects"); - mPickupChatCheckBox->setActionEventId("pickupchat"); - mPickupParticleCheckBox->setActionEventId("pickupparticle"); mAlphaSlider->setActionEventId("guialpha"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mSpeechSlider->setActionEventId("speech"); @@ -376,8 +366,6 @@ Setup_Video::Setup_Video(): mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); mParticleEffectsCheckBox->addActionListener(this); - mPickupChatCheckBox->addActionListener(this); - mPickupParticleCheckBox->addActionListener(this); mAlphaSlider->addActionListener(this); mFpsCheckBox->addActionListener(this); mSpeechSlider->addActionListener(this); @@ -407,8 +395,6 @@ Setup_Video::Setup_Video(): place(0, 0, scrollArea, 1, 6).setPadding(2); place(0, 6, mOpenGLDropDown, 1); -// place(0, 6, mHwAccelCheckBox, 6); - place(1, 0, mFsCheckBox, 2); place(1, 1, mCustomCursorCheckBox, 3); @@ -416,11 +402,9 @@ Setup_Video::Setup_Video(): place(1, 2, mEnableResizeCheckBox, 2); place(1, 3, mNoFrameCheckBox, 2); - place(1, 4, mParticleEffectsCheckBox, 2); - - place(1, 5, mPickupNotifyLabel, 4); - place(1, 6, mPickupChatCheckBox, 1); - place(2, 6, mPickupParticleCheckBox, 2); +// place(1, 5, mPickupNotifyLabel, 4); +// place(1, 6, mPickupChatCheckBox, 1); +// place(2, 6, mPickupParticleCheckBox, 2); place(0, 7, mAlphaSlider); place(1, 7, alphaLabel, 3); @@ -440,9 +424,11 @@ Setup_Video::Setup_Video(): place(1, 12, overlayDetailLabel); place(2, 12, mOverlayDetailField, 3).setPadding(2); - place(0, 13, mParticleDetailSlider); - place(1, 13, particleDetailLabel); - place(2, 13, mParticleDetailField, 3).setPadding(2); + place(0, 13, mParticleEffectsCheckBox, 5); + + place(0, 14, mParticleDetailSlider); + place(1, 14, particleDetailLabel); + place(2, 14, mParticleDetailField, 3).setPadding(2); int width = 600; @@ -547,8 +533,6 @@ void Setup_Video::apply() mOpacity = config.getFloatValue("guialpha"); mOverlayDetail = config.getIntValue("OverlayDetail"); mOpenGLEnabled = config.getIntValue("opengl"); - mPickupChatEnabled = config.getBoolValue("showpickupchat"); - mPickupParticleEnabled = config.getBoolValue("showpickupparticle"); mEnableResize = config.getBoolValue("enableresize"); mNoFrame = config.getBoolValue("noframe"); } @@ -589,8 +573,6 @@ void Setup_Video::cancel() config.setValue("guialpha", mOpacity); Image::setEnableAlpha(mOpacity != 1.0f); config.setValue("opengl", mOpenGLEnabled); - config.setValue("showpickupchat", mPickupChatEnabled); - config.setValue("showpickupparticle", mPickupParticleEnabled); config.setValue("enableresize", mEnableResize); config.setValue("noframe", mNoFrame); } @@ -674,15 +656,6 @@ void Setup_Video::action(const gcn::ActionEvent &event) _("Changes will take effect on map change.")); } } - else if (id == "pickupchat") - { - config.setValue("showpickupchat", mPickupChatCheckBox->isSelected()); - } - else if (id == "pickupparticle") - { - config.setValue("showpickupparticle", - mPickupParticleCheckBox->isSelected()); - } else if (id == "speech") { Being::Speech val = static_cast( diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 31d45d93d..ad6ca12d7 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -57,8 +57,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener int mOpenGLEnabled; bool mCustomCursorEnabled; bool mParticleEffectsEnabled; - bool mPickupChatEnabled; - bool mPickupParticleEnabled; float mOpacity; int mFps; int mAltFps; @@ -83,10 +81,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener gcn::CheckBox *mCustomCursorCheckBox; gcn::CheckBox *mParticleEffectsCheckBox; - gcn::Label *mPickupNotifyLabel; - gcn::CheckBox *mPickupChatCheckBox; - gcn::CheckBox *mPickupParticleCheckBox; - gcn::CheckBox *mEnableResizeCheckBox; gcn::CheckBox *mNoFrameCheckBox; diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp new file mode 100644 index 000000000..6df2dbf82 --- /dev/null +++ b/src/gui/setup_visual.cpp @@ -0,0 +1,64 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2012 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gui/setup_visual.h" + +#include "gui/chatwindow.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/chattab.h" +#include "gui/widgets/checkbox.h" +#include "gui/widgets/label.h" +#include "gui/widgets/layouthelper.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" + +#include "configuration.h" +#include "localplayer.h" +#include "logger.h" + +#include "utils/gettext.h" + +#include "debug.h" + +Setup_Visual::Setup_Visual() +{ + setName(_("Visual")); + + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + place(0, 0, mScroll, 10, 10); + + new SetupItemCheckBox(_("Show pickup notifications in chat"), "", + "showpickupchat", this, "showpickupchatEvent"); + + new SetupItemCheckBox(_("Show pickup notifications as particle effects"), + "", "showpickupparticle", this, "showpickupparticleEvent"); + + setDimension(gcn::Rectangle(0, 0, 550, 350)); +} + +void Setup_Visual::apply() +{ + SetupTabScroll::apply(); +} diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h new file mode 100644 index 000000000..f5001b9e4 --- /dev/null +++ b/src/gui/setup_visual.h @@ -0,0 +1,40 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2012 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GUI_SETUP_VISUAL_H +#define GUI_SETUP_VISUAL_H + +#include "guichanfwd.h" + +#include "gui/widgets/setuptabscroll.h" + +#include + +class Setup_Visual : public SetupTabScroll +{ + public: + Setup_Visual(); + + void apply(); +}; + +#endif -- cgit v1.2.3-70-g09d2 From 0d2d350e8eb6f57be31f926897e39c6483eeee75 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 19 Feb 2012 20:10:11 +0300 Subject: Add option to grab/ungrab input to game window. --- src/client.cpp | 8 ++++++++ src/client.h | 2 ++ src/gui/setup_visual.cpp | 4 ++++ 3 files changed, 14 insertions(+) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index e6aeb22e2..949dbacd2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -562,6 +562,8 @@ void Client::gameInit() } } + applyGrabMode(); + // Initialize for drawing mainGraphics->_beginDraw(); @@ -2429,3 +2431,9 @@ void Client::resizeVideo(int width, int height, bool always) config.setValue("screenheight", height); } } + +void Client::applyGrabMode() +{ + SDL_WM_GrabInput(config.getBoolValue("grabinput") + ? SDL_GRAB_ON : SDL_GRAB_OFF); +} diff --git a/src/client.h b/src/client.h index 6c93adbdf..ba6fde480 100644 --- a/src/client.h +++ b/src/client.h @@ -273,6 +273,8 @@ public: static bool isTmw(); + static void applyGrabMode(); + void optionChanged(const std::string &name); void action(const gcn::ActionEvent &event); diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 6df2dbf82..22894e267 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -55,10 +55,14 @@ Setup_Visual::Setup_Visual() new SetupItemCheckBox(_("Show pickup notifications as particle effects"), "", "showpickupparticle", this, "showpickupparticleEvent"); + new SetupItemCheckBox(_("Grab mouse and keyboard input"), + "", "grabinput", this, "grabinputEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } void Setup_Visual::apply() { SetupTabScroll::apply(); + Client::applyGrabMode(); } -- cgit v1.2.3-70-g09d2 From e2620fcbbe0ae5ac43565879f4b7243c367c84cf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 20 Feb 2012 02:49:46 +0300 Subject: Move gui opacity option to visual settings page. Add slider class for setup pages. --- src/gui/setup_video.cpp | 21 +------- src/gui/setup_video.h | 3 -- src/gui/setup_visual.cpp | 6 +++ src/gui/setup_visual.h | 1 + src/gui/widgets/horizontcontainer.cpp | 7 ++- src/gui/widgets/horizontcontainer.h | 2 + src/gui/widgets/setupitem.cpp | 98 +++++++++++++++++++++++++++++++++++ src/gui/widgets/setupitem.h | 34 ++++++++++++ 8 files changed, 149 insertions(+), 23 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 31060dcfd..65fb460e5 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -275,7 +275,6 @@ Setup_Video::Setup_Video(): mOpenGLEnabled(config.getIntValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), mParticleEffectsEnabled(config.getBoolValue("particleeffects")), - mOpacity(config.getFloatValue("guialpha")), mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), mEnableResize(config.getBoolValue("enableresize")), @@ -293,7 +292,6 @@ Setup_Video::Setup_Video(): mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)), mSpeechSlider(new Slider(0, 3)), mSpeechLabel(new Label("")), - mAlphaSlider(new Slider(0.1, 1.0)), mFpsCheckBox(new CheckBox(_("FPS limit:"))), mFpsSlider(new Slider(2, 160)), mFpsLabel(new Label), @@ -314,7 +312,6 @@ Setup_Video::Setup_Video(): scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); speechLabel = new Label(_("Overhead text")); - alphaLabel = new Label(_("Gui opacity")); overlayDetailLabel = new Label(_("Ambient FX")); particleDetailLabel = new Label(_("Particle detail")); @@ -328,9 +325,6 @@ Setup_Video::Setup_Video(): mOpenGLDropDown->setSelected(0); #endif - mAlphaSlider->setValue(mOpacity); - mAlphaSlider->setWidth(90); - mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None")); mFpsLabel->setWidth(60); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0 @@ -350,7 +344,6 @@ Setup_Video::Setup_Video(): mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mParticleEffectsCheckBox->setActionEventId("particleeffects"); - mAlphaSlider->setActionEventId("guialpha"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mSpeechSlider->setActionEventId("speech"); mFpsSlider->setActionEventId("fpslimitslider"); @@ -366,7 +359,6 @@ Setup_Video::Setup_Video(): mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); mParticleEffectsCheckBox->addActionListener(this); - mAlphaSlider->addActionListener(this); mFpsCheckBox->addActionListener(this); mSpeechSlider->addActionListener(this); mFpsSlider->addActionListener(this); @@ -406,8 +398,8 @@ Setup_Video::Setup_Video(): // place(1, 6, mPickupChatCheckBox, 1); // place(2, 6, mPickupParticleCheckBox, 2); - place(0, 7, mAlphaSlider); - place(1, 7, alphaLabel, 3); +// place(0, 7, mAlphaSlider); +// place(1, 7, alphaLabel, 3); place(0, 9, mFpsSlider); place(1, 9, mFpsCheckBox).setPadding(3); @@ -530,7 +522,6 @@ void Setup_Video::apply() mSpeechMode = static_cast( config.getIntValue("speech")); - mOpacity = config.getFloatValue("guialpha"); mOverlayDetail = config.getIntValue("OverlayDetail"); mOpenGLEnabled = config.getIntValue("opengl"); mEnableResize = config.getBoolValue("enableresize"); @@ -549,7 +540,6 @@ void Setup_Video::cancel() mAltFpsSlider->setValue(mAltFps); mAltFpsSlider->setEnabled(mAltFps > 0); mSpeechSlider->setValue(mSpeechMode); - mAlphaSlider->setValue(mOpacity); mOverlayDetailSlider->setValue(mOverlayDetail); mParticleDetailSlider->setValue(mParticleDetail); mFpsLabel->setCaption(mFpsCheckBox->isSelected() @@ -570,8 +560,6 @@ void Setup_Video::cancel() config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); config.setValue("speech", static_cast(mSpeechMode)); - config.setValue("guialpha", mOpacity); - Image::setEnableAlpha(mOpacity != 1.0f); config.setValue("opengl", mOpenGLEnabled); config.setValue("enableresize", mEnableResize); config.setValue("noframe", mNoFrame); @@ -635,11 +623,6 @@ void Setup_Video::action(const gcn::ActionEvent &event) { mDialog = nullptr; } - else if (id == "guialpha") - { - config.setValue("guialpha", mAlphaSlider->getValue()); - Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); - } else if (id == "customcursor") { config.setValue("customcursor", mCustomCursorCheckBox->isSelected()); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index ad6ca12d7..32a5d444c 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -57,7 +57,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener int mOpenGLEnabled; bool mCustomCursorEnabled; bool mParticleEffectsEnabled; - float mOpacity; int mFps; int mAltFps; bool mEnableResize; @@ -69,7 +68,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener OpenGLListModel *mOpenGLListModel; gcn::Label *speechLabel; - gcn::Label *alphaLabel; gcn::Label *scrollRadiusLabel; gcn::Label *scrollLazinessLabel; gcn::Label *overlayDetailLabel; @@ -86,7 +84,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener gcn::Slider *mSpeechSlider; gcn::Label *mSpeechLabel; - gcn::Slider *mAlphaSlider; gcn::CheckBox *mFpsCheckBox; gcn::Slider *mFpsSlider; gcn::Label *mFpsLabel; diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 22894e267..cc713effa 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -32,6 +32,8 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" +#include "resources/image.h" + #include "configuration.h" #include "localplayer.h" #include "logger.h" @@ -58,11 +60,15 @@ Setup_Visual::Setup_Visual() new SetupItemCheckBox(_("Grab mouse and keyboard input"), "", "grabinput", this, "grabinputEvent"); + new SetupItemSlider(_("Gui opacity"), "", "guialpha", + this, "guialphaEvent", 0.1, 1.0); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } void Setup_Visual::apply() { SetupTabScroll::apply(); + Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); Client::applyGrabMode(); } diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index f5001b9e4..b8715f409 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -35,6 +35,7 @@ class Setup_Visual : public SetupTabScroll Setup_Visual(); void apply(); + }; #endif diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index c128ea550..5bf81c5d8 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -33,12 +33,17 @@ HorizontContainer::HorizontContainer(int height, int spacing): } void HorizontContainer::add(gcn::Widget *widget) +{ + add(widget, mSpacing); +} + +void HorizontContainer::add(gcn::Widget *widget, int spacing) { if (!widget) return; Container::add(widget); - widget->setPosition(mLastX, mSpacing); + widget->setPosition(mLastX, spacing); mCount++; mLastX += widget->getWidth() + 2 * mSpacing; } diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 7439672dc..8e1d082ac 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -38,6 +38,8 @@ class HorizontContainer : public Container, public gcn::WidgetListener virtual void add(gcn::Widget *widget); + virtual void add(gcn::Widget *widget, int spacing); + virtual void clear(); void widgetResized(const gcn::Event &event); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 56ce0a25a..1d6bf5916 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -33,6 +33,7 @@ #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/slider.h" #include "gui/widgets/tabbedarea.h" #include "gui/widgets/textfield.h" #include "gui/widgets/vertcontainer.h" @@ -588,3 +589,100 @@ void SetupItemDropDown::toWidget() mDropDown->setSelectedString(mValue); } + + + + + + +SetupItemSlider::SetupItemSlider(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, double min, double max, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mSlider(nullptr), + mMin(min), + mMax(max) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSlider::SetupItemSlider(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, double min, double max, + std::string def, bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, def, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mSlider(nullptr), + mMin(min), + mMax(max) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSlider::~SetupItemSlider() +{ + mHorizont = nullptr; + mWidget = nullptr; + mSlider = nullptr; + mLabel = nullptr; +} + +void SetupItemSlider::createControls() +{ + load(); + mHorizont = new HorizontContainer(32, 2); + + mLabel = new Label(mText); + mSlider = new Slider(mMin, mMax); + mSlider->setActionEventId(mEventName); + mSlider->addActionListener(mParent); + mSlider->setValue(atof(mValue.c_str())); + mSlider->setHeight(30); + + mWidget = mSlider; + mSlider->setWidth(150); + mSlider->setHeight(40); + mHorizont->add(mLabel); + mHorizont->add(mSlider, -10); + + mParent->getContainer()->add2(mHorizont, true, 4); + mParent->addControl(this); + mParent->addActionListener(this); + mWidget->addActionListener(this); +} + +void SetupItemSlider::fromWidget() +{ + if (!mSlider) + return; + + mValue = toString(mSlider->getValue()); +} + +void SetupItemSlider::toWidget() +{ + if (!mSlider) + return; + + mSlider->setValue(atof(mValue.c_str())); +} + +void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED) +{ + fromWidget(); +} + +void SetupItemSlider::apply(std::string eventName) +{ + if (eventName != mEventName) + return; + + fromWidget(); + save(); +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 71856d6e2..220a55494 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -41,6 +41,7 @@ class EditDialog; class HorizontContainer; class IntTextField; class Label; +class Slider; class TextField; class SetupItem : public gcn::ActionListener @@ -264,4 +265,37 @@ class SetupItemDropDown : public SetupItem DropDown *mDropDown; }; +class SetupItemSlider : public SetupItem +{ + public: + SetupItemSlider(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, double min, double max, + bool mainConfig = true); + + SetupItemSlider(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, double min, double max, + std::string def, bool mainConfig = true); + + ~SetupItemSlider(); + + void createControls(); + + void fromWidget(); + + void toWidget(); + + void action(const gcn::ActionEvent &event); + + void apply(std::string eventName); + + protected: + HorizontContainer *mHorizont; + Label *mLabel; + Slider *mSlider; + double mMin; + double mMax; +}; + #endif -- cgit v1.2.3-70-g09d2 From f9abb45a7776fa158daef508f8287da267de002b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 20 Feb 2012 03:08:42 +0300 Subject: Allow chage gui opacity in settings on the fly. --- src/gui/setup_visual.cpp | 14 ++++++++++++++ src/gui/setup_visual.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src/gui') diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index cc713effa..1cf35e4f2 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -31,6 +31,7 @@ #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" +#include "gui/widgets/slider.h" #include "resources/image.h" @@ -72,3 +73,16 @@ void Setup_Visual::apply() Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); Client::applyGrabMode(); } + +void Setup_Visual::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "guialphaEvent") + { + Slider *slider = static_cast(event.getSource()); + if (slider) + { + config.setValue("guialpha", slider->getValue()); + Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); + } + } +} diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index b8715f409..c76002c06 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -36,6 +36,7 @@ class Setup_Visual : public SetupTabScroll void apply(); + void action(const gcn::ActionEvent &event A_UNUSED); }; #endif -- cgit v1.2.3-70-g09d2 From 2eef004b8b70861fd377ad50393a9a0ccbbbc152 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 00:10:57 +0300 Subject: Move some settings from video to visual page. --- src/gui/setup_video.cpp | 172 +++++------------------------------------- src/gui/setup_video.h | 21 ------ src/gui/setup_visual.cpp | 48 +++++++++++- src/gui/setup_visual.h | 10 +++ src/gui/widgets/setupitem.cpp | 161 ++++++++++++++++++++++++++++++++++++++- src/gui/widgets/setupitem.h | 51 ++++++++++++- src/utils/mathutils.h | 5 ++ 7 files changed, 286 insertions(+), 182 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 65fb460e5..ae7e7a9cc 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -28,7 +28,6 @@ #include "localplayer.h" #include "logger.h" #include "main.h" -#include "particle.h" #include "gui/gui.h" #include "gui/okdialog.h" @@ -214,95 +213,26 @@ public: } }; -static const char *speechModeToString(Being::Speech mode) -{ - switch (mode) - { - case Being::NO_SPEECH: - default: - return _("No text"); - case Being::TEXT_OVERHEAD: - return _("Text"); - case Being::NO_NAME_IN_BUBBLE: - return _("Bubbles, no names"); - case Being::NAME_IN_BUBBLE: - return _("Bubbles with names"); - } -} - -const char *Setup_Video::overlayDetailToString(int detail) -{ - if (detail == -1) - detail = config.getIntValue("OverlayDetail"); - - switch (detail) - { - case 0: - return _("off"); - case 1: - return _("low"); - case 2: - return _("high"); - default: - return ""; - } - return ""; -} - -const char *Setup_Video::particleDetailToString(int detail) -{ - if (detail == -1) - detail = 3 - config.getIntValue("particleEmitterSkip"); - - switch (detail) - { - case 0: - return _("low"); - case 1: - return _("medium"); - case 2: - return _("high"); - case 3: - return _("max"); - default: - return ""; - } - return ""; -} - Setup_Video::Setup_Video(): mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(config.getIntValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), - mParticleEffectsEnabled(config.getBoolValue("particleeffects")), mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), mEnableResize(config.getBoolValue("enableresize")), mNoFrame(config.getBoolValue("noframe")), - mSpeechMode(static_cast( - config.getIntValue("speech"))), mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), - mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), - mParticleEffectsEnabled)), mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)), mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)), - mSpeechSlider(new Slider(0, 3)), - mSpeechLabel(new Label("")), mFpsCheckBox(new CheckBox(_("FPS limit:"))), mFpsSlider(new Slider(2, 160)), mFpsLabel(new Label), mAltFpsSlider(new Slider(2, 160)), mAltFpsLabel(new Label(_("Alt FPS limit: "))), - mOverlayDetail(config.getIntValue("OverlayDetail")), - mOverlayDetailSlider(new Slider(0, 2)), - mOverlayDetailField(new Label), - mParticleDetail(3 - config.getIntValue("particleEmitterSkip")), - mParticleDetailSlider(new Slider(0, 3)), - mParticleDetailField(new Label), mDialog(nullptr) { setName(_("Video")); @@ -311,10 +241,6 @@ Setup_Video::Setup_Video(): scrollArea->setWidth(150); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - speechLabel = new Label(_("Overhead text")); - overlayDetailLabel = new Label(_("Ambient FX")); - particleDetailLabel = new Label(_("Particle detail")); - mOpenGLListModel = new OpenGLListModel; mOpenGLDropDown = new DropDown(mOpenGLListModel), mOpenGLDropDown->setSelected(mOpenGLEnabled); @@ -343,49 +269,28 @@ Setup_Video::Setup_Video(): mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); - mParticleEffectsCheckBox->setActionEventId("particleeffects"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); - mSpeechSlider->setActionEventId("speech"); mFpsSlider->setActionEventId("fpslimitslider"); mAltFpsSlider->setActionEventId("altfpslimitslider"); - mOverlayDetailSlider->setActionEventId("overlaydetailslider"); - mOverlayDetailField->setActionEventId("overlaydetailfield"); - mParticleDetailSlider->setActionEventId("particledetailslider"); - mParticleDetailField->setActionEventId("particledetailfield"); mOpenGLDropDown->setActionEventId("opengl"); mEnableResizeCheckBox->setActionEventId("enableresize"); mNoFrameCheckBox->setActionEventId("noframe"); mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); - mParticleEffectsCheckBox->addActionListener(this); mFpsCheckBox->addActionListener(this); - mSpeechSlider->addActionListener(this); mFpsSlider->addActionListener(this); mAltFpsSlider->addActionListener(this); - mOverlayDetailSlider->addActionListener(this); - mOverlayDetailField->addKeyListener(this); - mParticleDetailSlider->addActionListener(this); - mParticleDetailField->addKeyListener(this); mOpenGLDropDown->addActionListener(this); mEnableResizeCheckBox->addActionListener(this); mNoFrameCheckBox->addActionListener(this); - mSpeechLabel->setCaption(speechModeToString(mSpeechMode)); - mSpeechSlider->setValue(mSpeechMode); - - mOverlayDetailField->setCaption(overlayDetailToString(mOverlayDetail)); - mOverlayDetailSlider->setValue(mOverlayDetail); - - mParticleDetailField->setCaption(particleDetailToString(mParticleDetail)); - mParticleDetailSlider->setValue(mParticleDetail); - // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, scrollArea, 1, 6).setPadding(2); - place(0, 6, mOpenGLDropDown, 1); + place(0, 0, scrollArea, 1, 5).setPadding(2); + place(0, 5, mOpenGLDropDown, 1); place(1, 0, mFsCheckBox, 2); @@ -401,26 +306,26 @@ Setup_Video::Setup_Video(): // place(0, 7, mAlphaSlider); // place(1, 7, alphaLabel, 3); - place(0, 9, mFpsSlider); - place(1, 9, mFpsCheckBox).setPadding(3); - place(2, 9, mFpsLabel).setPadding(1); + place(0, 6, mFpsSlider); + place(1, 6, mFpsCheckBox).setPadding(3); + place(2, 6, mFpsLabel).setPadding(1); - place(0, 10, mAltFpsSlider); - place(1, 10, mAltFpsLabel).setPadding(3); + place(0, 7, mAltFpsSlider); + place(1, 7, mAltFpsLabel).setPadding(3); - place(0, 11, mSpeechSlider); - place(1, 11, speechLabel); - place(2, 11, mSpeechLabel, 3).setPadding(2); +// place(0, 11, mSpeechSlider); +// place(1, 11, speechLabel); +// place(2, 11, mSpeechLabel, 3).setPadding(2); - place(0, 12, mOverlayDetailSlider); - place(1, 12, overlayDetailLabel); - place(2, 12, mOverlayDetailField, 3).setPadding(2); +// place(0, 12, mOverlayDetailSlider); +// place(1, 12, overlayDetailLabel); +// place(2, 12, mOverlayDetailField, 3).setPadding(2); - place(0, 13, mParticleEffectsCheckBox, 5); +// place(0, 13, mParticleEffectsCheckBox, 5); - place(0, 14, mParticleDetailSlider); - place(1, 14, particleDetailLabel); - place(2, 14, mParticleDetailField, 3).setPadding(2); +// place(0, 14, mParticleDetailSlider); +// place(1, 14, particleDetailLabel); +// place(2, 14, mParticleDetailField, 3).setPadding(2); int width = 600; @@ -518,11 +423,7 @@ void Setup_Video::apply() // We sync old and new values at apply time mFullScreenEnabled = config.getBoolValue("screen"); mCustomCursorEnabled = config.getBoolValue("customcursor"); - mParticleEffectsEnabled = config.getBoolValue("particleeffects"); - mSpeechMode = static_cast( - config.getIntValue("speech")); - mOverlayDetail = config.getIntValue("OverlayDetail"); mOpenGLEnabled = config.getIntValue("opengl"); mEnableResize = config.getBoolValue("enableresize"); mNoFrame = config.getBoolValue("noframe"); @@ -534,14 +435,10 @@ void Setup_Video::cancel() mFsCheckBox->setSelected(mFullScreenEnabled); mOpenGLDropDown->setSelected(mOpenGLEnabled); mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); - mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled); mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); mAltFpsSlider->setValue(mAltFps); mAltFpsSlider->setEnabled(mAltFps > 0); - mSpeechSlider->setValue(mSpeechMode); - mOverlayDetailSlider->setValue(mOverlayDetail); - mParticleDetailSlider->setValue(mParticleDetail); mFpsLabel->setCaption(mFpsCheckBox->isSelected() ? toString(mFps) : _("None")); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps)); @@ -558,8 +455,6 @@ void Setup_Video::cancel() config.setValue("screenheight", mainGraphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); - config.setValue("particleeffects", mParticleEffectsEnabled); - config.setValue("speech", static_cast(mSpeechMode)); config.setValue("opengl", mOpenGLEnabled); config.setValue("enableresize", mEnableResize); config.setValue("noframe", mNoFrame); @@ -627,39 +522,6 @@ void Setup_Video::action(const gcn::ActionEvent &event) { config.setValue("customcursor", mCustomCursorCheckBox->isSelected()); } - else if (id == "particleeffects") - { - config.setValue("particleeffects", - mParticleEffectsCheckBox->isSelected()); - Particle::enabled = mParticleEffectsCheckBox->isSelected(); - - if (Game::instance()) - { - new OkDialog(_("Particle Effect Settings Changed."), - _("Changes will take effect on map change.")); - } - } - else if (id == "speech") - { - Being::Speech val = static_cast( - mSpeechSlider->getValue()); - mSpeechLabel->setCaption(speechModeToString(val)); - mSpeechSlider->setValue(val); - config.setValue("speech", static_cast(val)); - } - else if (id == "overlaydetailslider") - { - int val = static_cast(mOverlayDetailSlider->getValue()); - mOverlayDetailField->setCaption(overlayDetailToString(val)); - config.setValue("OverlayDetail", val); - } - else if (id == "particledetailslider") - { - int val = static_cast(mParticleDetailSlider->getValue()); - mParticleDetailField->setCaption(particleDetailToString(val)); - config.setValue("particleEmitterSkip", 3 - val); - Particle::emitterSkip = 4 - val; - } else if (id == "fpslimitcheckbox" || id == "fpslimitslider") { int tempFps = static_cast(mFpsSlider->getValue()); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 32a5d444c..0e7bc0f21 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -46,59 +46,38 @@ class Setup_Video : public SetupTab, public gcn::KeyListener void action(const gcn::ActionEvent &event); - static const char *overlayDetailToString(int detail = -1); - - static const char *particleDetailToString(int detail = -1); - virtual void externalUpdated(); private: bool mFullScreenEnabled; int mOpenGLEnabled; bool mCustomCursorEnabled; - bool mParticleEffectsEnabled; int mFps; int mAltFps; bool mEnableResize; bool mNoFrame; - Being::Speech mSpeechMode; ModeListModel *mModeListModel; OpenGLListModel *mOpenGLListModel; - gcn::Label *speechLabel; gcn::Label *scrollRadiusLabel; gcn::Label *scrollLazinessLabel; - gcn::Label *overlayDetailLabel; - gcn::Label *particleDetailLabel; gcn::ListBox *mModeList; gcn::CheckBox *mFsCheckBox; gcn::DropDown *mOpenGLDropDown; gcn::CheckBox *mCustomCursorCheckBox; - gcn::CheckBox *mParticleEffectsCheckBox; gcn::CheckBox *mEnableResizeCheckBox; gcn::CheckBox *mNoFrameCheckBox; - gcn::Slider *mSpeechSlider; - gcn::Label *mSpeechLabel; gcn::CheckBox *mFpsCheckBox; gcn::Slider *mFpsSlider; gcn::Label *mFpsLabel; -// gcn::CheckBox *mAltFpsCheckBox; gcn::Slider *mAltFpsSlider; gcn::Label *mAltFpsLabel; - int mOverlayDetail; - gcn::Slider *mOverlayDetailSlider; - gcn::Label *mOverlayDetailField; - - int mParticleDetail; - gcn::Slider *mParticleDetailSlider; - gcn::Label *mParticleDetailField; - TextDialog *mDialog; }; diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 1cf35e4f2..9c172da04 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -30,7 +30,6 @@ #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/setupitem.h" #include "gui/widgets/slider.h" #include "resources/image.h" @@ -38,6 +37,7 @@ #include "configuration.h" #include "localplayer.h" #include "logger.h" +#include "particle.h" #include "utils/gettext.h" @@ -64,9 +64,46 @@ Setup_Visual::Setup_Visual() new SetupItemSlider(_("Gui opacity"), "", "guialpha", this, "guialphaEvent", 0.1, 1.0); + mSpeachList = new SetupItemNames(); + mSpeachList->push_back(_("No text")); + mSpeachList->push_back(_("Text")); + mSpeachList->push_back(_("Bubbles, no names")); + mSpeachList->push_back(_("Bubbles with names")); + new SetupItemSlider2(_("Overhead text"),"", "speech", this, + "speechEvent", 0, 3, mSpeachList); + + mAmbientFxList = new SetupItemNames(); + mAmbientFxList->push_back(_("off")); + mAmbientFxList->push_back(_("low")); + mAmbientFxList->push_back(_("high")); + new SetupItemSlider2(_("Ambient FX"), "", "OverlayDetail", this, + "OverlayDetailEvent", 0, 2, mAmbientFxList); + + new SetupItemCheckBox(_("Particle effects"), "", + "particleeffects", this, "particleeffectsEvent"); + + mParticleList = new SetupItemNames(); + mParticleList->push_back(_("low")); + mParticleList->push_back(_("medium")); + mParticleList->push_back(_("high")); + mParticleList->push_back(_("max")); + (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", + this, "particleEmitterSkipEvent", 0, 3, + mParticleList))->setInvertValue(3); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } +Setup_Visual::~Setup_Visual() +{ + delete mSpeachList; + mSpeachList = nullptr; + delete mAmbientFxList; + mAmbientFxList = nullptr; + delete mParticleList; + mParticleList = nullptr; +} + void Setup_Visual::apply() { SetupTabScroll::apply(); @@ -85,4 +122,13 @@ void Setup_Visual::action(const gcn::ActionEvent &event) Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); } } + else if (event.getId() == "particleEmitterSkipEvent") + { + Slider *slider = static_cast(event.getSource()); + if (slider) + { + int val = static_cast(slider->getValue()); + Particle::emitterSkip = 4 - val; + } + } } diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index c76002c06..60d8ac787 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -25,6 +25,7 @@ #include "guichanfwd.h" +#include "gui/widgets/setupitem.h" #include "gui/widgets/setuptabscroll.h" #include @@ -34,9 +35,18 @@ class Setup_Visual : public SetupTabScroll public: Setup_Visual(); + ~Setup_Visual(); + void apply(); void action(const gcn::ActionEvent &event A_UNUSED); + + private: + SetupItemNames *mSpeachList; + + SetupItemNames *mAmbientFxList; + + SetupItemNames *mParticleList; }; #endif diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 1d6bf5916..581d9f239 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -25,6 +25,7 @@ #include "logger.h" #include "gui/editdialog.h" +#include "gui/gui.h" #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" @@ -40,7 +41,9 @@ #include "utils/dtor.h" #include "utils/gettext.h" +#include "utils/mathutils.h" +#include SetupItem::SetupItem(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, @@ -591,10 +594,6 @@ void SetupItemDropDown::toWidget() } - - - - SetupItemSlider::SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, double min, double max, @@ -686,3 +685,157 @@ void SetupItemSlider::apply(std::string eventName) fromWidget(); save(); } + +SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, int min, int max, + SetupItemNames *values, bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mLabel2(nullptr), + mSlider(nullptr), + mValues(values), + mMin(min), + mMax(max), + mInvert(false), + mInvertValue(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, int min, int max, + SetupItemNames *values, std::string def, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, def, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mLabel2(nullptr), + mSlider(nullptr), + mValues(values), + mMin(min), + mMax(max), + mInvert(false), + mInvertValue(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSlider2::~SetupItemSlider2() +{ + mHorizont = nullptr; + mWidget = nullptr; + mSlider = nullptr; + mLabel = nullptr; +} + +void SetupItemSlider2::createControls() +{ + load(); + mHorizont = new HorizontContainer(32, 2); + + int width = getMaxWidth(); + + mLabel = new Label(mText); + mLabel2 = new Label(""); + mLabel2->setWidth(width); + mSlider = new Slider(mMin, mMax); + mSlider->setActionEventId(mEventName); + mSlider->addActionListener(mParent); + mSlider->setValue(atof(mValue.c_str())); + mSlider->setHeight(30); + + mWidget = mSlider; + mSlider->setWidth(150); + mSlider->setHeight(40); + mHorizont->add(mLabel); + mHorizont->add(mSlider, -10); + mHorizont->add(mLabel2); + + mParent->getContainer()->add2(mHorizont, true, 4); + mParent->addControl(this); + mParent->addActionListener(this); + mWidget->addActionListener(this); + updateLabel(); +} + +int SetupItemSlider2::getMaxWidth() +{ + if (!mValues || !gui) + return 1; + + int maxWidth = 0; + SetupItemNamesConstIter it = mValues->begin(); + SetupItemNamesConstIter it_end = mValues->end(); + gcn::Font *font = gui->getFont(); + + while (it != it_end) + { + int w = font->getWidth(*it); + if (w > maxWidth) + maxWidth = w; + + ++ it; + } + return maxWidth; +} + +void SetupItemSlider2::fromWidget() +{ + if (!mSlider) + return; + + int val = roundDouble(mSlider->getValue()); + if (mInvert) + val = mInvertValue - val; + mValue = toString(val); +} + +void SetupItemSlider2::toWidget() +{ + if (!mSlider) + return; + + int val = roundDouble(atof(mValue.c_str())); + if (mInvert) + val = mInvertValue - val; + mSlider->setValue(val); + updateLabel(); +} + +void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED) +{ + fromWidget(); + updateLabel(); +} + +void SetupItemSlider2::updateLabel() +{ + int val = mSlider->getValue() - mMin; + if (val < 0) + val = 0; + else if (val >= (signed)mValues->size()) + val = (signed)mValues->size() - 1; + std::string str = mValues->at(val); + mLabel2->setCaption(str); +} + +void SetupItemSlider2::apply(std::string eventName) +{ + if (eventName != mEventName) + return; + + fromWidget(); + save(); +} + +void SetupItemSlider2::setInvertValue(int v) +{ + mInvert = true; + mInvertValue = v; + toWidget(); +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 220a55494..cf847f55d 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -92,7 +92,6 @@ class SetupItem : public gcn::ActionListener virtual void cancel(std::string eventName); virtual void externalUpdated(std::string eventName); -// virtual int add(ContainerPlacer &place, int x, int y, int width); bool isMainConfig() const { return mMainConfig; } @@ -290,6 +289,8 @@ class SetupItemSlider : public SetupItem void apply(std::string eventName); + void updateLabel(); + protected: HorizontContainer *mHorizont; Label *mLabel; @@ -298,4 +299,52 @@ class SetupItemSlider : public SetupItem double mMax; }; +typedef std::vector SetupItemNames; +typedef SetupItemNames::iterator SetupItemNamesIter; +typedef SetupItemNames::const_iterator SetupItemNamesConstIter; + +class SetupItemSlider2 : public SetupItem +{ + public: + SetupItemSlider2(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, int min, int max, + SetupItemNames *values, bool mainConfig = true); + + SetupItemSlider2(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, int min, int max, + SetupItemNames *values, std::string def, + bool mainConfig = true); + + ~SetupItemSlider2(); + + void createControls(); + + void fromWidget(); + + void toWidget(); + + void action(const gcn::ActionEvent &event); + + void apply(std::string eventName); + + void setInvertValue(int v); + + protected: + void updateLabel(); + + int getMaxWidth(); + + HorizontContainer *mHorizont; + Label *mLabel; + Label *mLabel2; + Slider *mSlider; + SetupItemNames *mValues; + int mMin; + int mMax; + bool mInvert; + int mInvertValue; +}; + #endif diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index 9f6818146..8ccd71e79 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -112,4 +112,9 @@ inline float weightedAverage(float n1, float n2, float w) return w * n2 + (1.0f - w) * n1; } +inline int roundDouble(double v) +{ + return (v > 0.0) ? (v + 0.5) : (v - 0.5); +} + #endif // UTILS_MATHUTILS_H -- cgit v1.2.3-70-g09d2 From e4dabfe2b75a20378bdb1bf32b53249b5d55740b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 03:33:54 +0300 Subject: Bit cleanup visual settings page. --- src/client.cpp | 20 ++++++++++++++++++++ src/client.h | 2 ++ src/defaults.cpp | 2 ++ src/gui/setup_visual.cpp | 30 +++++------------------------- src/gui/setup_visual.h | 2 -- src/gui/widgets/setupitem.cpp | 30 +++++++++++++++++++++--------- src/gui/widgets/setupitem.h | 12 +++++++++--- 7 files changed, 59 insertions(+), 39 deletions(-) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index 949dbacd2..d0c573e13 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -563,6 +563,7 @@ void Client::gameInit() } applyGrabMode(); + applyGamma(); // Initialize for drawing mainGraphics->_beginDraw(); @@ -665,6 +666,8 @@ void Client::gameInit() setFramerate(fpsLimit); config.addListener("fpslimit", this); config.addListener("guialpha", this); + config.addListener("gamma", this); + config.addListener("particleEmitterSkip", this); setGuiAlpha(config.getFloatValue("guialpha")); optionChanged("fpslimit"); @@ -704,6 +707,8 @@ void Client::gameClear() logger->log1("Quitting1"); config.removeListener("fpslimit", this); config.removeListener("guialpha", this); + config.removeListener("gamma", this); + config.removeListener("particleEmitterSkip", this); SDL_RemoveTimer(mLogicCounterId); SDL_RemoveTimer(mSecondsCounterId); @@ -1492,6 +1497,15 @@ void Client::optionChanged(const std::string &name) else if (name == "guialpha") { setGuiAlpha(config.getFloatValue("guialpha")); + Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); + } + else if (name == "gamma") + { + applyGamma(); + } + else if (name == "particleEmitterSkip") + { + Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1; } } @@ -2437,3 +2451,9 @@ void Client::applyGrabMode() SDL_WM_GrabInput(config.getBoolValue("grabinput") ? SDL_GRAB_ON : SDL_GRAB_OFF); } + +void Client::applyGamma() +{ + float val = config.getFloatValue("gamma"); + SDL_SetGamma(val, val, val); +} \ No newline at end of file diff --git a/src/client.h b/src/client.h index ba6fde480..922b24caf 100644 --- a/src/client.h +++ b/src/client.h @@ -275,6 +275,8 @@ public: static void applyGrabMode(); + void applyGamma(); + void optionChanged(const std::string &name); void action(const gcn::ActionEvent &event); diff --git a/src/defaults.cpp b/src/defaults.cpp index b21941bfb..865330827 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -226,6 +226,8 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "enableresize", true); AddDEF(configData, "noframe", false); AddDEF(configData, "groupFriends", true); + AddDEF(configData, "grabinput", false); + AddDEF(configData, "gamma", 1); return configData; } diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 9c172da04..5e072b53b 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -62,7 +62,7 @@ Setup_Visual::Setup_Visual() "", "grabinput", this, "grabinputEvent"); new SetupItemSlider(_("Gui opacity"), "", "guialpha", - this, "guialphaEvent", 0.1, 1.0); + this, "guialphaEvent", 0.1, 1.0, 150, true); mSpeachList = new SetupItemNames(); mSpeachList->push_back(_("No text")); @@ -89,7 +89,10 @@ Setup_Visual::Setup_Visual() mParticleList->push_back(_("max")); (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", this, "particleEmitterSkipEvent", 0, 3, - mParticleList))->setInvertValue(3); + mParticleList, true))->setInvertValue(3); + + new SetupItemSlider(_("Gamma"), "", "gamma", + this, "gammeEvent", 1, 20, 350, true); setDimension(gcn::Rectangle(0, 0, 550, 350)); } @@ -107,28 +110,5 @@ Setup_Visual::~Setup_Visual() void Setup_Visual::apply() { SetupTabScroll::apply(); - Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); Client::applyGrabMode(); } - -void Setup_Visual::action(const gcn::ActionEvent &event) -{ - if (event.getId() == "guialphaEvent") - { - Slider *slider = static_cast(event.getSource()); - if (slider) - { - config.setValue("guialpha", slider->getValue()); - Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); - } - } - else if (event.getId() == "particleEmitterSkipEvent") - { - Slider *slider = static_cast(event.getSource()); - if (slider) - { - int val = static_cast(slider->getValue()); - Particle::emitterSkip = 4 - val; - } - } -} diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index 60d8ac787..30ae18645 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -39,8 +39,6 @@ class Setup_Visual : public SetupTabScroll void apply(); - void action(const gcn::ActionEvent &event A_UNUSED); - private: SetupItemNames *mSpeachList; diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 581d9f239..490c046c3 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -597,13 +597,15 @@ void SetupItemDropDown::toWidget() SetupItemSlider::SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, double min, double max, - bool mainConfig) : + int width, bool onTheFly, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), mSlider(nullptr), mMin(min), - mMax(max) + mMax(max), + mWidth(width), + mOnTheFly(onTheFly) { mValueType = VSTR; createControls(); @@ -612,13 +614,16 @@ SetupItemSlider::SetupItemSlider(std::string text, std::string description, SetupItemSlider::SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, double min, double max, - std::string def, bool mainConfig) : + std::string def, int width, bool onTheFly, + bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), mSlider(nullptr), mMin(min), - mMax(max) + mMax(max), + mWidth(width), + mOnTheFly(onTheFly) { mValueType = VSTR; createControls(); @@ -645,7 +650,7 @@ void SetupItemSlider::createControls() mSlider->setHeight(30); mWidget = mSlider; - mSlider->setWidth(150); + mSlider->setWidth(mWidth); mSlider->setHeight(40); mHorizont->add(mLabel); mHorizont->add(mSlider, -10); @@ -675,6 +680,8 @@ void SetupItemSlider::toWidget() void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED) { fromWidget(); + if (mOnTheFly) + save(); } void SetupItemSlider::apply(std::string eventName) @@ -689,7 +696,8 @@ void SetupItemSlider::apply(std::string eventName) SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, int min, int max, - SetupItemNames *values, bool mainConfig) : + SetupItemNames *values, bool onTheFly, + bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -699,7 +707,8 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, mMin(min), mMax(max), mInvert(false), - mInvertValue(0) + mInvertValue(0), + mOnTheFly(onTheFly) { mValueType = VSTR; createControls(); @@ -709,7 +718,7 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, int min, int max, SetupItemNames *values, std::string def, - bool mainConfig) : + bool onTheFly, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -719,7 +728,8 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, mMin(min), mMax(max), mInvert(false), - mInvertValue(0) + mInvertValue(0), + mOnTheFly(onTheFly) { mValueType = VSTR; createControls(); @@ -811,6 +821,8 @@ void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED) { fromWidget(); updateLabel(); + if (mOnTheFly) + save(); } void SetupItemSlider2::updateLabel() diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index cf847f55d..b950d1488 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -270,12 +270,14 @@ class SetupItemSlider : public SetupItem SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, double min, double max, + int width = 150, bool onTheFly = false, bool mainConfig = true); SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, double min, double max, - std::string def, bool mainConfig = true); + std::string def, int width = 150, + bool onTheFly = false, bool mainConfig = true); ~SetupItemSlider(); @@ -297,6 +299,8 @@ class SetupItemSlider : public SetupItem Slider *mSlider; double mMin; double mMax; + int mWidth; + bool mOnTheFly; }; typedef std::vector SetupItemNames; @@ -309,13 +313,14 @@ class SetupItemSlider2 : public SetupItem SetupItemSlider2(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, int min, int max, - SetupItemNames *values, bool mainConfig = true); + SetupItemNames *values, bool onTheFly = false, + bool mainConfig = true); SetupItemSlider2(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, int min, int max, SetupItemNames *values, std::string def, - bool mainConfig = true); + bool onTheFly = false, bool mainConfig = true); ~SetupItemSlider2(); @@ -345,6 +350,7 @@ class SetupItemSlider2 : public SetupItem int mMax; bool mInvert; int mInvertValue; + bool mOnTheFly; }; #endif -- cgit v1.2.3-70-g09d2 From 8d60ace7ad6c9dffabdd5ed71374d82360dc2d2e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 18:41:03 +0300 Subject: Fix code style. --- src/client.cpp | 2 +- src/gui/setup_visual.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index d0c573e13..b853f1908 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2456,4 +2456,4 @@ void Client::applyGamma() { float val = config.getFloatValue("gamma"); SDL_SetGamma(val, val, val); -} \ No newline at end of file +} diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 5e072b53b..22df1ffa7 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -69,7 +69,7 @@ Setup_Visual::Setup_Visual() mSpeachList->push_back(_("Text")); mSpeachList->push_back(_("Bubbles, no names")); mSpeachList->push_back(_("Bubbles with names")); - new SetupItemSlider2(_("Overhead text"),"", "speech", this, + new SetupItemSlider2(_("Overhead text"), "", "speech", this, "speechEvent", 0, 3, mSpeachList); mAmbientFxList = new SetupItemNames(); -- cgit v1.2.3-70-g09d2 From 826ead0896ab8d47ec032627e39874c859260736 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 23:58:54 +0300 Subject: Add vsync option. --- src/client.cpp | 14 ++++++++++++++ src/client.h | 2 ++ src/gui/setup_visual.cpp | 9 +++++++++ src/gui/setup_visual.h | 2 ++ 4 files changed, 27 insertions(+) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index b853f1908..242bb2f21 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -564,6 +564,7 @@ void Client::gameInit() applyGrabMode(); applyGamma(); + applyVSync(); // Initialize for drawing mainGraphics->_beginDraw(); @@ -668,6 +669,7 @@ void Client::gameInit() config.addListener("guialpha", this); config.addListener("gamma", this); config.addListener("particleEmitterSkip", this); + config.addListener("vsync", this); setGuiAlpha(config.getFloatValue("guialpha")); optionChanged("fpslimit"); @@ -709,6 +711,7 @@ void Client::gameClear() config.removeListener("guialpha", this); config.removeListener("gamma", this); config.removeListener("particleEmitterSkip", this); + config.removeListener("vsync", this); SDL_RemoveTimer(mLogicCounterId); SDL_RemoveTimer(mSecondsCounterId); @@ -1507,6 +1510,10 @@ void Client::optionChanged(const std::string &name) { Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1; } + else if (name == "vsync") + { + applyVSync(); + } } void Client::action(const gcn::ActionEvent &event) @@ -2457,3 +2464,10 @@ void Client::applyGamma() float val = config.getFloatValue("gamma"); SDL_SetGamma(val, val, val); } + +void Client::applyVSync() +{ + int val = config.getIntValue("vsync"); + if (val > 0 && val < 2) + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val); +} diff --git a/src/client.h b/src/client.h index 922b24caf..54de27824 100644 --- a/src/client.h +++ b/src/client.h @@ -277,6 +277,8 @@ public: void applyGamma(); + void applyVSync(); + void optionChanged(const std::string &name); void action(const gcn::ActionEvent &event); diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 22df1ffa7..454a2c3f6 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -94,6 +94,13 @@ Setup_Visual::Setup_Visual() new SetupItemSlider(_("Gamma"), "", "gamma", this, "gammeEvent", 1, 20, 350, true); + mVSyncList = new SetupItemNames(); + mVSyncList->push_back(_("default")); + mVSyncList->push_back(_("off")); + mVSyncList->push_back(_("on")); + new SetupItemSlider2(_("Vsync"), "", "vsync", this, + "vsyncEvent", 0, 2, mVSyncList); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } @@ -105,6 +112,8 @@ Setup_Visual::~Setup_Visual() mAmbientFxList = nullptr; delete mParticleList; mParticleList = nullptr; + delete mVSyncList; + mVSyncList = nullptr; } void Setup_Visual::apply() diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index 30ae18645..3c4c8a6d2 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -45,6 +45,8 @@ class Setup_Visual : public SetupTabScroll SetupItemNames *mAmbientFxList; SetupItemNames *mParticleList; + + SetupItemNames *mVSyncList; }; #endif -- cgit v1.2.3-70-g09d2 From 28aa543a0a1927e88b2968a30fd068e1536da0ef Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 23:59:13 +0300 Subject: Fix compilation for windows. --- src/gui/setup_visual.cpp | 15 +-------------- src/gui/setup_visual.h | 2 -- 2 files changed, 1 insertion(+), 16 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 454a2c3f6..f7a083498 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -22,22 +22,10 @@ #include "gui/setup_visual.h" -#include "gui/chatwindow.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/chattab.h" -#include "gui/widgets/checkbox.h" -#include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/slider.h" - -#include "resources/image.h" -#include "configuration.h" -#include "localplayer.h" -#include "logger.h" -#include "particle.h" +#include "client.h" #include "utils/gettext.h" @@ -46,7 +34,6 @@ Setup_Visual::Setup_Visual() { setName(_("Visual")); - // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h index 3c4c8a6d2..028f366b8 100644 --- a/src/gui/setup_visual.h +++ b/src/gui/setup_visual.h @@ -28,8 +28,6 @@ #include "gui/widgets/setupitem.h" #include "gui/widgets/setuptabscroll.h" -#include - class Setup_Visual : public SetupTabScroll { public: -- cgit v1.2.3-70-g09d2 From a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 22 Feb 2012 19:50:00 +0300 Subject: Fix code style. --- build/bmake | 1 - src/configuration.cpp | 2 +- src/effectmanager.h | 1 + src/gui/setup_joystick.cpp | 2 +- src/guichan/color.cpp | 18 +++++++++--------- src/guichan/defaultfont.cpp | 2 +- src/guichan/focushandler.cpp | 20 ++++++++++---------- src/guichan/include/guichan/sdl/sdlpixel.hpp | 23 +++++++++++++---------- src/guichan/sdl/sdlimage.cpp | 4 ++-- src/localplayer.cpp | 2 +- src/opengl1graphics.h | 4 ++-- src/openglgraphics.h | 6 +++--- src/particleemitterprop.h | 1 + src/utils/mathutils.h | 2 ++ src/utils/translation/poparser.cpp | 2 +- 15 files changed, 48 insertions(+), 42 deletions(-) (limited to 'src/gui') diff --git a/build/bmake b/build/bmake index d99766ea7..33df5d180 100755 --- a/build/bmake +++ b/build/bmake @@ -8,7 +8,6 @@ cd .. #for feature #-Wstrict-overflow=4 -Wfloat-equal #-Wunsafe-loop-optimizations -#-Wnon-virtual-dtor #-Woverloaded-virtual #-Wformat=2 #-Wswitch-enum diff --git a/src/configuration.cpp b/src/configuration.cpp index 1ff205195..694f94e78 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -334,7 +334,7 @@ float Configuration::getFloatValue(const std::string &key) const (static_cast(itdef->second))->getData()); } else if (itdef->second->getType() - == VariableData::DATA_STRING) + == VariableData::DATA_STRING) { defaultValue = atof((static_cast( itdef->second))->getData().c_str()); diff --git a/src/effectmanager.h b/src/effectmanager.h index df19a0040..f8babd2f5 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -24,6 +24,7 @@ #include #include +#include class Being; diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 290607be4..a3240282a 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -146,7 +146,7 @@ void Setup_Joystick::action(const gcn::ActionEvent &event) { mCalibrateButton->setCaption(_("Stop")); mCalibrateLabel->setCaption( - _("Rotate the stick and dont press buttons")); + _("Rotate the stick and don't press buttons")); joystick->startCalibration(); } } diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp index d3dc7a738..f58e7b58e 100644 --- a/src/guichan/color.cpp +++ b/src/guichan/color.cpp @@ -97,23 +97,23 @@ namespace gcn b - color.b, 255); - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); return result; } Color Color::operator*(float value) const { - Color result((int)(r * value), - (int)(g * value), - (int)(b * value), + Color result(static_cast(r * value), + static_cast(g * value), + static_cast(b * value), a); - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); return result; } diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp index 8871d51de..70901bc8e 100644 --- a/src/guichan/defaultfont.cpp +++ b/src/guichan/defaultfont.cpp @@ -89,7 +89,7 @@ namespace gcn int DefaultFont::getStringIndexAt(const std::string& text, int x) const { - if (x > (int)text.size() * 8) + if (x > static_cast(text.size() * 8)) return text.size(); return x / 8; diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 832a201ad..e3610fb1e 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -158,7 +158,7 @@ namespace gcn { int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast(mWidgets.size()); ++i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -167,7 +167,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast(mWidgets.size()); do { ++ focusedWidget; @@ -180,7 +180,7 @@ namespace gcn -- i; - if (focusedWidget >= (int)mWidgets.size()) + if (focusedWidget >= static_cast(mWidgets.size())) focusedWidget = 0; if (focusedWidget == focused) @@ -213,7 +213,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++ i) + for (i = 0; i < static_cast(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -222,7 +222,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast(mWidgets.size()); do { -- focusedWidget; @@ -342,7 +342,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -352,7 +352,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast(mWidgets.size()); do { ++ focusedWidget; @@ -365,7 +365,7 @@ namespace gcn -- i; - if (focusedWidget >= (int)mWidgets.size()) + if (focusedWidget >= static_cast(mWidgets.size())) focusedWidget = 0; if (focusedWidget == focused) @@ -411,7 +411,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -421,7 +421,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast(mWidgets.size()); do { -- focusedWidget; diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index a0221ca7c..bfd08341b 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -68,7 +68,8 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; unsigned int color = 0; @@ -79,7 +80,7 @@ namespace gcn break; case 2: - color = *(Uint16 *)p; + color = *reinterpret_cast(p); break; case 3: @@ -90,7 +91,7 @@ namespace gcn break; case 4: - color = *(Uint32 *)p; + color = *reinterpret_cast(p); break; default: @@ -123,7 +124,7 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); @@ -134,7 +135,7 @@ namespace gcn break; case 2: - *(Uint16 *)p = pixel; + *reinterpret_cast(p) = pixel; break; case 3: @@ -153,7 +154,7 @@ namespace gcn break; case 4: - *(Uint32 *)p = pixel; + *reinterpret_cast(p) = pixel; break; default: @@ -199,7 +200,7 @@ namespace gcn unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) * (255 - a)) >> 8; - return (unsigned short)((b & f->Rmask) + return static_cast((b & f->Rmask) | (g & f->Gmask) | (r & f->Bmask)); } @@ -230,7 +231,8 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); @@ -241,7 +243,7 @@ namespace gcn break; case 2: - *(Uint16 *)p = SDLAlpha16(pixel, *(Uint32 *)p, + *reinterpret_cast(p) = SDLAlpha16(pixel, *(Uint32 *)p, color.a, surface->format); break; @@ -275,7 +277,8 @@ namespace gcn break; case 4: - *(Uint32 *)p = SDLAlpha32(pixel, *(Uint32 *)p, color.a); + *reinterpret_cast(p) = SDLAlpha32(pixel, + *reinterpret_cast(p), color.a); break; default: break; diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index e4aadc465..4f9b9565c 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -130,8 +130,8 @@ namespace gcn for (i = 0; i < mSurface->w * mSurface->h; ++i) { - if (((unsigned int*)mSurface->pixels)[i] == SDL_MapRGB( - mSurface->format, 255, 0, 255)) + if ((static_cast(mSurface->pixels))[i] + == SDL_MapRGB(mSurface->format, 255, 0, 255)) { hasPink = true; break; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 03199f7be..b07511196 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2153,7 +2153,7 @@ static const char *pvpAttackStrings[] = N_("(a) attack all players"), N_("(f) attack all except friends"), N_("(b) attack bad relations"), - N_("(d) dont attack players"), + N_("(d) don't attack players"), N_("(?) pvp attack") }; diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h index 76dc3ef00..8cc3c89a7 100644 --- a/src/opengl1graphics.h +++ b/src/opengl1graphics.h @@ -23,15 +23,14 @@ #ifndef OPENGL1GRAPHICS_H #define OPENGL1GRAPHICS_H +#ifdef USE_OPENGL #include "main.h" #include "graphics.h" -#ifdef USE_OPENGL #define NO_SDL_GLEXT #include -#endif class OpenGL1Graphics : public Graphics { @@ -140,5 +139,6 @@ class OpenGL1Graphics : public Graphics bool mColorAlpha; bool mSync; }; +#endif #endif diff --git a/src/openglgraphics.h b/src/openglgraphics.h index f3bdc4470..9eeb530ac 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -23,15 +23,14 @@ #ifndef OPENGLGRAPHICS_H #define OPENGLGRAPHICS_H -#include "main.h" +#ifdef USE_OPENGL +#include "main.h" #include "graphics.h" -#ifdef USE_OPENGL #define NO_SDL_GLEXT #include -#endif class OpenGLGraphics : public Graphics { @@ -154,5 +153,6 @@ class OpenGLGraphics : public Graphics bool mColorAlpha; bool mSync; }; +#endif #endif diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h index cadfa0f3a..2b6b7ba1a 100644 --- a/src/particleemitterprop.h +++ b/src/particleemitterprop.h @@ -21,6 +21,7 @@ */ #include +#include /** * Returns a random numeric value that is larger than or equal min and smaller diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index 8ccd71e79..6d5a8339d 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -23,7 +23,9 @@ #ifndef UTILS_MATHUTILS_H #define UTILS_MATHUTILS_H +#include #include +#include static uint16_t crc_table[256] = { diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index 24d2ee4d4..521774592 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -144,7 +144,7 @@ bool PoParser::readMsgId() mLine = ""; return true; } - // stop reading if we dont read msgid before + // stop reading if we don't read msgid before return mMsgId.empty(); } } -- cgit v1.2.3-70-g09d2 From b908c4df2da79adb0108d9d6243a83633eec1cc2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Feb 2012 02:54:43 +0300 Subject: Fix GPL license. Add missing manaplus copyright. --- src/chatlogger.cpp | 3 +-- src/chatlogger.h | 3 +-- src/dropshortcut.cpp | 3 +-- src/dropshortcut.h | 3 +-- src/gui/botcheckerwindow.cpp | 3 +-- src/gui/botcheckerwindow.h | 3 +-- src/gui/editdialog.cpp | 3 +-- src/gui/editdialog.h | 3 +-- src/gui/killstats.cpp | 3 +-- src/gui/killstats.h | 3 +-- src/gui/sdlinput.h | 1 + src/gui/setup_chat.cpp | 3 +-- src/gui/setup_chat.h | 3 +-- src/gui/setup_other.cpp | 3 +-- src/gui/setup_other.h | 3 +-- src/gui/setup_perfomance.cpp | 3 +-- src/gui/setup_perfomance.h | 3 +-- src/gui/setup_players.cpp | 3 +-- src/gui/setup_players.h | 3 +-- src/gui/setup_theme.cpp | 3 +-- src/gui/setup_theme.h | 3 +-- src/gui/spellpopup.cpp | 3 +-- src/gui/spellpopup.h | 3 +-- src/gui/statuspopup.cpp | 3 +-- src/gui/statuspopup.h | 3 +-- src/gui/textcommandeditor.cpp | 3 +-- src/gui/textcommandeditor.h | 3 +-- src/gui/textpopup.cpp | 3 +-- src/gui/textpopup.h | 3 +-- src/gui/whoisonline.cpp | 3 +-- src/gui/whoisonline.h | 3 +-- src/gui/widgets/dropshortcutcontainer.cpp | 3 +-- src/gui/widgets/dropshortcutcontainer.h | 3 +-- src/gui/widgets/spellshortcutcontainer.cpp | 3 +-- src/gui/widgets/spellshortcutcontainer.h | 3 +-- src/net/beinghandler.h | 3 +-- src/spellmanager.cpp | 3 +-- src/spellmanager.h | 3 +-- src/spellshortcut.cpp | 3 +-- src/spellshortcut.h | 3 +-- src/textcommand.cpp | 3 +-- src/textcommand.h | 3 +-- 42 files changed, 42 insertions(+), 82 deletions(-) (limited to 'src/gui') diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index b8418edda..4c4f2ce83 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "chatlogger.h" diff --git a/src/chatlogger.h b/src/chatlogger.h index bb02d8127..26fa2e37f 100644 --- a/src/chatlogger.h +++ b/src/chatlogger.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef M_CHATLOGGER_H diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index 5b01f7f4f..f6fd0bc93 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "dropshortcut.h" diff --git a/src/dropshortcut.h b/src/dropshortcut.h index 31c20677d..f11123b1b 100644 --- a/src/dropshortcut.h +++ b/src/dropshortcut.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef DROPSHORTCUT_H diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 4a092ab55..87b7517ce 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "botcheckerwindow.h" diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index 86d5ef290..f2df981e3 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef BOTCHECKER_H diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp index 84f4f6ddf..178eef970 100644 --- a/src/gui/editdialog.cpp +++ b/src/gui/editdialog.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/editdialog.h" diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h index ef260acfb..f3a1d90dd 100644 --- a/src/gui/editdialog.h +++ b/src/gui/editdialog.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef EDIT_DIALOG_H diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 357a016f2..1334e1f95 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/killstats.h" diff --git a/src/gui/killstats.h b/src/gui/killstats.h index 9773190de..60438b4d3 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef KILLSTATS_H diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index b441380a4..17cb4ea8a 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -8,6 +8,7 @@ * * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson * Copyright (C) 2007-2010 The Mana World Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * Js_./ * Per Larsson a.k.a finalman _RqZ{a<^_aa diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 7e81acaa9..4bfb8928e 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/setup_chat.h" diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h index 238021cca..858dadf3a 100644 --- a/src/gui/setup_chat.h +++ b/src/gui/setup_chat.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef GUI_SETUP_CHAT_H diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index d6f5e9972..3ea5f4e4a 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/setup_other.h" diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h index 4144a02ab..182a3f4c6 100644 --- a/src/gui/setup_other.h +++ b/src/gui/setup_other.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef GUI_Setup_Other_H diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index 95703fa4c..976f1123b 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/setup_perfomance.h" diff --git a/src/gui/setup_perfomance.h b/src/gui/setup_perfomance.h index 097c1e28c..178cf3265 100644 --- a/src/gui/setup_perfomance.h +++ b/src/gui/setup_perfomance.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef GUI_SETUP_PERFOMANCE_H diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index a08517fae..b2cd7847d 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/setup_players.h" diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index ebfc78db6..8db486eb0 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef GUI_SETUP_PLAYERS_H diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 67936f698..fc83bfac2 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/setup_theme.h" diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h index 1ff159195..c14957388 100644 --- a/src/gui/setup_theme.h +++ b/src/gui/setup_theme.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef GUI_Setup_Theme_H diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 48037f03e..06e60604c 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/spellpopup.h" diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 883b2bfe0..643a14079 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef SPELLPOPUP_H diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 3e1f68d09..0646fcdda 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/statuspopup.h" diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h index 976b5e57b..9ff1af4c7 100644 --- a/src/gui/statuspopup.h +++ b/src/gui/statuspopup.h @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef StatusPopup_H diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 7d97549f3..10cd7968f 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/textcommandeditor.h" diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index d0b2f0a54..dd9bfd0ca 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef TEXTCOMMANDEDITOR_H diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 8cdbfa430..afece5319 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/textpopup.h" diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index 6f418152c..d06315171 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -18,8 +18,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef TEXTPOPUP_H diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 7e4f02426..2aec28360 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/whoisonline.h" diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 1607286a9..49851837e 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef WHOISONLINE_H diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 8335a61bc..47060cdfb 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/widgets/dropshortcutcontainer.h" diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 1f03fd53b..3f1af0329 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef DROPSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 5c4dbc9a1..130b245fb 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "gui/widgets/spellshortcutcontainer.h" diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 4191f9921..c5dacea80 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef SPELLSHORTCUTCONTAINER_H diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index bc1491ada..66ea6fe17 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -16,8 +16,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef BEINGHANDLER_H diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index ebdff6382..144881a43 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "spellmanager.h" diff --git a/src/spellmanager.h b/src/spellmanager.h index 651ada56c..cf7e18e85 100644 --- a/src/spellmanager.h +++ b/src/spellmanager.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef SPELLMANAGER_H diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp index 67171524c..bf4a62a98 100644 --- a/src/spellshortcut.cpp +++ b/src/spellshortcut.cpp @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "configuration.h" diff --git a/src/spellshortcut.h b/src/spellshortcut.h index 047ccdef3..e0e722524 100644 --- a/src/spellshortcut.h +++ b/src/spellshortcut.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef SPELLSHORTCUT_H diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 8801ef149..48dc86dab 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -16,8 +16,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #include "textcommand.h" diff --git a/src/textcommand.h b/src/textcommand.h index 6677b97e9..12f7e0760 100644 --- a/src/textcommand.h +++ b/src/textcommand.h @@ -17,8 +17,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . */ #ifndef TEXTCOMMAND_H -- cgit v1.2.3-70-g09d2 From 56dfa92acb9b94a0f9f8e085bb1a05ec94875516 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Feb 2012 20:06:42 +0300 Subject: Fix copyrights. --- src/gui/botcheckerwindow.cpp | 2 +- src/gui/botcheckerwindow.h | 2 +- src/utils/copynpaste.cpp | 2 +- src/utils/copynpaste.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 87b7517ce..3ed93e875 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index f2df981e3..82b29770f 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index d918c8108..49934c7be 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -1,7 +1,7 @@ /* * Retrieve string pasted depending on OS mechanisms. * Copyright (C) 2001-2010 Wormux Team - * Copyright (C) 2011 ManaPlus Developers + * Copyright (C) 2011-2012 ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h index 03596d5d1..e2bd0558c 100644 --- a/src/utils/copynpaste.h +++ b/src/utils/copynpaste.h @@ -1,6 +1,7 @@ /* * Retrieve string pasted depending on OS mechanisms. * Copyright (C) 2001-2010 Wormux Team + * Copyright (C) 2011-2012 ManaPlus Developers * * This file is part of The ManaPlus Client. * -- cgit v1.2.3-70-g09d2 From a5926417dad1f91966ccacfc5572369d309c59be Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 24 Feb 2012 00:26:56 +0300 Subject: More copyright fixes. --- src/dropshortcut.cpp | 2 +- src/dropshortcut.h | 2 +- src/effectmanager.cpp | 1 + src/effectmanager.h | 1 + src/emoteshortcut.cpp | 1 + src/emoteshortcut.h | 1 + src/gui/botcheckerwindow.cpp | 2 +- src/gui/botcheckerwindow.h | 2 +- src/gui/editdialog.cpp | 2 +- src/gui/editdialog.h | 2 +- src/gui/killstats.cpp | 2 +- src/gui/killstats.h | 2 +- src/gui/setup_keyboard.h | 3 +++ src/gui/setup_theme.cpp | 4 ++-- src/gui/setup_theme.h | 2 +- src/gui/spellpopup.cpp | 2 +- src/gui/spellpopup.h | 2 +- src/gui/statuspopup.cpp | 2 +- src/gui/statuspopup.h | 2 +- src/gui/textcommandeditor.cpp | 2 +- src/gui/textcommandeditor.h | 2 +- src/gui/whoisonline.cpp | 2 +- src/gui/whoisonline.h | 2 +- src/gui/widgets/desktop.cpp | 1 + src/gui/widgets/desktop.h | 1 + src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emoteshortcutcontainer.cpp | 1 + src/gui/widgets/emoteshortcutcontainer.h | 1 + src/gui/widgets/label.cpp | 1 + src/gui/widgets/label.h | 1 + src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.h | 2 +- src/keyboardconfig.cpp | 2 ++ src/keyboardconfig.h | 2 ++ src/net/beinghandler.h | 2 +- src/net/ea/partyhandler.cpp | 1 + src/net/ea/partyhandler.h | 1 + src/net/tmwa/partyhandler.cpp | 1 + src/net/tmwa/partyhandler.h | 1 + src/resources/emotedb.cpp | 1 + src/resources/emotedb.h | 1 + src/spellmanager.cpp | 2 +- src/spellmanager.h | 2 +- src/spellshortcut.cpp | 2 +- src/spellshortcut.h | 2 +- src/textcommand.cpp | 1 + src/textcommand.h | 2 +- src/textmanager.cpp | 1 + src/textmanager.h | 1 + src/utils/copynpaste.cpp | 2 +- src/utils/copynpaste.h | 2 +- 52 files changed, 57 insertions(+), 31 deletions(-) (limited to 'src/gui') diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index f6fd0bc93..410af8739 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/dropshortcut.h b/src/dropshortcut.h index f11123b1b..6a0ef49e9 100644 --- a/src/dropshortcut.h +++ b/src/dropshortcut.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index de12ecaa5..b52d2ac22 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -2,6 +2,7 @@ * An effects manager * Copyright (C) 2008 Fate * Copyright (C) 2008 Chuck Miller + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/effectmanager.h b/src/effectmanager.h index f8babd2f5..7b71069fe 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -2,6 +2,7 @@ * An effects manager * Copyright (C) 2008 Fate * Copyright (C) 2008 Chuck Miller + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp index 352c373b5..d0b5d9be5 100644 --- a/src/emoteshortcut.cpp +++ b/src/emoteshortcut.cpp @@ -1,6 +1,7 @@ /* * Extended support for activating emotes * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h index d7f1e7b79..c47569738 100644 --- a/src/emoteshortcut.h +++ b/src/emoteshortcut.h @@ -1,6 +1,7 @@ /* * Extended support for activating emotes * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 3ed93e875..2739978cb 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2012 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index 82b29770f..b1075686f 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2012 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp index 178eef970..1bd3ccbf5 100644 --- a/src/gui/editdialog.cpp +++ b/src/gui/editdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h index f3a1d90dd..206a45079 100644 --- a/src/gui/editdialog.h +++ b/src/gui/editdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 1334e1f95..e563b8c7c 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/killstats.h b/src/gui/killstats.h index 60438b4d3..67c2967e3 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index bffa13cf6..5970a7735 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -1,6 +1,9 @@ /* * Custom keyboard shortcuts configuration * Copyright (C) 2007 Joshua Langley + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index fc83bfac2..d4a1d5652 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -1,8 +1,8 @@ /* * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h index c14957388..496ba2aca 100644 --- a/src/gui/setup_theme.h +++ b/src/gui/setup_theme.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 06e60604c..9446f7515 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 643a14079..e64b510fc 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 0646fcdda..2d9cc69b6 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h index 9ff1af4c7..e867f0fa9 100644 --- a/src/gui/statuspopup.h +++ b/src/gui/statuspopup.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 10cd7968f..7b9442318 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index dd9bfd0ca..39952f353 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 2aec28360..15c8a42c4 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 49851837e..46fe74f62 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index b40558c78..6352c300f 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -1,6 +1,7 @@ /* * Desktop widget * Copyright (c) 2009-2010 The Mana World Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index b1f059ffe..e4edc8857 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -1,6 +1,7 @@ /* * Desktop widget * Copyright (c) 2009-2010 The Mana World Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 47060cdfb..8c6aec68a 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 3f1af0329..91e436836 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 794357275..8d828a87e 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -1,6 +1,7 @@ /* * Extended support for activating emotes * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 743ca4e87..f509798bb 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -1,6 +1,7 @@ /* * Extended support for activating emotes * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 67e8bd12b..640010c62 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (c) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 775eda18c..f2048c94a 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (c) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 130b245fb..07ecbfaf0 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index c5dacea80..72fec758f 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index ea04a0e89..fc676dab0 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -1,6 +1,8 @@ /* * Custom keyboard shortcuts configuration * Copyright (C) 2007 Joshua Langley + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index 1610c1ecd..1c91159ac 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -1,6 +1,8 @@ /* * Custom keyboard shortcuts configuration * Copyright (C) 2007 Joshua Langley + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index 66ea6fe17..49ce3a01c 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2004 The Mana World Development Team - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 556e72c8d..68d712db1 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2008 Lloyd Bryant + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 596fda4f7..f08930e8c 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2008 Lloyd Bryant + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 7f942a206..b8f3a07e1 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2008 Lloyd Bryant + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 4d727a986..eb3f68a70 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -1,6 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2008 Lloyd Bryant + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index d6c01af6d..4fe036528 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -1,6 +1,7 @@ /* * Emote database * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h index 94d97a872..f739b1ed0 100644 --- a/src/resources/emotedb.h +++ b/src/resources/emotedb.h @@ -1,6 +1,7 @@ /* * Emote database * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 144881a43..1e4c43f1f 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/spellmanager.h b/src/spellmanager.h index cf7e18e85..ae928ee7a 100644 --- a/src/spellmanager.h +++ b/src/spellmanager.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp index bf4a62a98..27ccc1646 100644 --- a/src/spellshortcut.cpp +++ b/src/spellshortcut.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers. + * Copyright (C) 2011-2012 The ManaPlus developers. * * This file is part of The ManaPlus Client. * diff --git a/src/spellshortcut.h b/src/spellshortcut.h index e0e722524..f3e5611e4 100644 --- a/src/spellshortcut.h +++ b/src/spellshortcut.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 48dc86dab..ec9e97f61 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -2,6 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/textcommand.h b/src/textcommand.h index 12f7e0760..7cab06317 100644 --- a/src/textcommand.h +++ b/src/textcommand.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 ManaPlus developers + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 6c73d00b4..3cd36e449 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -1,6 +1,7 @@ /* * Support for non-overlapping floating text * Copyright (C) 2008 Douglas Boffey + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/textmanager.h b/src/textmanager.h index 1ed88883a..220f30da3 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -1,6 +1,7 @@ /* * Support for non-overlapping floating text * Copyright (C) 2008 Douglas Boffey + * Copyright (C) 2011-2012 The ManaPlus developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 49934c7be..90e0c5c93 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -1,7 +1,7 @@ /* * Retrieve string pasted depending on OS mechanisms. * Copyright (C) 2001-2010 Wormux Team - * Copyright (C) 2011-2012 ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h index e2bd0558c..5e95a1152 100644 --- a/src/utils/copynpaste.h +++ b/src/utils/copynpaste.h @@ -1,7 +1,7 @@ /* * Retrieve string pasted depending on OS mechanisms. * Copyright (C) 2001-2010 Wormux Team - * Copyright (C) 2011-2012 ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * -- cgit v1.2.3-70-g09d2 From 490a93a1d7a347ab586637bf9d8163e114285a02 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 24 Feb 2012 22:21:02 +0300 Subject: Add safe error string reporting function. --- src/client.cpp | 4 ++-- src/gui/setup_video.cpp | 2 +- src/logger.cpp | 30 +++++++++++++++++++++++++++++- src/logger.h | 7 +++++++ src/net/manaserv/network.cpp | 8 ++++---- src/net/tmwa/network.cpp | 2 +- 6 files changed, 44 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index 242bb2f21..978c58eef 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -363,7 +363,7 @@ void Client::gameInit() logger->log1("Initializing SDL..."); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { - logger->error(strprintf("Could not initialize SDL: %s", + logger->safeError(strprintf("Could not initialize SDL: %s", SDL_GetError())); } atexit(SDL_Quit); @@ -555,7 +555,7 @@ void Client::gameInit() if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, oldFullscreen, hwaccel, enableResize, noFrame)) { - logger->error(strprintf("Couldn't restore %dx%dx%d " + logger->safeError(strprintf("Couldn't restore %dx%dx%d " "video mode: %s", oldWidth, oldHeight, bpp, SDL_GetError())); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index ae7e7a9cc..eff04614d 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -383,7 +383,7 @@ void Setup_Video::apply() " and restoration of old mode also " "failed!") << std::endl; } - logger->error(errorMsg.str()); + logger->safeError(errorMsg.str()); } } #if defined(WIN32) || defined(__APPLE__) diff --git a/src/logger.cpp b/src/logger.cpp index 8eba8fdb9..3c439136b 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -189,6 +189,34 @@ void Logger::log(const char *log_text, ...) delete [] buf; } +// here string must be safe for any usage +void Logger::safeError(const std::string &error_text) +{ + log("Error: %s", error_text.c_str()); +#ifdef WIN32 + MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK); +#elif defined __APPLE__ +// Str255 msg; +// CFStringRef error; +// error = CFStringCreateWithCString(nullptr, +// error_text.c_str(), +// kCFStringEncodingMacRoman); +// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman); +// StandardAlert(kAlertStopAlert, +// (const unsigned char*)"\pError", +// (ConstStr255Param) msg, nullptr, nullptr); +#elif defined __linux__ || __linux + std::cerr << "Error: " << error_text << std::endl; + std::string msg = "xmessage \"" + error_text + "\""; + if (system(msg.c_str()) == -1) + std::cerr << "Error: " << error_text << std::endl; +#else + std::cerr << "Error: " << error_text << std::endl; +#endif + exit(1); +} + +// here string can be unsafe strings void Logger::error(const std::string &error_text) { log("Error: %s", error_text.c_str()); @@ -206,7 +234,7 @@ void Logger::error(const std::string &error_text) // (ConstStr255Param) msg, nullptr, nullptr); #elif defined __linux__ || __linux std::cerr << "Error: " << error_text << std::endl; - std::string msg = "xmessage \"Error happand. Please see log file for more information.\""; + std::string msg = "xmessage \"Error happend. Please see log file for more information.\""; if (system(msg.c_str()) == -1) std::cerr << "Error: " << error_text << std::endl; #else diff --git a/src/logger.h b/src/logger.h index db618b275..3dc24420d 100644 --- a/src/logger.h +++ b/src/logger.h @@ -98,6 +98,13 @@ class Logger */ void error(const std::string &error_text) __attribute__ ((noreturn)); + /** + * Log an error and quit. The error will pop-up on Windows and Mac, and + * will be printed to standard error everywhere else. + */ + void safeError(const std::string &error_text) + __attribute__ ((noreturn)); + private: std::ofstream mLogFile; bool mLogToStandardOut; diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 84e71eaf3..a75da3643 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -54,7 +54,7 @@ void initialize() { if (enet_initialize()) { - logger->error("Failed to initialize ENet."); + logger->safeError("Failed to initialize ENet."); } #if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF @@ -65,7 +65,7 @@ void initialize() if (!client) { - logger->error("Failed to create the local host."); + logger->safeError("Failed to create the local host."); } } @@ -76,7 +76,7 @@ void finalize() if (connections) { - logger->error("Tried to shutdown the network subsystem while there " + logger->safeError("Tried to shutdown the network subsystem while there " "are network connections left!"); } @@ -88,7 +88,7 @@ Connection *getConnection() { if (!client) { - logger->error("Tried to instantiate a network object before " + logger->safeError("Tried to instantiate a network object before " "initializing the network subsystem!"); } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 6e9e367c0..b8ba7554e 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -236,7 +236,7 @@ void Network::dispatchMessages() MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); if (msg.getLength() == 0) - logger->error("Zero length packet received. Exiting."); + logger->safeError("Zero length packet received. Exiting."); if (iter != mMessageHandlers.end()) { -- cgit v1.2.3-70-g09d2 From 7873888f72ceb6a026eacac0d791f81cfee80a7c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Feb 2012 01:32:11 +0300 Subject: Replace setuo audio page to new class. --- src/gui/setup_audio.cpp | 173 +++++++++--------------------------------------- src/gui/setup_audio.h | 18 +---- src/sound.cpp | 8 +++ 3 files changed, 43 insertions(+), 156 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index bc058faf9..1f7db484c 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -23,179 +23,72 @@ #include "gui/setup_audio.h" #include "configuration.h" -#include "logger.h" #include "sound.h" -#include "gui/okdialog.h" #include "gui/viewport.h" -#include "gui/widgets/checkbox.h" -#include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" -#include "gui/widgets/slider.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" #include "utils/gettext.h" #include "debug.h" -Setup_Audio::Setup_Audio(): - mMusicVolume(config.getIntValue("musicVolume")), - mSfxVolume(config.getIntValue("sfxVolume")), - mAudioEnabled(config.getBoolValue("sound")), - mGameSoundEnabled(config.getBoolValue("playBattleSound")), - mGuiSoundEnabled(config.getBoolValue("playGuiSound")), - mMusicEnabled(config.getBoolValue("playMusic")), - mMumbleEnabled(config.getBoolValue("enableMumble")), - mDownloadEnabled(config.getBoolValue("download-music")), - mAudioCheckBox(new CheckBox(_("Enable Audio"), mAudioEnabled)), - mGameSoundCheckBox(new CheckBox(_("Enable game sfx"), mGameSoundEnabled)), - mGuiSoundCheckBox(new CheckBox(_("Enable gui sfx"), mGuiSoundEnabled)), - mMusicCheckBox(new CheckBox(_("Enable music"), mMusicEnabled)), - mMumbleCheckBox(new CheckBox(_("Enable mumble voice chat"), - mMumbleEnabled)), - mDownloadMusicCheckBox(new CheckBox(_("Download music"), - mDownloadEnabled)), - mSfxSlider(new Slider(0, sound.getMaxVolume())), - mMusicSlider(new Slider(0, sound.getMaxVolume())) +Setup_Audio::Setup_Audio() { setName(_("Audio")); - setDimension(gcn::Rectangle(0, 0, 250, 200)); - gcn::Label *sfxLabel = new Label(_("Sfx volume")); - gcn::Label *musicLabel = new Label(_("Music volume")); + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + place(0, 0, mScroll, 10, 10); - mSfxSlider->setActionEventId("sfx"); - mMusicSlider->setActionEventId("music"); + new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent"); - mSfxSlider->addActionListener(this); - mMusicSlider->addActionListener(this); + new SetupItemCheckBox(_("Enable music"), "", + "playMusic", this, "playMusicEvent"); - mAudioCheckBox->setPosition(10, 10); + new SetupItemCheckBox(_("Enable game sfx"), "", + "playBattleSound", this, "playBattleSoundEvent"); - mSfxSlider->setValue(mSfxVolume); - mMusicSlider->setValue(mMusicVolume); + new SetupItemCheckBox(_("Enable gui sfx"), "", + "playGuiSound", this, "playGuiSoundEvent"); - mSfxSlider->setWidth(90); - mMusicSlider->setWidth(90); + new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", + this, "sfxVolumeEvent", 0, sound.getMaxVolume(), 150, true); - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); + new SetupItemSlider(_("Music volume"), "", "musicVolume", + this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true); + + new SetupItemCheckBox(_("Enable mumble voice chat"), "", + "enableMumble", this, "enableMumbleEvent"); - place(0, 0, mAudioCheckBox); - place(0, 1, mMusicCheckBox); - place(0, 2, mGameSoundCheckBox); - place(0, 3, mGuiSoundCheckBox); - place(0, 4, mSfxSlider); - place(1, 4, sfxLabel); - place(0, 5, mMusicSlider); - place(1, 5, musicLabel); - place(0, 6, mMumbleCheckBox); - place(0, 7, mDownloadMusicCheckBox); - - setDimension(gcn::Rectangle(0, 0, 365, 280)); + new SetupItemCheckBox(_("Download music"), "", + "download-music", this, "download-musicEvent"); + + setDimension(gcn::Rectangle(0, 0, 550, 350)); } void Setup_Audio::apply() { - mAudioEnabled = mAudioCheckBox->isSelected(); - mGameSoundEnabled = mGameSoundCheckBox->isSelected(); - mGuiSoundEnabled = mGuiSoundCheckBox->isSelected(); - mMusicEnabled = mMusicCheckBox->isSelected(); - mMumbleEnabled = mMumbleCheckBox->isSelected(); - mDownloadEnabled = mDownloadMusicCheckBox->isSelected(); - mSfxVolume = config.getIntValue("sfxVolume"); - mMusicVolume = config.getIntValue("musicVolume"); - - config.setValue("sound", mAudioEnabled); - config.setValue("playBattleSound", mGameSoundEnabled); - config.setValue("playGuiSound", mGuiSoundEnabled); - - config.setValue("enableMumble", mMumbleEnabled); - - // Display a message if user has selected to download music, - // And if downloadmusic is not already enabled - if (mDownloadEnabled && !config.getBoolValue("download-music")) - { - new OkDialog(_("Notice"), _("You may have to restart your client " - "if you want to download new music")); - } - config.setValue("download-music", mDownloadEnabled); - - if (mAudioEnabled) + SetupTabScroll::apply(); + if (config.getBoolValue("sound")) { - try + sound.init(); + if (viewport && config.getBoolValue("playMusic")) { - sound.init(); + Map *map = viewport->getMap(); + if (map) + sound.playMusic(map->getMusicFile()); } - catch (const char *err) - { - new OkDialog(_("Sound Engine"), err); - logger->log("Warning: %s", err); - } - if (mMusicEnabled) - { - if (viewport && !config.getBoolValue("playMusic")) - { - Map *map = viewport->getMap(); - if (map) - { - config.setValue("playMusic", mMusicEnabled); - sound.playMusic(map->getMusicFile()); - } - } - } - else if (config.getBoolValue("playMusic")) + else { sound.stopMusic(); } - } else { sound.close(); } - - config.setValue("playMusic", mMusicEnabled); -} - -void Setup_Audio::cancel() -{ - mAudioCheckBox->setSelected(mAudioEnabled); - mGameSoundCheckBox->setSelected(mGameSoundEnabled); - mGuiSoundCheckBox->setSelected(mGuiSoundEnabled); - mMusicCheckBox->setSelected(mMusicEnabled); - mMumbleCheckBox->setSelected(mMumbleEnabled); - mDownloadMusicCheckBox->setSelected(mDownloadEnabled); - - sound.setSfxVolume(mSfxVolume); - mSfxSlider->setValue(mSfxVolume); - - sound.setMusicVolume(mMusicVolume); - mMusicSlider->setValue(mMusicVolume); - - config.setValue("sound", mAudioEnabled); - config.setValue("playBattleSound", mGameSoundEnabled); - config.setValue("playGuiSound", mGuiSoundEnabled); - config.setValue("enableMumble", mMumbleEnabled); - config.setValue("download-music", mDownloadEnabled); - config.setValue("sfxVolume", mSfxVolume); - config.setValue("musicVolume", mMusicVolume); - config.setValue("playMusic", mMusicEnabled); -} - -void Setup_Audio::action(const gcn::ActionEvent &event) -{ - if (event.getId() == "sfx") - { - config.setValueInt("sfxVolume", - static_cast(mSfxSlider->getValue())); - sound.setSfxVolume(static_cast(mSfxSlider->getValue())); - } - else if (event.getId() == "music") - { - config.setValueInt("musicVolume", - static_cast(mMusicSlider->getValue())); - sound.setMusicVolume(static_cast(mMusicSlider->getValue())); - } } diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index 88869d730..c08c49c7a 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -25,30 +25,16 @@ #include "guichanfwd.h" -#include "gui/widgets/setuptab.h" +#include "gui/widgets/setuptabscroll.h" #include -class Setup_Audio : public SetupTab +class Setup_Audio : public SetupTabScroll { public: Setup_Audio(); void apply(); - void cancel(); - - void action(const gcn::ActionEvent &event); - - private: - int mMusicVolume, mSfxVolume; - bool mAudioEnabled, mGameSoundEnabled, mGuiSoundEnabled; - bool mMusicEnabled, mMumbleEnabled; - bool mDownloadEnabled; - - gcn::CheckBox *mAudioCheckBox, *mGameSoundCheckBox, *mGuiSoundCheckBox; - gcn::CheckBox *mMusicCheckBox, *mMumbleCheckBox; - gcn::CheckBox *mDownloadMusicCheckBox; - gcn::Slider *mSfxSlider, *mMusicSlider; }; #endif diff --git a/src/sound.cpp b/src/sound.cpp index 913b55656..25b37d578 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -69,6 +69,8 @@ Sound::~Sound() config.removeListener("playBattleSound", this); config.removeListener("playGuiSound", this); config.removeListener("playMusic", this); + config.removeListener("sfxVolume", this); + config.removeListener("musicVolume", this); // Unlink the callback function. Mix_HookMusicFinished(nullptr); @@ -82,6 +84,10 @@ void Sound::optionChanged(const std::string &value) mPlayGui = config.getBoolValue("playGuiSound"); else if (value == "playMusic") mPlayMusic = config.getBoolValue("playMusic"); + else if (value == "sfxVolume") + setSfxVolume(config.getIntValue("sfxVolume")); + else if (value == "musicVolume") + setMusicVolume(config.getIntValue("musicVolume")); } void Sound::init() @@ -98,6 +104,8 @@ void Sound::init() config.addListener("playBattleSound", this); config.addListener("playGuiSound", this); config.addListener("playMusic", this); + config.addListener("sfxVolume", this); + config.addListener("musicVolume", this); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { -- cgit v1.2.3-70-g09d2 From 9ee2c8b92be2959cc984216a3fc1e8c3b8cd0ebd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Feb 2012 01:41:13 +0300 Subject: Decrease vertical size for setup items. --- src/gui/widgets/setuptabscroll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index ab8f61a40..34cc993a9 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -30,7 +30,7 @@ SetupTabScroll::SetupTabScroll() : SetupTab() { - mContainer = new VertContainer(32, false, 8); + mContainer = new VertContainer(25, false, 8); mScroll = new ScrollArea(mContainer); mScroll->setOpaque(false); mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); -- cgit v1.2.3-70-g09d2 From 3884c9d240a6dd7e3821f1ed9cb18a28a228b93e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Feb 2012 04:41:33 +0300 Subject: Add SliderList control. --- src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/gui/setup_video.cpp | 2 + src/gui/widgets/sliderlist.cpp | 216 +++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/sliderlist.h | 80 +++++++++++++++ 5 files changed, 302 insertions(+) create mode 100644 src/gui/widgets/sliderlist.cpp create mode 100644 src/gui/widgets/sliderlist.h (limited to 'src/gui') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 982d9b5ca..90c9240d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -197,6 +197,8 @@ SET(SRCS gui/widgets/shortcutcontainer.h gui/widgets/slider.cpp gui/widgets/slider.h + gui/widgets/sliderlist.cpp + gui/widgets/sliderlist.h gui/widgets/tab.cpp gui/widgets/tab.h gui/widgets/tabbedarea.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 5b40ac447..55c2700d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -200,6 +200,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/shortcutcontainer.h \ gui/widgets/slider.cpp \ gui/widgets/slider.h \ + gui/widgets/sliderlist.cpp \ + gui/widgets/sliderlist.h \ gui/widgets/tab.cpp \ gui/widgets/tab.h \ gui/widgets/tabbedarea.cpp \ diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index eff04614d..6690f1452 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -39,6 +39,7 @@ #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/slider.h" +#include "gui/widgets/sliderlist.h" #include "gui/widgets/textfield.h" #include "gui/widgets/dropdown.h" @@ -299,6 +300,7 @@ Setup_Video::Setup_Video(): place(1, 2, mEnableResizeCheckBox, 2); place(1, 3, mNoFrameCheckBox, 2); + // place(1, 5, mPickupNotifyLabel, 4); // place(1, 6, mPickupChatCheckBox, 1); // place(2, 6, mPickupParticleCheckBox, 2); diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp new file mode 100644 index 000000000..bc30bbe38 --- /dev/null +++ b/src/gui/widgets/sliderlist.cpp @@ -0,0 +1,216 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 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 . + */ + +#include "gui/widgets/sliderlist.h" + +#include "client.h" +#include "logger.h" + +#include "gui/gui.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/label.h" + +#include "utils/dtor.h" + +#include + +#include "debug.h" + +static const int buttonWidth = 27; +static const int buttonSpace = 30; +static const int sliderHeight = 30; + +SliderList::SliderList(gcn::ListModel *listModel, + gcn::ActionListener* listener, + std::string eventId) : + mListModel(listModel), + mOldWidth(0), + mSelectedIndex(0) +{ + mPrevEventId = eventId + "_prev"; + mNextEventId = eventId + "_next"; + + setHeight(sliderHeight); + + mButtons[0] = new Button("<", mPrevEventId, this); + mButtons[1] = new Button(">", mNextEventId, this); + mLabel = new Label(""); + add(mButtons[0]); + add(mLabel); + add(mButtons[1]); + + if (!eventId.empty()) + setActionEventId(eventId); + + if (listener) + addActionListener(listener); + + updateLabel(); + addMouseListener(this); +} + +SliderList::~SliderList() +{ +} + +void SliderList::updateAlpha() +{ + mButtons[0]->updateAlpha(); + mButtons[1]->updateAlpha(); +} + +void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) +{ + logger->log("SliderList::mouseWheelMovedUp"); + setSelected(mSelectedIndex - 1); + mouseEvent.consume(); +} + +void SliderList::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) +{ + setSelected(mSelectedIndex + 1); + mouseEvent.consume(); +} + +void SliderList::resize() +{ + const int width = getWidth(); + + mButtons[0]->setWidth(buttonWidth); +// mLabel->setPosition(buttonSpace, 0); + mLabel->setWidth(width - buttonSpace * 2); + mButtons[1]->setPosition(width - buttonSpace + 3, 0); + mButtons[1]->setWidth(buttonWidth); + updateLabel(); +} + +void SliderList::draw(gcn::Graphics *graphics) +{ + if (mOldWidth != getWidth()) + { + resize(); + mOldWidth = getWidth(); + } + Container::draw(graphics); +} + +void SliderList::updateLabel() +{ + if (!mListModel || mSelectedIndex < 0 + || mSelectedIndex >= mListModel->getNumberOfElements()) + { + return; + } + + mLabel->setCaption(mListModel->getElementAt(mSelectedIndex)); + mLabel->adjustSize(); + const int space = getWidth() - buttonSpace * 2; + const int labelWidth = mLabel->getWidth(); + int labelY = (getHeight() - mLabel->getHeight()) / 2; + if (labelY < 0) + labelY = 0; + + if (space < 0 || space < labelWidth) + mLabel->setPosition(buttonSpace, labelY); + else + mLabel->setPosition(buttonSpace + (space - labelWidth) / 2, labelY); +} + +void SliderList::action(const gcn::ActionEvent &event) +{ + if (!mListModel) + return; + + if (event.getId() == mPrevEventId) + { + mSelectedIndex --; + if (mSelectedIndex < 0) + mSelectedIndex = mListModel->getNumberOfElements() - 1; + } + else if (event.getId() == mNextEventId) + { + mSelectedIndex ++; + if (mSelectedIndex >= mListModel->getNumberOfElements()) + mSelectedIndex = 0; + } + updateLabel(); + distributeActionEvent(); +} + +void SliderList::setSelectedString(std::string str) +{ + if (!mListModel) + return; + + for (int f = 0; f < mListModel->getNumberOfElements(); f ++) + { + if (mListModel->getElementAt(f) == str) + { + setSelected(f); + break; + } + } +} + +std::string SliderList::getSelectedString() const +{ + if (!mListModel) + return ""; + + return mListModel->getElementAt(mSelectedIndex); +} + +void SliderList::setSelected(int idx) +{ + if (!mListModel) + return; + + mSelectedIndex = idx; + if (mSelectedIndex >= mListModel->getNumberOfElements()) + mSelectedIndex = 0; + if (mSelectedIndex < 0) + mSelectedIndex = mListModel->getNumberOfElements() - 1; + updateLabel(); +} + +void SliderList::adjustSize() +{ + setWidth(getMaxLabelWidth() + 60); + updateLabel(); +} + +int SliderList::getMaxLabelWidth() +{ + if (!mListModel || !gui) + return 1; + + int maxWidth = 0; + gcn::Font *font = gui->getFont(); + + for (int f = 0; f < mListModel->getNumberOfElements(); f ++) + { + int w = font->getWidth(mListModel->getElementAt(f)); + if (w > maxWidth) + maxWidth = w; + } + + return maxWidth; +} diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h new file mode 100644 index 000000000..a7b1a564c --- /dev/null +++ b/src/gui/widgets/sliderlist.h @@ -0,0 +1,80 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 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 . + */ + +#ifndef GUI_WIDGETS_SLIDERLIST_H +#define GUI_WIDGETS_SLIDERLIST_H + +#include +#include +#include + +#include "gui/widgets/container.h" + +#include "localconsts.h" + +class Button; +class Label; + +class SliderList : public Container, + public gcn::ActionListener, + public gcn::MouseListener +{ + public: + SliderList(gcn::ListModel *listModel = nullptr, + gcn::ActionListener* listener = nullptr, + std::string eventId = ""); + + ~SliderList(); + + void updateAlpha(); + + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + + void resize(); + + void draw(gcn::Graphics *graphics); + + void action(const gcn::ActionEvent &event); + + void setSelectedString(std::string str); + + std::string getSelectedString() const; + + void setSelected(int idx); + + void adjustSize(); + + protected: + void updateLabel(); + + int getMaxLabelWidth(); + + Button *mButtons[2]; + Label *mLabel; + gcn::ListModel *mListModel; + std::string mPrevEventId; + std::string mNextEventId; + int mOldWidth; + int mSelectedIndex; +}; + +#endif // end GUI_WIDGETS_SLIDERLIST_H -- cgit v1.2.3-70-g09d2 From 81db0022e50e25d922ac7d67d9ec6017b8856f13 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Feb 2012 21:28:51 +0300 Subject: Fix old casts. --- src/being.cpp | 2 +- src/configuration.cpp | 3 ++- src/graphics.cpp | 23 +++++++++++++-------- src/gui/charcreatedialog.cpp | 10 +++++++-- src/gui/debugwindow.cpp | 2 +- src/gui/editserverdialog.cpp | 3 ++- src/gui/equipmentwindow.cpp | 10 +++++++-- src/gui/itempopup.cpp | 2 +- src/gui/outfitwindow.cpp | 2 +- src/gui/popupmenu.cpp | 2 +- src/gui/serverdialog.cpp | 4 ++-- src/gui/setup_relations.cpp | 2 +- src/gui/updaterwindow.cpp | 4 ++-- src/gui/viewport.cpp | 3 ++- src/gui/widgets/browserbox.cpp | 22 ++++++++++---------- src/gui/widgets/guitable.cpp | 9 ++++---- src/gui/widgets/setupitem.cpp | 4 ++-- src/gui/widgets/textfield.cpp | 2 +- src/guichan/include/guichan/sdl/sdlpixel.hpp | 4 ++-- src/guichan/sdl/sdlgraphics.cpp | 23 ++++++++++++++------- src/guichan/sdl/sdlimage.cpp | 4 ++-- src/guichan/widgets/scrollarea.cpp | 8 +++---- src/guichan/widgets/slider.cpp | 4 ++-- src/guichan/widgets/tabbedarea.cpp | 2 +- src/guichan/widgets/textbox.cpp | 31 ++++++++++++++-------------- src/guichan/widgets/window.cpp | 2 +- src/guildmanager.cpp | 6 +++--- src/localplayer.cpp | 2 +- src/net/messagein.cpp | 2 +- src/net/tmwa/playerhandler.cpp | 4 ++-- src/opengl1graphics.cpp | 6 ++++-- src/openglgraphics.cpp | 10 +++++---- src/utils/copynpaste.cpp | 10 +++++++-- src/utils/langs.cpp | 8 +++---- src/utils/physfsrwops.cpp | 22 ++++++++++---------- src/utils/process.cpp | 6 +++--- src/utils/stringutils.cpp | 6 +++--- 37 files changed, 153 insertions(+), 116 deletions(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index e1cb9b0ae..b5f55592f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2320,7 +2320,7 @@ void Being::recalcSpritesOrder() int val = slotRemap.at(slot); int id = 0; - if ((int)mSpriteIDs.size() > val) + if (static_cast(mSpriteIDs.size()) > val) id = mSpriteIDs[val]; int idx = -1; diff --git a/src/configuration.cpp b/src/configuration.cpp index 694f94e78..97540c385 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -572,7 +572,8 @@ void ConfigurationObject::writeToXML(XmlTextWriterPtr writer) elt_it != it->second.end(); ++elt_it) { xmlTextWriterStartElement(writer, BAD_CAST name); - (*elt_it)->writeToXML(writer); + if (*elt_it) + (*elt_it)->writeToXML(writer); xmlTextWriterEndElement(writer); } diff --git a/src/graphics.cpp b/src/graphics.cpp index 5241bbcc6..e6841fa5c 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -845,7 +845,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) case 1: for (y = y1; y < y2; y++) { - Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch; + Uint8 *p = static_cast(mTarget->pixels) + + y * mTarget->pitch; for (x = x1; x < x2; x++) *(p + x) = pixel; } @@ -853,12 +854,14 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) case 2: for (y = y1; y < y2; y++) { - Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch; + Uint8 *p0 = static_cast(mTarget->pixels) + + y * mTarget->pitch; for (x = x1; x < x2; x++) { Uint8 *p = p0 + x * 2; - *(Uint16 *)p = gcn::SDLAlpha16( - pixel, *(Uint32 *)p, mColor.a, mTarget->format); + *reinterpret_cast(p) = gcn::SDLAlpha16( + pixel, *reinterpret_cast(p), + mColor.a, mTarget->format); } } break; @@ -871,7 +874,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) for (y = y1; y < y2; y++) { - Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch; + Uint8 *p0 = static_cast(mTarget->pixels) + + y * mTarget->pitch; for (x = x1; x < x2; x++) { Uint8 *p = p0 + x * 3; @@ -896,18 +900,19 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) const unsigned a1 = (255 - mColor.a); for (y = y1; y < y2; y++) { - Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch; + Uint8 *p0 = static_cast(mTarget->pixels) + + y * mTarget->pitch; for (x = x1; x < x2; x++) { Uint8 *p = p0 + x * 4; - Uint32 dst = *(Uint32 *)p; + Uint32 dst = *reinterpret_cast(p); const unsigned int b = (pb + (dst & 0xff) * a1) >> 8; const unsigned int g = (pg + (dst & 0xff00) * a1) >> 8; const unsigned int r = (pr + (dst & 0xff0000) * a1) >> 8; - *(Uint32 *)p = ((b & 0xff) | (g & 0xff00) - | (r & 0xff0000)); + *reinterpret_cast(p) = ((b & 0xff) + | (g & 0xff00) | (r & 0xff0000)); } } break; diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 8d4767a15..9f7436ad8 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -474,8 +474,11 @@ void CharCreateDialog::updateHair() mHairStyle %= Being::getNumOfHairstyles(); if (mHairStyle < 0) mHairStyle += Being::getNumOfHairstyles(); - if (mHairStyle < (signed)minHairStyle || mHairStyle > (signed)maxHairStyle) + if (mHairStyle < static_cast(minHairStyle) + || mHairStyle > static_cast(maxHairStyle)) + { mHairStyle = minHairStyle; + } const ItemInfo &item = ItemDB::get(-mHairStyle); mHairStyleNameLabel->setCaption(item.getName()); mHairStyleNameLabel->adjustSize(); @@ -483,8 +486,11 @@ void CharCreateDialog::updateHair() mHairColor %= ColorDB::getHairSize(); if (mHairColor < 0) mHairColor += ColorDB::getHairSize(); - if (mHairColor < (signed)minHairColor || mHairColor > (signed)maxHairColor) + if (mHairColor < static_cast(minHairColor) + || mHairColor > static_cast(maxHairColor)) + { mHairColor = minHairColor; + } mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor)); mHairColorNameLabel->adjustSize(); diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index b65068dc5..fa01b5aa8 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -390,7 +390,7 @@ void NetDebugTab::logic() if (player_node && player_node->getPingTime() != 0) { mPingLabel->setCaption(strprintf(_("Ping: %s ms"), - toString((int)player_node->getPingTime()).c_str())); + toString(static_cast(player_node->getPingTime())).c_str())); } else { diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp index 8a4a9579d..53e31c3c8 100644 --- a/src/gui/editserverdialog.cpp +++ b/src/gui/editserverdialog.cpp @@ -184,7 +184,8 @@ void EditServerDialog::action(const gcn::ActionEvent &event) mServer.name = mNameField->getText(); mServer.description = mDescriptionField->getText(); mServer.hostname = mServerAddressField->getText(); - mServer.port = (short) atoi(mPortField->getText().c_str()); + mServer.port = static_cast(atoi( + mPortField->getText().c_str())); if (mTypeField) { diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 275bf19bb..89063c3dc 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -407,8 +407,11 @@ void EquipmentWindow::loadSlot(XmlNodePtr slotNode, ImageSet *imageset) const int imageIndex = XML::getProperty(slotNode, "image", -1); Image *image = nullptr; - if (imageset && imageIndex >= 0 && imageIndex < (signed)imageset->size()) + if (imageset && imageIndex >= 0 && imageIndex + < static_cast(imageset->size())) + { image = imageset->get(imageIndex); + } if (mBoxes[slot]) { @@ -510,8 +513,11 @@ void EquipmentWindow::addBox(int idx, int x, int y, int imageIndex) { Image *image = nullptr; - if (mImageSet && imageIndex >= 0 && imageIndex < (signed)mImageSet->size()) + if (mImageSet && imageIndex >= 0 && imageIndex + < static_cast(mImageSet->size())) + { image = mImageSet->get(imageIndex); + } mBoxes[idx] = new EquipmentBox(x + getPadding(), y + getTitleBarHeight(), image); diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index d96aa564f..f33f77e83 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -123,7 +123,7 @@ void ItemPopup::setItem(const Item *item, bool showImage) } mItemName->adjustSize(); unsigned minWidth = mItemName->getWidth() + 8; - if ((unsigned)getWidth() < minWidth) + if (static_cast(getWidth()) < minWidth) setWidth(minWidth); } } diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 73484f1d5..6eaa2ac4e 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -190,7 +190,7 @@ void OutfitWindow::save() outfitStr += toString(res); if (i < OUTFIT_ITEM_COUNT - 1) outfitStr += " "; - outfitColorsStr += toString((int)mItemColors[o][i]); + outfitColorsStr += toString(static_cast(mItemColors[o][i])); if (i < OUTFIT_ITEM_COUNT - 1) outfitColorsStr += " "; } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index c987843d3..933d2c7cd 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2205,7 +2205,7 @@ void PlayerListener::action(const gcn::ActionEvent &event) { std::string comment = mDialog->getText(); Being* being = actorSpriteManager->findBeingByName( - mNick, (ActorSprite::Type)mType); + mNick, static_cast(mType)); if (being) being->setComment(comment); Being::saveComment(mNick, comment, mType); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index da61e105b..ed9696892 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -125,7 +125,7 @@ std::string ServersListModel::getElementAt(int elementIndex) void ServersListModel::setVersionString(int index, const std::string &version) { - if (index >= (int)mVersionStrings.size()) + if (index >= static_cast(mVersionStrings.size())) return; if (version.empty()) @@ -632,7 +632,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, // Make sure the current server is mentioned first if (currentServer.isValid()) { - if (index >= 0 && (unsigned)index < mServers.size()) + if (index >= 0 && static_cast(index) < mServers.size()) { mServers[index] = currentServer; } diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 47d53620c..f3b664c9b 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -194,7 +194,7 @@ public: std::string getPlayerAt(int index) const { - if (index < 0 || index >= (signed)mPlayers->size()) + if (index < 0 || index >= static_cast(mPlayers->size())) return ""; return (*mPlayers)[index]; } diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 3aaf93557..fe26d42eb 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -554,8 +554,8 @@ void UpdaterWindow::logic() if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size()) { mProgressBar->setText(strprintf("%d/%d", mUpdateIndex - + mUpdateIndexOffset + 1, (int)mUpdateFiles.size() - + (int)mTempUpdateFiles.size() + 1)); + + mUpdateIndexOffset + 1, static_cast(mUpdateFiles.size()) + + static_cast(mTempUpdateFiles.size()) + 1)); } else { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d4c188bfb..0c0f0d3d9 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -199,7 +199,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // if (debugChatTab) // debugChatTab->chatLog("incorrect player position!"); logger->log("incorrect player position: %d, %d, %d, %d", - player_x, player_y, (int)mPixelViewX, (int)mPixelViewY); + player_x, player_y, static_cast(mPixelViewX), + static_cast(mPixelViewY)); if (player_node) { logger->log("tile position: %d, %d", diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 5856a91b1..47c5616b6 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -232,15 +232,17 @@ void BrowserBox::addRow(const std::string &row, bool atTop) tempRow.substr(nextChar, (nextSpacePos - nextChar))); - if ((x + nextWordWidth + 10) > (unsigned)getWidth()) + if ((x + nextWordWidth + 10) + > static_cast(getWidth())) { x = 15; // Ident in new line y += 1; - j++; + j ++; } } // Wrapping looong lines (brutal force) - else if ((x + 2 * hyphenWidth) > (unsigned)getWidth()) + else if ((x + 2 * hyphenWidth) + > static_cast(getWidth())) { x = 15; // Ident in new line y += 1; @@ -249,7 +251,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) } setHeight(font->getHeight() * (static_cast( - mTextRows.size()) + y)); + mTextRows.size()) + y)); } else { @@ -423,7 +425,7 @@ int BrowserBox::calcHeight() if (row.find("---", 0) == 0) { const int dashWidth = fontWidthMinus; - for (x = 0; x < (unsigned)getWidth(); x++) + for (x = 0; x < static_cast(getWidth()); x ++) { mLineParts.push_back(LinePart(x, y, selColor, "-", false)); x += dashWidth - 2; @@ -557,9 +559,8 @@ int BrowserBox::calcHeight() width = font->getWidth(part); // Auto wrap mode - if (mMode == AUTO_WRAP && getWidth() > 0 - && width > 0 - && (x + width + 10) > (unsigned)getWidth()) + if (mMode == AUTO_WRAP && getWidth() > 0 && width > 0 + && (x + width + 10) > static_cast(getWidth())) { bool forced = false; @@ -592,9 +593,8 @@ int BrowserBox::calcHeight() else width = font->getWidth(part); } - while (end > start && width > 0 - && (x + width + 10) - > (unsigned)getWidth()); + while (end > start && width > 0 && (x + width + 10) + > static_cast(getWidth())); if (forced) { diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index d620cbb8d..6434f5453 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -348,14 +348,15 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mSelectedRow > 0) { - if (mLinewiseMode && r == (unsigned)mSelectedRow && c == 0) + if (mLinewiseMode && r == static_cast( + mSelectedRow) && c == 0) { graphics->fillRectangle(gcn::Rectangle(0, y_offset, - getWidth(), height)); + getWidth(), height)); } else if (!mLinewiseMode && mSelectedColumn > 0 - && c == (unsigned)mSelectedColumn - && r == (unsigned)mSelectedRow) + && c == static_cast(mSelectedColumn) + && r == static_cast(mSelectedRow)) { graphics->fillRectangle(gcn::Rectangle( x_offset, y_offset, width, height)); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 490c046c3..8987719da 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -830,8 +830,8 @@ void SetupItemSlider2::updateLabel() int val = mSlider->getValue() - mMin; if (val < 0) val = 0; - else if (val >= (signed)mValues->size()) - val = (signed)mValues->size() - 1; + else if (val >= static_cast(mValues->size())) + val = static_cast(mValues->size()) - 1; std::string str = mValues->at(val); mLabel2->setCaption(str); } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index e207b0613..a90712340 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -183,7 +183,7 @@ int TextField::getValue() const if (value < mMinimum) return mMinimum; - if (value > (signed)mMaximum) + if (value > static_cast(mMaximum)) return mMaximum; return value; diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index f56100b4a..23298ef37 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -244,8 +244,8 @@ namespace gcn break; case 2: - *reinterpret_cast(p) = SDLAlpha16(pixel, *(Uint32 *)p, - color.a, surface->format); + *reinterpret_cast(p) = SDLAlpha16(pixel, + *reinterpret_cast(p), color.a, surface->format); break; case 3: diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index c8cec6370..ae61a0432 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -283,7 +283,8 @@ namespace gcn SDL_LockSurface(mTarget); - Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch + x1 * bpp; + Uint8 *p = static_cast(mTarget->pixels) + + y * mTarget->pitch + x1 * bpp; Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, @@ -298,7 +299,7 @@ namespace gcn case 2: { - Uint16* q = (Uint16*)p; + Uint16* q = reinterpret_cast(p); for (; x1 <= x2; ++x1) *(q++) = pixel; break; @@ -329,7 +330,7 @@ namespace gcn case 4: { - Uint32* q = (Uint32*)p; + Uint32 *q = reinterpret_cast(p); for (; x1 <= x2; ++x1) { if (mAlpha) @@ -395,7 +396,8 @@ namespace gcn SDL_LockSurface(mTarget); - Uint8 *p = (Uint8 *)mTarget->pixels + y1 * mTarget->pitch + x * bpp; + Uint8 *p = static_cast(mTarget->pixels) + + y1 * mTarget->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b); @@ -411,9 +413,9 @@ namespace gcn break; case 2: - for (; y1 <= y2; ++y1) + for (; y1 <= y2; ++ y1) { - *(Uint16*)p = pixel; + *reinterpret_cast(p) = pixel; p += mTarget->pitch; } break; @@ -445,9 +447,14 @@ namespace gcn for (; y1 <= y2; ++y1) { if (mAlpha) - *(Uint32*)p = SDLAlpha32(pixel, *(Uint32*)p, mColor.a); + { + *reinterpret_cast(p) = SDLAlpha32(pixel, + *reinterpret_cast(p), mColor.a); + } else - *(Uint32*)p = pixel; + { + *reinterpret_cast(p) = pixel; + } p += mTarget->pitch; } break; diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index 4f9b9565c..cf8505c4e 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -142,8 +142,8 @@ namespace gcn { Uint8 r, g, b, a; - SDL_GetRGBA(((unsigned int*)mSurface->pixels)[i], mSurface->format, - &r, &g, &b, &a); + SDL_GetRGBA((static_cast(mSurface->pixels)[i]), + mSurface->format, &r, &g, &b, &a); if (a != 255) { diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 451288c77..21f7b5930 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -325,12 +325,12 @@ namespace gcn if (y < getVerticalMarkerDimension().y) { setVerticalScrollAmount(getVerticalScrollAmount() - - (int)(getChildrenArea().height * 0.95)); + - static_cast(getChildrenArea().height * 0.95)); } else { setVerticalScrollAmount(getVerticalScrollAmount() - + (int)(getChildrenArea().height * 0.95)); + + static_cast(getChildrenArea().height * 0.95)); } } else if (getHorizontalMarkerDimension().isPointInRect(x, y)) @@ -345,12 +345,12 @@ namespace gcn if (x < getHorizontalMarkerDimension().x) { setHorizontalScrollAmount(getHorizontalScrollAmount() - - (int)(getChildrenArea().width * 0.95)); + - static_cast(getChildrenArea().width * 0.95)); } else { setHorizontalScrollAmount(getHorizontalScrollAmount() - + (int)(getChildrenArea().width * 0.95)); + + static_cast(getChildrenArea().width * 0.95)); } } } diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index 16f7cd8be..36f067eab 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -245,7 +245,7 @@ namespace gcn else w = getHeight(); - double pos = v / ((double)w - getMarkerLength()); + double pos = v / (static_cast(w) - getMarkerLength()); return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); } @@ -257,7 +257,7 @@ namespace gcn else v = getHeight(); - int w = (int)((v - getMarkerLength()) + int w = static_cast((v - getMarkerLength()) * (value - getScaleStart()) / (getScaleEnd() - getScaleStart())); diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index 7af00c4c4..3e7178548 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -320,7 +320,7 @@ namespace gcn int index = getSelectedTabIndex(); index++; - if (index >= (int)mTabs.size()) + if (index >= static_cast(mTabs.size())) return; else setSelectedTab(mTabs[index].first); diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index e78ea91a3..c2cd5586f 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -155,7 +155,7 @@ namespace gcn { mCaretRow = mouseEvent.getY() / getFont()->getHeight(); - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast(mTextRows.size())) mCaretRow = mTextRows.size() - 1; mCaretColumn = getFont()->getStringIndexAt( @@ -193,11 +193,11 @@ namespace gcn else if (key.getValue() == Key::RIGHT) { ++mCaretColumn; - if (mCaretColumn > (int)mTextRows[mCaretRow].size()) + if (mCaretColumn > static_cast(mTextRows[mCaretRow].size())) { - ++mCaretRow; + ++ mCaretRow; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast(mTextRows.size())) { mCaretRow = mTextRows.size() - 1; if (mCaretRow < 0) @@ -254,14 +254,15 @@ namespace gcn --mCaretRow; } else if (key.getValue() == Key::DELETE - && mCaretColumn < (int)mTextRows[mCaretRow].size() - && mEditable) + && mCaretColumn < static_cast( + mTextRows[mCaretRow].size()) && mEditable) { mTextRows[mCaretRow].erase(mCaretColumn, 1); } else if (key.getValue() == Key::DELETE - && mCaretColumn == (int)mTextRows[mCaretRow].size() - && mCaretRow < ((int)mTextRows.size() - 1) + && mCaretColumn == static_cast( + mTextRows[mCaretRow].size()) + && mCaretRow < (static_cast(mTextRows.size()) - 1) && mEditable) { mTextRows[mCaretRow] += mTextRows[mCaretRow + 1]; @@ -291,7 +292,7 @@ namespace gcn / getFont()->getHeight(); mCaretRow += rowsPerPage; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast(mTextRows.size())) mCaretRow = mTextRows.size() - 1; } } @@ -305,7 +306,7 @@ namespace gcn && mEditable) { mTextRows[mCaretRow].insert(mCaretColumn, - std::string(1, (char)key.getValue())); + std::string(1, static_cast(key.getValue()))); ++ mCaretColumn; } @@ -332,9 +333,7 @@ namespace gcn void TextBox::setCaretPosition(unsigned int position) { - int row; - - for (row = 0; row < (int)mTextRows.size(); row++) + for (int row = 0; row < static_cast(mTextRows.size()); row ++) { if (position <= mTextRows[row].size()) { @@ -373,7 +372,7 @@ namespace gcn { mCaretRow = row; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast(mTextRows.size())) mCaretRow = mTextRows.size() - 1; if (mCaretRow < 0) @@ -391,7 +390,7 @@ namespace gcn { mCaretColumn = column; - if (mCaretColumn > (int)mTextRows[mCaretRow].size()) + if (mCaretColumn > static_cast(mTextRows[mCaretRow].size())) mCaretColumn = mTextRows[mCaretRow].size(); if (mCaretColumn < 0) @@ -431,7 +430,7 @@ namespace gcn int i; std::string text; - for (i = 0; i < (int)mTextRows.size() - 1; ++i) + for (i = 0; i < static_cast(mTextRows.size()) - 1; ++ i) text = text + mTextRows[i] + "\n"; text = text + mTextRows[i]; diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index d7c5809e6..c7ed8a69e 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -137,7 +137,7 @@ namespace gcn mDragOffsetX = mouseEvent.getX(); mDragOffsetY = mouseEvent.getY(); - mMoved = mouseEvent.getY() <= (int)mTitleBarHeight; + mMoved = mouseEvent.getY() <= static_cast(mTitleBarHeight); } void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED) diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 9dc9d7b73..08af3b2c7 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -274,7 +274,7 @@ bool GuildManager::process(std::string msg) return false; // logger->log("welcome message: %s", msg.c_str()); int pos = msg.find("! ("); - if (pos == (int)std::string::npos) + if (pos == static_cast(std::string::npos)) return false; msg = msg.substr(0, pos); guild->setName(msg); @@ -299,7 +299,7 @@ bool GuildManager::process(std::string msg) return false; pos = msg.find(", Guild:"); - if (pos == (int)std::string::npos) + if (pos == static_cast(std::string::npos)) return false; int level = atoi(msg.substr(0, pos).c_str()); @@ -310,7 +310,7 @@ bool GuildManager::process(std::string msg) msg = msg.substr(pos + strlen(", Guild:")); pos = msg.find(", No. Of Online Players: "); - if (pos == (int)std::string::npos) + if (pos == static_cast(std::string::npos)) return false; msg = msg.substr(0, pos); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index b07511196..5114f868c 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2064,7 +2064,7 @@ std::string LocalPlayer::getQuickDropCounterString() void LocalPlayer::setQuickDropCounter(int n) { - if (n < 1 || n >= (signed)quickDropCounterSize) + if (n < 1 || n >= static_cast(quickDropCounterSize)) return; mQuickDropCounter = n; config.setValue("quickDropCounter", mQuickDropCounter); diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 0547ed337..5d15d26ac 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -265,7 +265,7 @@ unsigned char *MessageIn::readBytes(int length) #ifdef ENABLEDEBUGLOG std::string str; for (int f = 0; f < length; f ++) - str += strprintf ("%02x", (unsigned)buf[f]); + str += strprintf ("%02x", static_cast(buf[f])); str += " "; for (int f = 0; f < length; f ++) { diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index bfe9eea42..a63af770a 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -229,7 +229,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) return; } - char *start = (char*)msg.readBytes(size); + char *start = reinterpret_cast(msg.readBytes(size)); if (!start) return; @@ -265,7 +265,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) gender = GENDER_FEMALE; } } - arr.push_back(new OnlinePlayer((char*)buf, + arr.push_back(new OnlinePlayer(static_cast(buf), status, level, gender, ver)); buf += strlen(buf) + 1; } diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 34e9fcda3..ea4d5e6f3 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -393,8 +393,10 @@ void OpenGL1Graphics::drawRescaledImagePattern(Image *image, int x, int y, // Draw a set of textured rectangles glBegin(GL_QUADS); - const float scaleFactorW = (float) scaledWidth / image->getWidth(); - const float scaleFactorH = (float) scaledHeight / image->getHeight(); + const float scaleFactorW = static_cast(scaledWidth) + / image->getWidth(); + const float scaleFactorH = static_cast(scaledHeight) + / image->getHeight(); for (int py = 0; py < h; py += ih) { diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index bcf46e18b..d972a738f 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -554,8 +554,10 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, { int width = (px + scaledWidth >= w) ? w - px : scaledWidth; int dstX = x + px; - const float visibleFractionW = (float) width / scaledWidth; - const float visibleFractionH = (float) height / scaledHeight; + const float visibleFractionW = static_cast(width) + / scaledWidth; + const float visibleFractionH = static_cast(height) + / scaledHeight; const float texX2 = texX1 + tFractionW * visibleFractionW; const float texY2 = texY1 + tFractionH * visibleFractionH; @@ -597,8 +599,8 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, } else { - const float scaleFactorW = (float) scaledWidth / iw; - const float scaleFactorH = (float) scaledHeight / ih; + const float scaleFactorW = static_cast(scaledWidth) / iw; + const float scaleFactorH = static_cast(scaledHeight) / ih; for (int py = 0; py < h; py += scaledHeight) { diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 90e0c5c93..763b579d0 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -442,9 +442,15 @@ bool runxsel(std::string& text, const char *p1, const char *p2) close(fd[0]); } if (p2) - execl("/usr/bin/xsel", "xsel", p1, p2, (char *)nullptr); + { + execl("/usr/bin/xsel", "xsel", p1, p2, + static_cast(nullptr)); + } else - execl("/usr/bin/xsel", "xsel", p1, (char *)nullptr); + { + execl("/usr/bin/xsel", "xsel", p1, + static_cast(nullptr)); + } exit(1); } diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp index 2efbd781a..c1f9f7ecf 100644 --- a/src/utils/langs.cpp +++ b/src/utils/langs.cpp @@ -44,11 +44,11 @@ std::vector getLang() } int dot = lang.find("."); - if (dot != (signed)std::string::npos) + if (dot != static_cast(std::string::npos)) lang = lang.substr(0, dot); langs.push_back(lang); dot = lang.find("_"); - if (dot != (signed)std::string::npos) + if (dot != static_cast(std::string::npos)) langs.push_back(lang.substr(0, dot)); return langs; } @@ -78,10 +78,10 @@ std::string getLangShort() } int dot = lang.find("."); - if (dot != (signed)std::string::npos) + if (dot != static_cast(std::string::npos)) lang = lang.substr(0, dot); dot = lang.find("_"); - if (dot != (signed)std::string::npos) + if (dot != static_cast(std::string::npos)) return lang.substr(0, dot); return lang; } diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp index 1960f0dee..2675b89ae 100644 --- a/src/utils/physfsrwops.cpp +++ b/src/utils/physfsrwops.cpp @@ -29,7 +29,7 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) { - PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1; + PHYSFS_file *handle = static_cast(rw->hidden.unknown.data1); int pos = 0; if (whence == SEEK_SET) @@ -46,8 +46,8 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) return -1; } /* if */ - pos = (int)current; - if (((PHYSFS_sint64)pos) != current) + pos = static_cast(current); + if (static_cast(pos) != current) { SDL_SetError("Can't fit current file position in an int!"); return -1; @@ -67,8 +67,8 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) return -1; } /* if */ - pos = (int)len; - if (((PHYSFS_sint64)pos) != len) + pos = static_cast(len); + if (static_cast(pos) != len) { SDL_SetError("Can't fit end-of-file position in an int!"); return -1; @@ -88,7 +88,7 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) return -1; } /* if */ - if (!PHYSFS_seek(handle, (PHYSFS_uint64) pos)) + if (!PHYSFS_seek(handle, static_cast(pos))) { SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); return -1; @@ -99,7 +99,7 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum) { - PHYSFS_file *handle = (PHYSFS_file*)rw->hidden.unknown.data1; + PHYSFS_file *handle = static_cast(rw->hidden.unknown.data1); PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum); if (rc != maxnum) { @@ -107,22 +107,22 @@ static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum) SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); } /* if */ - return (int)rc; + return static_cast(rc); } /* physfsrwops_read */ static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num) { - PHYSFS_file *handle = (PHYSFS_file*)rw->hidden.unknown.data1; + PHYSFS_file *handle = static_cast(rw->hidden.unknown.data1); PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num); if (rc != num) SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); - return (int) rc; + return static_cast(rc); } /* physfsrwops_write */ static int physfsrwops_close(SDL_RWops *rw) { - PHYSFS_file *handle = (PHYSFS_file*)rw->hidden.unknown.data1; + PHYSFS_file *handle = static_cast(rw->hidden.unknown.data1); if (!PHYSFS_close(handle)) { SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); diff --git a/src/utils/process.cpp b/src/utils/process.cpp index fd0ec0fa8..0106c597d 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -112,12 +112,12 @@ int execFile(std::string pathName, std::string name, if (arg2.empty()) { execl(pathName.c_str(), name.c_str(), - arg1.c_str(), (char *)nullptr); + arg1.c_str(), static_cast(nullptr)); } else { - execl(pathName.c_str(), name.c_str(), - arg1.c_str(), arg2.c_str(), (char *)nullptr); + execl(pathName.c_str(), name.c_str(), arg1.c_str(), + arg2.c_str(), static_cast(nullptr)); } exit(-1); } diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 2f478a909..5a7ea87fd 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -522,9 +522,9 @@ std::string stringToHexPath(const std::string &str) if (str.empty()) return ""; - std::string hex = strprintf("%%%2x/", (int)str[0]); + std::string hex = strprintf("%%%2x/", static_cast(str[0])); for (unsigned f = 1; f < str.size(); f ++) - hex += strprintf("%%%2x", (int)str[f]); + hex += strprintf("%%%2x", static_cast(str[f])); return hex; } @@ -600,7 +600,7 @@ bool findCutFirst(std::string &str1, std::string str2) std::string &removeProtocol(std::string &url) { int i = url.find("://"); - if (i != (int)std::string::npos) + if (i != static_cast(std::string::npos)) url = url.substr(i + 3); return url; } -- cgit v1.2.3-70-g09d2 From 481bbd254103fc9d6dc98b19a5226f8868c8c5d9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 27 Feb 2012 02:44:23 +0300 Subject: Add sliderlist setup item. --- src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/defaults.cpp | 2 + src/gui/setup_theme.cpp | 29 +----------- src/gui/theme.cpp | 19 ++++++++ src/gui/theme.h | 2 + src/gui/widgets/namesmodel.cpp | 51 ++++++++++++++++++++ src/gui/widgets/namesmodel.h | 45 ++++++++++++++++++ src/gui/widgets/setupitem.cpp | 103 +++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/setupitem.h | 37 +++++++++++++++ 10 files changed, 265 insertions(+), 27 deletions(-) create mode 100644 src/gui/widgets/namesmodel.cpp create mode 100644 src/gui/widgets/namesmodel.h (limited to 'src/gui') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90c9240d1..7e7d60886 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -167,6 +167,8 @@ SET(SRCS gui/widgets/listbox.cpp gui/widgets/listbox.h gui/widgets/mouseevent.h + gui/widgets/namesmodel.cpp + gui/widgets/namesmodel.h gui/widgets/passwordfield.cpp gui/widgets/passwordfield.h gui/widgets/playerbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 55c2700d6..06b457e4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,6 +170,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/listbox.cpp \ gui/widgets/listbox.h \ gui/widgets/mouseevent.h \ + gui/widgets/namesmodel.cpp \ + gui/widgets/namesmodel.h \ gui/widgets/passwordfield.cpp \ gui/widgets/passwordfield.h \ gui/widgets/playerbox.cpp \ diff --git a/src/defaults.cpp b/src/defaults.cpp index df401e119..01907bfe8 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -263,6 +263,8 @@ DefaultsData* getBrandingDefaults() AddDEF(brandingData, "guiThemePath", "themes/"); AddDEF(brandingData, "fontsPath", "fonts/"); + AddDEF(brandingData, "systemsounds", "sfx/system/"); + AddDEF(brandingData, "wallpaperFile", ""); AddDEF(brandingData, "dataPath", ""); return brandingData; diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index d4a1d5652..d3b9d0e3c 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -29,10 +29,11 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" #include "gui/widgets/textfield.h" -#include "gui/widgets/dropdown.h" #include "configuration.h" #include "localplayer.h" @@ -53,32 +54,6 @@ const char* ACTION_HELP_FONT = "help font"; const char* ACTION_SECURE_FONT = "secure font"; const char* ACTION_JAPAN_FONT = "japan font"; -class NamesModel : public gcn::ListModel -{ -public: - NamesModel() - { - } - - virtual ~NamesModel() { } - - virtual int getNumberOfElements() - { - return static_cast(mNames.size()); - } - - virtual std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return _("???"); - - return mNames[i]; - } - -protected: - std::vector mNames; -}; - class ThemesModel : public NamesModel { public: diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 85fd215ac..3a09810d0 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -569,6 +569,25 @@ void Theme::fillFontsList(std::vector &list) PHYSFS_permitSymbolicLinks(0); } +void Theme::fillSoundsList(std::vector &list) +{ + char **skins = PHYSFS_enumerateFiles( + branding.getStringValue("systemsounds").c_str()); + + for (char **i = skins; *i; i++) + { + if (!PHYSFS_isDirectory(( + branding.getStringValue("systemsounds") + *i).c_str())) + { + std::string str = *i; + if (findCutLast(str, ".ogg")) + list.push_back(str); + } + } + + PHYSFS_freeList(skins); +} + void Theme::selectSkin() { prepareThemePath(); diff --git a/src/gui/theme.h b/src/gui/theme.h index 9cb8f6180..c30044dc7 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -131,6 +131,8 @@ class Theme : public Palette, public ConfigListener static void fillFontsList(std::vector &list); + static void fillSoundsList(std::vector &list); + /** * Returns the patch to the given gui resource relative to the theme * or, if it isn't in the theme, relative to 'graphics/gui'. diff --git a/src/gui/widgets/namesmodel.cpp b/src/gui/widgets/namesmodel.cpp new file mode 100644 index 000000000..abfcd6def --- /dev/null +++ b/src/gui/widgets/namesmodel.cpp @@ -0,0 +1,51 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012 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 . + */ + +#include "gui/widgets/namesmodel.h" + +#include "logger.h" + +#include "utils/gettext.h" + +#include +#include + +#include "debug.h" + +NamesModel::NamesModel() +{ +} + +NamesModel::~NamesModel() +{ +} + +int NamesModel::getNumberOfElements() +{ + return static_cast(mNames.size()); +} + +std::string NamesModel::getElementAt(int i) +{ + if (i >= getNumberOfElements() || i < 0) + return _("???"); + + return mNames[i]; +} diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h new file mode 100644 index 000000000..3f9f10b52 --- /dev/null +++ b/src/gui/widgets/namesmodel.h @@ -0,0 +1,45 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012 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 . + */ + +#ifndef GUI_WIDGETS_NAMESMODEL_H +#define GUI_WIDGETS_NAMESMODEL_H + +//#include "guichanfwd.h" + +#include + +#include + +class NamesModel : public gcn::ListModel +{ + public: + NamesModel(); + + virtual ~NamesModel(); + + virtual int getNumberOfElements(); + + virtual std::string getElementAt(int i); + + protected: + std::vector mNames; +}; + +#endif diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8987719da..581002a58 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -35,6 +35,7 @@ #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/slider.h" +#include "gui/widgets/sliderlist.h" #include "gui/widgets/tabbedarea.h" #include "gui/widgets/textfield.h" #include "gui/widgets/vertcontainer.h" @@ -693,6 +694,7 @@ void SetupItemSlider::apply(std::string eventName) save(); } + SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, int min, int max, @@ -851,3 +853,104 @@ void SetupItemSlider2::setInvertValue(int v) mInvertValue = v; toWidget(); } + + +SetupItemSliderList::SetupItemSliderList(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + int width, bool onTheFly, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mSlider(nullptr), + mModel(model), + mWidth(width), + mOnTheFly(onTheFly) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSliderList::SetupItemSliderList(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + std::string def, int width, + bool onTheFly, bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, def, mainConfig), + mHorizont(nullptr), + mLabel(nullptr), + mSlider(nullptr), + mModel(model), + mWidth(width), + mOnTheFly(onTheFly) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemSliderList::~SetupItemSliderList() +{ + mHorizont = nullptr; + mWidget = nullptr; + mSlider = nullptr; + mLabel = nullptr; +} + +void SetupItemSliderList::createControls() +{ + load(); + mHorizont = new HorizontContainer(32, 2); + + mLabel = new Label(mText); + mSlider = new SliderList(mModel, mParent, mEventName); + mSlider->setSelectedString(mValue); + mSlider->adjustSize(); + + mWidget = mSlider; + mHorizont->add(mLabel, 5); + mHorizont->add(mSlider); + + mParent->getContainer()->add2(mHorizont, true, 4); + mParent->addControl(this); + mParent->addActionListener(this); + mWidget->addActionListener(this); +} + +void SetupItemSliderList::fromWidget() +{ + if (!mSlider) + return; + + mValue = mSlider->getSelectedString(); +} + +void SetupItemSliderList::toWidget() +{ + if (!mSlider) + return; + + mSlider->setSelectedString(mValue); +} + +void SetupItemSliderList::action(const gcn::ActionEvent &event A_UNUSED) +{ + fromWidget(); + if (mOnTheFly) + save(); +} + +void SetupItemSliderList::apply(std::string eventName) +{ + if (eventName != mEventName) + return; + + fromWidget(); + save(); +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index b950d1488..f883a5b94 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -42,6 +42,7 @@ class HorizontContainer; class IntTextField; class Label; class Slider; +class SliderList; class TextField; class SetupItem : public gcn::ActionListener @@ -353,4 +354,40 @@ class SetupItemSlider2 : public SetupItem bool mOnTheFly; }; +class SetupItemSliderList : public SetupItem +{ + public: + SetupItemSliderList(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width = 150, bool onTheFly = false, + bool mainConfig = true); + + SetupItemSliderList(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + std::string def, int width = 150, + bool onTheFly = false, bool mainConfig = true); + + ~SetupItemSliderList(); + + void createControls(); + + void fromWidget(); + + void toWidget(); + + void action(const gcn::ActionEvent &event); + + void apply(std::string eventName); + + protected: + HorizontContainer *mHorizont; + Label *mLabel; + SliderList *mSlider; + gcn::ListModel *mModel; + int mWidth; + bool mOnTheFly; +}; + #endif -- cgit v1.2.3-70-g09d2 From 5023a1d0b96071a35547dcc309ce45ba6a17eec1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 27 Feb 2012 22:44:30 +0300 Subject: Fix compilation. --- src/gui/setup_joystick.cpp | 31 +++---------------------------- src/gui/widgets/namesmodel.h | 6 ++++++ 2 files changed, 9 insertions(+), 28 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index a3240282a..cb3ff9341 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -31,6 +31,7 @@ #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" #include "utils/gettext.h" @@ -40,32 +41,6 @@ extern Joystick *joystick; -class NamesModel : public gcn::ListModel -{ - public: - NamesModel() - { } - - virtual ~NamesModel() - { } - - virtual int getNumberOfElements() - { - return static_cast(mNames.size()); - } - - virtual std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return _("???"); - - return mNames[i]; - } - - std::vector mNames; -}; - - Setup_Joystick::Setup_Joystick(): mCalibrateLabel(new Label(_("Press the button to start calibration"))), mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)), @@ -77,7 +52,7 @@ Setup_Joystick::Setup_Joystick(): { setName(_("Joystick")); - Joystick::getNames(mNamesModel->mNames); + Joystick::getNames(mNamesModel->getNames()); mOriginalJoystickEnabled = config.getBoolValue("joystickEnabled"); mJoystickEnabled->setSelected(mOriginalJoystickEnabled); @@ -95,7 +70,7 @@ Setup_Joystick::Setup_Joystick(): else { unsigned sel = config.getIntValue("selectedJoystick"); - if (sel >= mNamesModel->mNames.size()) + if (sel >= mNamesModel->size()) sel = 0; mNamesDropDown->setSelected(sel); } diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h index 3f9f10b52..dc694fc46 100644 --- a/src/gui/widgets/namesmodel.h +++ b/src/gui/widgets/namesmodel.h @@ -38,6 +38,12 @@ class NamesModel : public gcn::ListModel virtual std::string getElementAt(int i); + std::vector &getNames() + { return mNames; } + + size_t size() + { return mNames.size(); } + protected: std::vector mNames; }; -- cgit v1.2.3-70-g09d2 From c85d939d9b3f6c10288dc86ffa7811408e349657 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 02:14:15 +0300 Subject: Add different sound effects for different events. Can be configured in audio tab in settings. --- data/sfx/system/CMakeLists.txt | 16 ++++++++++++ data/sfx/system/Makefile.am | 18 +++++++++++++- data/sfx/system/attention.ogg | Bin 0 -> 10439 bytes data/sfx/system/chat1.ogg | Bin 0 -> 8270 bytes data/sfx/system/chat2.ogg | Bin 0 -> 6341 bytes data/sfx/system/complete.ogg | Bin 0 -> 13971 bytes data/sfx/system/email.ogg | Bin 0 -> 21002 bytes data/sfx/system/error.ogg | Bin 0 -> 7192 bytes data/sfx/system/finish.ogg | Bin 0 -> 12576 bytes data/sfx/system/incoming.ogg | Bin 0 -> 15903 bytes data/sfx/system/move.ogg | Bin 0 -> 6443 bytes data/sfx/system/notify.ogg | Bin 0 -> 9485 bytes data/sfx/system/offline.ogg | Bin 0 -> 7119 bytes data/sfx/system/online.ogg | Bin 0 -> 7883 bytes data/sfx/system/reminder.ogg | Bin 0 -> 7279 bytes data/sfx/system/send.ogg | Bin 0 -> 8205 bytes data/sfx/system/start.ogg | Bin 0 -> 8597 bytes data/sfx/system/watcher.ogg | Bin 0 -> 8919 bytes src/client.cpp | 15 +++++++----- src/defaults.cpp | 7 ++++++ src/game.cpp | 6 ++--- src/gui/changeemaildialog.cpp | 3 ++- src/gui/changepassworddialog.cpp | 3 ++- src/gui/charcreatedialog.cpp | 4 +-- src/gui/charselectdialog.cpp | 2 +- src/gui/confirmdialog.cpp | 2 +- src/gui/editserverdialog.cpp | 2 +- src/gui/okdialog.cpp | 10 +++++++- src/gui/okdialog.h | 11 +++++++-- src/gui/register.cpp | 2 +- src/gui/setup_audio.cpp | 50 ++++++++++++++++++++++++++++++++++++++ src/gui/setup_audio.h | 5 ++++ src/gui/setup_keyboard.cpp | 2 +- src/gui/setup_theme.cpp | 4 +-- src/gui/setup_video.cpp | 16 +++++++----- src/gui/shopwindow.cpp | 2 +- src/gui/socialwindow.cpp | 6 ++--- src/gui/unregisterdialog.cpp | 3 ++- src/gui/widgets/chattab.cpp | 2 +- src/gui/widgets/setupitem.cpp | 40 ++++++++++++++++++++++++++++-- src/gui/widgets/setupitem.h | 21 +++++++++++++++- src/gui/widgets/sliderlist.h | 3 +++ src/localplayer.cpp | 5 ++-- src/net/ea/charserverhandler.cpp | 4 +-- src/net/ea/gamehandler.cpp | 2 +- src/net/ea/playerhandler.cpp | 7 +++--- src/net/manaserv/beinghandler.cpp | 3 ++- src/net/manaserv/charhandler.cpp | 4 +-- src/sound.cpp | 6 +++++ src/sound.h | 2 ++ 50 files changed, 237 insertions(+), 51 deletions(-) create mode 100644 data/sfx/system/attention.ogg create mode 100644 data/sfx/system/chat1.ogg create mode 100644 data/sfx/system/chat2.ogg create mode 100644 data/sfx/system/complete.ogg create mode 100644 data/sfx/system/email.ogg create mode 100644 data/sfx/system/error.ogg create mode 100644 data/sfx/system/finish.ogg create mode 100644 data/sfx/system/incoming.ogg create mode 100644 data/sfx/system/move.ogg create mode 100644 data/sfx/system/notify.ogg create mode 100644 data/sfx/system/offline.ogg create mode 100644 data/sfx/system/online.ogg create mode 100644 data/sfx/system/reminder.ogg create mode 100644 data/sfx/system/send.ogg create mode 100644 data/sfx/system/start.ogg create mode 100644 data/sfx/system/watcher.ogg (limited to 'src/gui') diff --git a/data/sfx/system/CMakeLists.txt b/data/sfx/system/CMakeLists.txt index bf6f0f0f3..0fa325a45 100644 --- a/data/sfx/system/CMakeLists.txt +++ b/data/sfx/system/CMakeLists.txt @@ -1,5 +1,21 @@ SET (FILES + attention.ogg + chat1.ogg + chat2.ogg + complete.ogg + email.ogg + error.ogg + finish.ogg + incoming.ogg + move.ogg + notify.ogg newmessage.ogg + offline.ogg + online.ogg + reminder.ogg + send.ogg + start.ogg + watcher.ogg ) INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/sfx/system) diff --git a/data/sfx/system/Makefile.am b/data/sfx/system/Makefile.am index e744932c3..d46934461 100644 --- a/data/sfx/system/Makefile.am +++ b/data/sfx/system/Makefile.am @@ -1,7 +1,23 @@ systemdir = $(pkgdatadir)/data/sfx/system system_DATA = \ - newmessage.ogg + attention.ogg \ + chat1.ogg \ + chat2.ogg \ + complete.ogg \ + email.ogg \ + error.ogg \ + finish.ogg \ + incoming.ogg \ + move.ogg \ + newmessage.ogg \ + notify.ogg \ + offline.ogg \ + online.ogg \ + reminder.ogg \ + send.ogg \ + start.ogg \ + watcher.ogg EXTRA_DIST = \ $(system_DATA) \ diff --git a/data/sfx/system/attention.ogg b/data/sfx/system/attention.ogg new file mode 100644 index 000000000..929265775 Binary files /dev/null and b/data/sfx/system/attention.ogg differ diff --git a/data/sfx/system/chat1.ogg b/data/sfx/system/chat1.ogg new file mode 100644 index 000000000..ad6c52a1d Binary files /dev/null and b/data/sfx/system/chat1.ogg differ diff --git a/data/sfx/system/chat2.ogg b/data/sfx/system/chat2.ogg new file mode 100644 index 000000000..155b15e1f Binary files /dev/null and b/data/sfx/system/chat2.ogg differ diff --git a/data/sfx/system/complete.ogg b/data/sfx/system/complete.ogg new file mode 100644 index 000000000..0975ff7c8 Binary files /dev/null and b/data/sfx/system/complete.ogg differ diff --git a/data/sfx/system/email.ogg b/data/sfx/system/email.ogg new file mode 100644 index 000000000..afb25909f Binary files /dev/null and b/data/sfx/system/email.ogg differ diff --git a/data/sfx/system/error.ogg b/data/sfx/system/error.ogg new file mode 100644 index 000000000..69dccfe7c Binary files /dev/null and b/data/sfx/system/error.ogg differ diff --git a/data/sfx/system/finish.ogg b/data/sfx/system/finish.ogg new file mode 100644 index 000000000..d8dbbf80f Binary files /dev/null and b/data/sfx/system/finish.ogg differ diff --git a/data/sfx/system/incoming.ogg b/data/sfx/system/incoming.ogg new file mode 100644 index 000000000..a8ff86676 Binary files /dev/null and b/data/sfx/system/incoming.ogg differ diff --git a/data/sfx/system/move.ogg b/data/sfx/system/move.ogg new file mode 100644 index 000000000..e5c703bbf Binary files /dev/null and b/data/sfx/system/move.ogg differ diff --git a/data/sfx/system/notify.ogg b/data/sfx/system/notify.ogg new file mode 100644 index 000000000..95d8fed4a Binary files /dev/null and b/data/sfx/system/notify.ogg differ diff --git a/data/sfx/system/offline.ogg b/data/sfx/system/offline.ogg new file mode 100644 index 000000000..cc1b8e938 Binary files /dev/null and b/data/sfx/system/offline.ogg differ diff --git a/data/sfx/system/online.ogg b/data/sfx/system/online.ogg new file mode 100644 index 000000000..3e55793fd Binary files /dev/null and b/data/sfx/system/online.ogg differ diff --git a/data/sfx/system/reminder.ogg b/data/sfx/system/reminder.ogg new file mode 100644 index 000000000..d7beeed6f Binary files /dev/null and b/data/sfx/system/reminder.ogg differ diff --git a/data/sfx/system/send.ogg b/data/sfx/system/send.ogg new file mode 100644 index 000000000..b5941323d Binary files /dev/null and b/data/sfx/system/send.ogg differ diff --git a/data/sfx/system/start.ogg b/data/sfx/system/start.ogg new file mode 100644 index 000000000..0b1f85643 Binary files /dev/null and b/data/sfx/system/start.ogg differ diff --git a/data/sfx/system/watcher.ogg b/data/sfx/system/watcher.ogg new file mode 100644 index 000000000..9a0dd1af2 Binary files /dev/null and b/data/sfx/system/watcher.ogg differ diff --git a/src/client.cpp b/src/client.cpp index 978c58eef..5f79176c7 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1327,14 +1327,16 @@ int Client::gameExec() case STATE_LOGIN_ERROR: logger->log1("State: LOGIN ERROR"); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&loginListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_ACCOUNTCHANGE_ERROR: logger->log1("State: ACCOUNT CHANGE ERROR"); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; @@ -1370,7 +1372,7 @@ int Client::gameExec() case STATE_CHANGEPASSWORD_SUCCESS: logger->log1("State: CHANGE PASSWORD SUCCESS"); mCurrentDialog = new OkDialog(_("Password Change"), - _("Password changed successfully!")); + _("Password changed successfully!"), DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself loginData.password = loginData.newPassword; @@ -1390,7 +1392,7 @@ int Client::gameExec() case STATE_CHANGEEMAIL_SUCCESS: logger->log1("State: CHANGE EMAIL SUCCESS"); mCurrentDialog = new OkDialog(_("Email Change"), - _("Email changed successfully!")); + _("Email changed successfully!"), DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; @@ -1411,7 +1413,7 @@ int Client::gameExec() Net::getLoginHandler()->disconnect(); mCurrentDialog = new OkDialog(_("Unregister Successful"), - _("Farewell, come back any time...")); + _("Farewell, come back any time..."), DIALOG_ERROR); loginData.clear(); //The errorlistener sets the state to STATE_CHOOSE_SERVER mCurrentDialog->addActionListener(&errorListener); @@ -1468,7 +1470,8 @@ int Client::gameExec() case STATE_ERROR: logger->log1("State: ERROR"); logger->log("Error: %s\n", errorMessage.c_str()); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&errorListener); mCurrentDialog = nullptr; // OkDialog deletes itself Net::getGameHandler()->disconnect(); diff --git a/src/defaults.cpp b/src/defaults.cpp index 01907bfe8..cd2911192 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -229,6 +229,13 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "grabinput", false); AddDEF(configData, "gamma", 1); AddDEF(configData, "vsync", 0); + AddDEF(configData, "soundwhisper", "newmessage"); + AddDEF(configData, "soundhighlight", "reminder"); + AddDEF(configData, "soundglobal", "email"); + AddDEF(configData, "sounderror", "error"); + AddDEF(configData, "soundtrade", "start"); + AddDEF(configData, "soundinfo", "notify"); + AddDEF(configData, "soundrequest", "attention"); return configData; } diff --git a/src/game.cpp b/src/game.cpp index e016d02ff..ae8682972 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -561,7 +561,7 @@ void Game::logic() { errorMessage = _("The connection to the server was lost."); disconnectedDialog = new OkDialog(_("Network Error"), - errorMessage, false); + errorMessage, DIALOG_ERROR, false); disconnectedDialog->addActionListener(&errorListener); disconnectedDialog->requestMoveToTop(); } @@ -1796,8 +1796,8 @@ void Game::changeMap(const std::string &mapPath) if (!newMap) { logger->log("Error while loading %s", fullMap.c_str()); - new OkDialog(_("Could Not Load Map"), - strprintf(_("Error while loading %s"), fullMap.c_str())); + new OkDialog(_("Could Not Load Map"), strprintf( + _("Error while loading %s"), fullMap.c_str()), DIALOG_ERROR); } if (mCurrentMap) diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 518ed3da1..1a468d44f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -154,7 +154,8 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 8082b8d58..a58d8616b 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -144,7 +144,8 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 9f7436ad8..124476f1c 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -270,8 +270,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) else { new OkDialog(_("Error"), - _("Your name needs to be at least 4 characters."), - true, this); + _("Your name needs to be at least 4 characters."), + DIALOG_ERROR, true, this); } } else if (id == "cancel") diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index d2b74a632..b1b8009a4 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -253,7 +253,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) } else { - new OkDialog(_("Error"), _("Incorrect password")); + new OkDialog(_("Error"), _("Incorrect password"), DIALOG_ERROR); } mDeleteIndex = -1; } diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index 22acf5116..b6645db3c 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -97,7 +97,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, } setVisible(true); yesButton->requestFocus(); - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundrequest"); } void ConfirmDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp index 53e31c3c8..ca1afeaba 100644 --- a/src/gui/editserverdialog.cpp +++ b/src/gui/editserverdialog.cpp @@ -173,7 +173,7 @@ void EditServerDialog::action(const gcn::ActionEvent &event) { OkDialog *dlg = new OkDialog(_("Error"), _("Please at least type both the address and the port " - "of the server.")); + "of the server."), DIALOG_ERROR); dlg->addActionListener(this); } else diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 4a3bdf731..fe22cf008 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -22,6 +22,8 @@ #include "gui/okdialog.h" +#include "sound.h" + #include "gui/gui.h" #include "gui/widgets/button.h" @@ -34,7 +36,8 @@ #include "debug.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, - bool modal, bool showCenter, Window *parent): + int soundEvent, bool modal, bool showCenter, + Window *parent): Window(title, modal, parent, "ok.xml") { mTextBox = new TextBox; @@ -71,6 +74,11 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, centerHorisontally(); setVisible(true); okButton->requestFocus(); + + if (soundEvent == DIALOG_OK) + sound.playGuiSound("soundinfo"); + else if (soundEvent == DIALOG_ERROR) + sound.playGuiSound("sounderror"); } void OkDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 5705be568..b6f17480b 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -31,6 +31,13 @@ class TextBox; +enum +{ + DIALOG_OK = 0, + DIALOG_ERROR, + DIALOG_SILENCE +}; + /** * An 'Ok' button dialog. * @@ -45,8 +52,8 @@ class OkDialog : public Window, public gcn::ActionListener * @see Window::Window */ OkDialog(const std::string &title, const std::string &msg, - bool modal = true, bool showCenter = true, - Window *parent = nullptr); + int soundEvent = DIALOG_OK, bool modal = true, + bool showCenter = true, Window *parent = nullptr); /** * Called when receiving actions from the widgets. diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 2122e0d6b..bf0cb299e 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMsg); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg, DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 1f7db484c..a4c3110d9 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -25,9 +25,11 @@ #include "configuration.h" #include "sound.h" +#include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" @@ -35,6 +37,19 @@ #include "debug.h" +class SoundsModel : public NamesModel +{ +public: + SoundsModel() + { + mNames.push_back(gettext("(no sound)")); + Theme::fillSoundsList(mNames); + } + + virtual ~SoundsModel() + { } +}; + Setup_Audio::Setup_Audio() { setName(_("Audio")); @@ -44,6 +59,10 @@ Setup_Audio::Setup_Audio() ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); + mSoundModel = new SoundsModel(); + + new SetupItemLabel(_("Basic settings"), "", this); + new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent"); new SetupItemCheckBox(_("Enable music"), "", @@ -61,6 +80,31 @@ Setup_Audio::Setup_Audio() new SetupItemSlider(_("Music volume"), "", "musicVolume", this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true); + new SetupItemLabel(_("Sound effects"), "", this); + + new SetupItemSound(_("Information dialog sound"), "", + "soundinfo", this, "soundinfoEvent", mSoundModel); + + new SetupItemSound(_("Request dialog sound"), "", + "soundrequest", this, "soundrequestEvent", mSoundModel); + + new SetupItemSound(_("Whisper message sound"), "", + "soundwhisper", this, "soundwhisperEvent", mSoundModel); + + new SetupItemSound(_("Highlight message sound"), "", + "soundhighlight", this, "soundhighlightEvent", mSoundModel); + + new SetupItemSound(_("Global message sound"), "", + "soundglobal", this, "soundglobalEvent", mSoundModel); + + new SetupItemSound(_("Error message sound"), "", + "sounderror", this, "sounderrorEvent", mSoundModel); + + new SetupItemSound(_("Trade request sound"), "", + "soundtrade", this, "soundtradeEvent", mSoundModel); + + new SetupItemLabel(_("Other"), "", this); + new SetupItemCheckBox(_("Enable mumble voice chat"), "", "enableMumble", this, "enableMumbleEvent"); @@ -70,6 +114,12 @@ Setup_Audio::Setup_Audio() setDimension(gcn::Rectangle(0, 0, 550, 350)); } +Setup_Audio::~Setup_Audio() +{ + delete mSoundModel; + mSoundModel = nullptr; +} + void Setup_Audio::apply() { SetupTabScroll::apply(); diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index c08c49c7a..21b661bcb 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -34,7 +34,12 @@ class Setup_Audio : public SetupTabScroll public: Setup_Audio(); + ~Setup_Audio(); + void apply(); + + private: + gcn::ListModel *mSoundModel; }; #endif diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index bdd7c2083..ef024c5d9 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -131,7 +131,7 @@ void Setup_Keyboard::apply() if (keyboard.hasConflicts()) { new OkDialog(_("Key Conflict(s) Detected."), - keyboard.getBindError()); + keyboard.getBindError(), DIALOG_ERROR); } keyboard.setEnabled(true); keyboard.store(); diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index d3b9d0e3c..7386f496a 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -349,8 +349,8 @@ void Setup_Theme::apply() if (config.getValue("theme", config.getValue("selectedSkin", "")) != mTheme) { - new OkDialog(_("Theme Changed"), - _("Restart your client for the change to take effect.")); + new OkDialog(_("Theme Changed"), _("Restart your client for " + "the change to take effect.")); } config.setValue("selectedSkin", ""); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 6690f1452..24d42c83d 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -393,7 +393,7 @@ void Setup_Video::apply() else { new OkDialog(_("Switching to Full Screen"), - _("Restart needed for changes to take effect.")); + _("Restart needed for changes to take effect.")); } #endif config.setValue("screen", fullscreen); @@ -406,7 +406,7 @@ void Setup_Video::apply() // OpenGL can currently only be changed by restarting, notify user. new OkDialog(_("Changing to OpenGL"), - _("Applying change to OpenGL requires restart.")); + _("Applying change to OpenGL requires restart.")); } mFps = mFpsCheckBox->isSelected() ? @@ -498,13 +498,17 @@ void Setup_Video::action(const gcn::ActionEvent &event) { #if defined(_WIN32) if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) + { new OkDialog(_("Screen Resolution Changed"), - _("Restart your client for the change to take effect.") - + std::string("\n") + - _("Some windows may be moved to fit the lowered resolution.")); + _("Restart your client for the change to take effect.") + + std::string("\n") + _("Some windows may be moved to " + "fit the lowered resolution.")); + } else + { new OkDialog(_("Screen Resolution Changed"), - _("Restart your client for the change to take effect.")); + _("Restart your client for the change to take effect.")); + } #else Client::resize(width, height); #endif diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 1a27b8b0c..33ab32ca5 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -753,7 +753,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode) if (config.getBoolValue("autoShop")) { - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundtrade"); startTrade(); } else diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 287089790..f0ac9e128 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1630,13 +1630,13 @@ void SocialWindow::showPartyCreate() if (player_node->getParty()) { new OkDialog(_("Create Party"), - _("Cannot create party. You are already in a party"), - this); + _("Cannot create party. You are already in a party"), + DIALOG_ERROR, true, true, this); return; } mPartyCreateDialog = new TextDialog(_("Party Name"), - _("Choose your party's name."), this); + _("Choose your party's name."), this); mPartyCreateDialog->setActionEventId("create party"); mPartyCreateDialog->addActionListener(this); } diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index ca21263f1..9ba895ec8 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -134,7 +134,8 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 018e35030..53842e887 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -301,7 +301,7 @@ void ChatTab::chatLog(std::string line, Own own, && !Client::getInputFocused())))) { if (own != BY_SERVER) - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundwhisper"); } } } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 581002a58..9eedfd58d 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "main.h" #include "logger.h" +#include "sound.h" #include "gui/editdialog.h" #include "gui/gui.h" @@ -872,7 +873,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::SetupItemSliderList(std::string text, @@ -892,7 +893,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::~SetupItemSliderList() @@ -917,6 +918,8 @@ void SetupItemSliderList::createControls() mHorizont->add(mLabel, 5); mHorizont->add(mSlider); + addMoreControls(); + mParent->getContainer()->add2(mHorizont, true, 4); mParent->addControl(this); mParent->addActionListener(this); @@ -954,3 +957,36 @@ void SetupItemSliderList::apply(std::string eventName) fromWidget(); save(); } + +SetupItemSound::SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width, bool onTheFly, bool mainConfig) : + SetupItemSliderList(text, description, keyName, parent, eventName, + model, width, onTheFly, mainConfig), + mButton(nullptr) +{ + createControls(); +} + +void SetupItemSound::addMoreControls() +{ + mButton = new Button(_("Play"), mEventName + "_PLAY", this); + mHorizont->add(mButton); +} + +void SetupItemSound::action(const gcn::ActionEvent &event) +{ + if (event.getId() == mEventName + "_PLAY") + { + if (mSlider->getSelected()) + { + sound.playGuiSfx(branding.getStringValue("systemsounds") + + mSlider->getSelectedString() + ".ogg"); + } + } + else + { + SetupItemSliderList::action(event); + } +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index f883a5b94..38dec929e 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -377,10 +377,12 @@ class SetupItemSliderList : public SetupItem void toWidget(); - void action(const gcn::ActionEvent &event); + virtual void action(const gcn::ActionEvent &event); void apply(std::string eventName); + virtual void addMoreControls() = 0; + protected: HorizontContainer *mHorizont; Label *mLabel; @@ -390,4 +392,21 @@ class SetupItemSliderList : public SetupItem bool mOnTheFly; }; +class SetupItemSound : public SetupItemSliderList +{ + public: + SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width = 150, bool onTheFly = false, + bool mainConfig = true); + + void action(const gcn::ActionEvent &event); + + void addMoreControls(); + + protected: + Button *mButton; +}; + #endif diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index a7b1a564c..b2239834d 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -63,6 +63,9 @@ class SliderList : public Container, void adjustSize(); + int getSelected() + { return mSelectedIndex; } + protected: void updateLabel(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 5114f868c..de1304240 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2204,7 +2204,8 @@ void LocalPlayer::changeAwayMode() if (outfitWindow) outfitWindow->wearAwayOutfit(); mAwayDialog = new OkDialog(_("Away"), - config.getStringValue("afkMessage"), true, false); + config.getStringValue("afkMessage"), + DIALOG_SILENCE, true, false); mAwayDialog->addActionListener(mAwayListener); sound.volumeOff(); } @@ -4147,7 +4148,7 @@ void LocalPlayer::checkNewName(Being *being) if (!mWaitFor.empty() && mWaitFor == nick) { debugMsg(_("You see ") + mWaitFor); - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundinfo"); mWaitFor = ""; } } diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 2dc51acf3..67894b0d9 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -167,7 +167,7 @@ void CharServerHandler::processCharCreateFailed(Net::MessageIn &msg) errorMessage = _("Incorrect race."); break; } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); if (mCharCreateDialog) mCharCreateDialog->unlock(); } @@ -185,7 +185,7 @@ void CharServerHandler::processCharDelete(Net::MessageIn &msg A_UNUSED) void CharServerHandler::processCharDeleteFailed(Net::MessageIn &msg A_UNUSED) { unlockCharSelectDialog(); - new OkDialog(_("Error"), _("Failed to delete character.")); + new OkDialog(_("Error"), _("Failed to delete character."), DIALOG_ERROR); } void CharServerHandler::clear() diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 6d021d6a9..c8c870dbd 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -101,7 +101,7 @@ void GameHandler::processCharSwitchResponse(Net::MessageIn &msg) void GameHandler::processMapQuitResponse(Net::MessageIn &msg) { if (msg.readInt8()) - new OkDialog(_("Game"), _("Request to quit denied!"), nullptr); + new OkDialog(_("Game"), _("Request to quit denied!"), DIALOG_ERROR); } } // namespace Ea diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 27aa4da80..ddcf7d9c0 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -336,7 +336,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) weightNotice = new OkDialog(_("Message"), _("You are carrying more than " "half your weight. You are " - "unable to regain health."), false); + "unable to regain health."), DIALOG_ERROR, false); weightNotice->addActionListener( &weightListener); } @@ -346,7 +346,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) weightNotice = new OkDialog(_("Message"), _("You are carrying less than " "half your weight. You " - "can regain health."), false); + "can regain health."), DIALOG_ERROR, false); weightNotice->addActionListener( &weightListener); } @@ -426,8 +426,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) if (PlayerInfo::getAttribute(HP) == 0 && !deathNotice) { deathNotice = new OkDialog(_("Message"), - randomDeathMessage(), - false); + randomDeathMessage(), false); deathNotice->addActionListener(&deathListener); player_node->setAction(Being::DEAD); } diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index cef4f497a..9468baaa1 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -335,7 +335,8 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg) }; std::string message(deadMsg[rand() % 13]); message.append(std::string(" ") + _("Press OK to respawn.")); - OkDialog *dlg = new OkDialog(_("You Died"), message, false); + OkDialog *dlg = new OkDialog(_("You Died"), + message, DIALOG_OK, false); dlg->addActionListener(&(ManaServ::respawnListener)); } } diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 300af5a2b..7977df909 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -181,7 +181,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) errorMessage = _("Unknown error."); break; } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); if (mCharCreateDialog) mCharCreateDialog->unlock(); @@ -224,7 +224,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg) default: errorMessage = strprintf(_("Unknown error (%d)."), errMsg); } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); } mSelectedCharacter = 0; unlockCharSelectDialog(); diff --git a/src/sound.cpp b/src/sound.cpp index 25b37d578..2c7ecb53d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -325,6 +325,12 @@ void Sound::playSfx(const std::string &path, int x, int y) } } +void Sound::playGuiSound(const std::string &name) +{ + playGuiSfx(branding.getStringValue("systemsounds") + + config.getStringValue(name) + ".ogg"); +} + void Sound::playGuiSfx(const std::string &path) { if (!mInstalled || path.empty() || !mPlayGui) diff --git a/src/sound.h b/src/sound.h index 7f9fb64a4..cfa847a0b 100644 --- a/src/sound.h +++ b/src/sound.h @@ -109,6 +109,8 @@ class Sound : public ConfigListener */ void playGuiSfx(const std::string &path); + void playGuiSound(const std::string &name); + void changeAudio(); void volumeOff(); -- cgit v1.2.3-70-g09d2 From 3e026f7efc76b0e6e76177d04c989432cb517b7a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 03:29:34 +0300 Subject: Fix manaplus clients name highlight in evol server. Before was all highlighted. --- src/being.cpp | 2 +- src/gui/whoisonline.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index b5f55592f..2d8bc042c 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2525,7 +2525,6 @@ void Being::saveComment(const std::string &name, void Being::setState(Uint8 state) { - mAdvanced = true; bool shop = (state & FLAG_SHOP); bool away = (state & FLAG_AWAY); bool inactive = (state & FLAG_INACTIVE); @@ -2548,6 +2547,7 @@ void Being::setEmote(Uint8 emotion, int emote_time) if ((emotion & FLAG_SPECIAL) == FLAG_SPECIAL) { setState(emotion); + mAdvanced = true; } else { diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 15c8a42c4..eba058bd7 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -738,7 +738,12 @@ void OnlinePlayer::setText(std::string color) Being *being = actorSpriteManager->findBeingByName( mNick, Being::PLAYER); if (being) + { being->setState(mStatus); + // for now highlight versions > 3 + if (mVersion > 3) + being->setAdvanced(true); + } } if (mLevel > 0) -- cgit v1.2.3-70-g09d2 From b985de6e83790bd02bd63e3ed47a3a79592b08da Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 20:34:46 +0300 Subject: Add image support for buttons. --- src/gui/widgets/button.cpp | 191 ++++++++++++++++++++++++++++++++++++++++----- src/gui/widgets/button.h | 31 ++++++++ 2 files changed, 202 insertions(+), 20 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 2867e3d39..10a64a3d3 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -32,6 +32,7 @@ #include "gui/theme.h" #include "resources/image.h" +#include "resources/imageset.h" #include "utils/dtor.h" @@ -69,30 +70,92 @@ static ButtonData const data[BUTTON_COUNT] = ImageRect Button::button[BUTTON_COUNT]; -Button::Button(): +Button::Button() : mDescription(""), mClickCount(0), mTag(0), mVertexes(new GraphicsVertexes()), mRedraw(true), mMode(0), mXOffset(0), - mYOffset(0) + mYOffset(0), + mImages(nullptr), + mImageSet(nullptr) { init(); + adjustSize(); } Button::Button(const std::string &caption, const std::string &actionEventId, - gcn::ActionListener *listener): + gcn::ActionListener *listener) : gcn::Button(caption), - mDescription(""), mClickCount(0), + mDescription(""), + mClickCount(0), + mTag(0), + mVertexes(new GraphicsVertexes()), + mRedraw(true), + mMode(0), + mXOffset(0), + mYOffset(0), + mImages(nullptr), + mImageSet(nullptr), + mImageWidth(0), + mImageHeight(0) +{ + init(); + adjustSize(); + setActionEventId(actionEventId); + + if (listener) + addActionListener(listener); +} + +Button::Button(const std::string &caption, const std::string &imageName, + int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener) : + gcn::Button(caption), + mDescription(""), + mClickCount(0), + mTag(0), + mVertexes(new GraphicsVertexes()), + mRedraw(true), + mMode(0), + mXOffset(0), + mYOffset(0), + mImages(nullptr), + mImageSet(nullptr), + mImageWidth(imageWidth), + mImageHeight(imageHeight) +{ + init(); + loadImage(imageName); + adjustSize(); + setActionEventId(actionEventId); + + if (listener) + addActionListener(listener); +} + +Button::Button(const std::string &imageName, int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener) : + gcn::Button(""), + mDescription(""), + mClickCount(0), mTag(0), mVertexes(new GraphicsVertexes()), mRedraw(true), mMode(0), mXOffset(0), - mYOffset(0) + mYOffset(0), + mImages(nullptr), + mImageSet(nullptr), + mImageWidth(imageWidth), + mImageHeight(imageHeight) { init(); + loadImage(imageName); + adjustSize(); setActionEventId(actionEventId); if (listener) @@ -158,6 +221,41 @@ Button::~Button() } } } + if (mImageSet) + { + mImageSet->decRef(); + mImageSet = nullptr; + } + if (mImages) + { + for (int f = 0; f < BUTTON_COUNT; f ++) + mImages[f] = 0; + delete [] mImages; + mImages = nullptr; + } +} + +void Button::loadImage(const std::string &imageName) +{ + if (mImageSet) + { + mImageSet->decRef(); + mImageSet = nullptr; + } + mImageSet = Theme::getImageSetFromTheme(imageName, + mImageWidth, mImageHeight); + if (!mImageSet) + return; + mImages = new Image*[BUTTON_COUNT]; + mImages[0] = nullptr; + for (int f = 0; f < BUTTON_COUNT; f ++) + { + Image *img = mImageSet->get(f); + if (img) + mImages[f] = img; + else + mImages[f] = mImages[0]; + } } void Button::updateAlpha() @@ -197,6 +295,7 @@ void Button::draw(gcn::Graphics *graphics) updateAlpha(); + Graphics *g2 = static_cast(graphics); bool recalc = false; if (mRedraw) @@ -207,8 +306,7 @@ void Button::draw(gcn::Graphics *graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - gcn::ClipRectangle &rect = static_cast( - graphics)->getTopClip(); + gcn::ClipRectangle &rect = g2->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { recalc = true; @@ -220,7 +318,7 @@ void Button::draw(gcn::Graphics *graphics) recalc = true; mMode = mode; } - else if (static_cast(graphics)->getRedraw()) + else if (g2->getRedraw()) { recalc = true; } @@ -230,45 +328,74 @@ void Button::draw(gcn::Graphics *graphics) { mRedraw = false; mMode = mode; - static_cast(graphics)->calcWindow(mVertexes, 0, 0, - getWidth(), getHeight(), button[mode]); + g2->calcWindow(mVertexes, 0, 0, getWidth(), getHeight(), button[mode]); } - static_cast(graphics)->drawImageRect2( - mVertexes, button[mode]); + g2->drawImageRect2(mVertexes, button[mode]); -// static_cast(graphics)-> -// drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); +// g2->drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); if (mode == BUTTON_DISABLED) graphics->setColor(mDisabledColor); else graphics->setColor(mEnabledColor); - int textX; + int textX = 0; int textY = getHeight() / 2 - getFont()->getHeight() / 2; + int imageX = 0; + int imageY = 0; + if (mImages) + imageY = getHeight() / 2 - mImageHeight / 2; + +// need move calculation from draw!!! switch (getAlignment()) { default: case gcn::Graphics::LEFT: - textX = 4; + if (mImages) + { + imageX = 4; + textX = 4 + mImageWidth + 2; + } + else + { + textX = 4; + } break; case gcn::Graphics::CENTER: - textX = getWidth() / 2; + if (mImages) + { + textX = getWidth() / 2; + int width = getFont()->getWidth(mCaption) + mImageWidth + 2; + imageX = getWidth() / 2 - width / 2; + textX = imageX + mImageWidth + 2; + } + else + { + textX = getWidth() / 2; + } break; case gcn::Graphics::RIGHT: textX = getWidth() - 4; + imageX = textX - getFont()->getWidth(mCaption) - 2; break; -// throw GCN_EXCEPTION("Button::draw. Unknown alignment."); } graphics->setFont(getFont()); if (isPressed()) - graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); + { + if (mImages) + g2->drawImage(mImages[mode], imageX + 1, imageY + 1); + g2->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); + } else - graphics->drawText(getCaption(), textX, textY, getAlignment()); + { + if (mImages) + g2->drawImage(mImages[mode], imageX, imageY); + g2->drawText(getCaption(), textX, textY, getAlignment()); + } } void Button::mouseReleased(gcn::MouseEvent& mouseEvent) @@ -298,3 +425,27 @@ void Button::widgetMoved(const gcn::Event &event A_UNUSED) { mRedraw = true; } + +void Button::adjustSize() +{ + if (mImages) + { + setWidth(getFont()->getWidth(mCaption) + + mImageWidth + 2 + 2 * mSpacing); + int height = getFont()->getHeight(); + if (height < mImageHeight) + height = mImageHeight; + setHeight(height + 2 * mSpacing); + } + else + { + setWidth(getFont()->getWidth(mCaption) + 2 * mSpacing); + setHeight(getFont()->getHeight() + 2 * mSpacing); + } +} + +void Button::setCaption(const std::string& caption) +{ + mCaption = caption; + adjustSize(); +} diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 560e46377..6585d9850 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -28,8 +28,12 @@ #include class GraphicsVertexes; +class Image; +class ImageSet; class ImageRect; +const std::string BUTTON_PLAY = "buttonplay.png"; + /** * Button widget. Same as the Guichan button but with custom look. * @@ -50,6 +54,23 @@ class Button : public gcn::Button, public gcn::WidgetListener Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener); + /** + * Constructor, sets the caption of the button to the given string and + * adds the given action listener. + */ + Button(const std::string &caption, const std::string &imageName, + int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener); + + /** + * Constructor, sets the caption of the button to the given string and + * adds the given action listener. + */ + Button(const std::string &imageName, int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener); + /** * Destructor. */ @@ -86,6 +107,12 @@ class Button : public gcn::Button, public gcn::WidgetListener void widgetMoved(const gcn::Event &event); + void loadImage(const std::string &imageName); + + void adjustSize(); + + void setCaption(const std::string& caption); + private: void init(); @@ -103,6 +130,10 @@ class Button : public gcn::Button, public gcn::WidgetListener int mYOffset; gcn::Color mEnabledColor; gcn::Color mDisabledColor; + Image **mImages; + ImageSet *mImageSet; + int mImageWidth; + int mImageHeight; }; #endif -- cgit v1.2.3-70-g09d2 From 6ffd428383326c7b77e1b5e1777ae3a9f2e4156b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 21:24:03 +0300 Subject: Replace "play" button text to image. --- data/graphics/gui/CMakeLists.txt | 1 + data/graphics/gui/Makefile.am | 1 + data/graphics/gui/buttonplay.png | Bin 0 -> 272 bytes src/gui/widgets/setupitem.cpp | 2 +- 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 data/graphics/gui/buttonplay.png (limited to 'src/gui') diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index aba42b39c..b262a5ac3 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -3,6 +3,7 @@ SET (FILES button.png button_disabled.png buttonhi.png + buttonplay.png buttonpress.png checkbox.png circle-gray.png diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index 7fb82f545..6f294fa45 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -6,6 +6,7 @@ gui_DATA = \ button.png \ button_disabled.png \ buttonhi.png \ + buttonplay.png \ buttonpress.png \ checkbox.png \ circle-gray.png \ diff --git a/data/graphics/gui/buttonplay.png b/data/graphics/gui/buttonplay.png new file mode 100644 index 000000000..cd3a2c3db Binary files /dev/null and b/data/graphics/gui/buttonplay.png differ diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 9eedfd58d..7c15ea785 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -971,7 +971,7 @@ SetupItemSound::SetupItemSound(std::string text, std::string description, void SetupItemSound::addMoreControls() { - mButton = new Button(_("Play"), mEventName + "_PLAY", this); + mButton = new Button(BUTTON_PLAY, 16, 16, mEventName + "_PLAY", this); mHorizont->add(mButton); } -- cgit v1.2.3-70-g09d2 From 8a3adb5dc695fec3f4db5f0705c53687862fb801 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 21:33:08 +0300 Subject: Add some missing debug includes. --- src/gui/widgets/button.cpp | 2 +- src/gui/widgets/setupitem.cpp | 2 ++ src/utils/checkutils.cpp | 2 ++ src/utils/physfsrwops.cpp | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 10a64a3d3..b430dfebb 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -447,5 +447,5 @@ void Button::adjustSize() void Button::setCaption(const std::string& caption) { mCaption = caption; - adjustSize(); +// adjustSize(); } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 7c15ea785..b3a018813 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -47,6 +47,8 @@ #include +#include "debug.h" + SetupItem::SetupItem(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, std::string eventName, bool mainConfig) : diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp index 64bb42d0c..abbc6138a 100644 --- a/src/utils/checkutils.cpp +++ b/src/utils/checkutils.cpp @@ -24,6 +24,8 @@ #include "logger.h" +#include "debug.h" + bool reportFalseReal(bool val, const char* file, unsigned line) { if (!val) diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp index 2675b89ae..19b08d4c7 100644 --- a/src/utils/physfsrwops.cpp +++ b/src/utils/physfsrwops.cpp @@ -27,6 +27,8 @@ #include "localconsts.h" +#include "debug.h" + static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) { PHYSFS_file *handle = static_cast(rw->hidden.unknown.data1); -- cgit v1.2.3-70-g09d2 From bbf5743dd18e78298376da6f78c71ae2a524c766 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 22:16:23 +0300 Subject: Fix some sound event. Replace hardcoded sound names to constants. Add party/guild sound. --- src/defaults.cpp | 1 + src/gui/confirmdialog.cpp | 2 +- src/gui/okdialog.cpp | 4 ++-- src/gui/setup_audio.cpp | 3 +++ src/gui/shopwindow.cpp | 2 +- src/gui/widgets/chattab.cpp | 21 +++++++++++++++++++-- src/gui/widgets/chattab.h | 2 ++ src/gui/widgets/guildchattab.cpp | 6 ++++++ src/gui/widgets/guildchattab.h | 2 ++ src/localplayer.cpp | 2 +- src/net/ea/gui/guildtab.cpp | 6 ++++++ src/net/ea/gui/guildtab.h | 2 ++ src/net/ea/gui/partytab.cpp | 5 +++++ src/net/ea/gui/partytab.h | 2 ++ src/sound.h | 9 +++++++++ 15 files changed, 62 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/defaults.cpp b/src/defaults.cpp index cd2911192..3e53506b4 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -236,6 +236,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "soundtrade", "start"); AddDEF(configData, "soundinfo", "notify"); AddDEF(configData, "soundrequest", "attention"); + AddDEF(configData, "soundguild", "newmessage"); return configData; } diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index b6645db3c..a2fb7b6cc 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -97,7 +97,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, } setVisible(true); yesButton->requestFocus(); - sound.playGuiSound("soundrequest"); + sound.playGuiSound(SOUND_REQUEST); } void ConfirmDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index fe22cf008..3259cb6d6 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -76,9 +76,9 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, okButton->requestFocus(); if (soundEvent == DIALOG_OK) - sound.playGuiSound("soundinfo"); + sound.playGuiSound(SOUND_INFO); else if (soundEvent == DIALOG_ERROR) - sound.playGuiSound("sounderror"); + sound.playGuiSound(SOUND_ERROR); } void OkDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index a4c3110d9..69ca4e759 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -91,6 +91,9 @@ Setup_Audio::Setup_Audio() new SetupItemSound(_("Whisper message sound"), "", "soundwhisper", this, "soundwhisperEvent", mSoundModel); + new SetupItemSound(_("Guild / Party message sound"), "", + "soundguild", this, "soundguildEvent", mSoundModel); + new SetupItemSound(_("Highlight message sound"), "", "soundhighlight", this, "soundhighlightEvent", mSoundModel); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 33ab32ca5..01b589ab6 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -753,7 +753,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode) if (config.getBoolValue("autoShop")) { - sound.playGuiSound("soundtrade"); + sound.playGuiSound(SOUND_TRADE); startTrade(); } else diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 53842e887..be6a31164 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -289,9 +289,19 @@ void ChatTab::chatLog(std::string line, Own own, if (getFlash() == 0) { if (chatWindow && chatWindow->findHighlight(tmp.text)) + { setFlash(2); + sound.playGuiSound(SOUND_HIGHLIGHT); + } else + { setFlash(1); + } + } + else if (getFlash() == 2) + { + if (chatWindow && chatWindow->findHighlight(tmp.text)) + sound.playGuiSound(SOUND_HIGHLIGHT); } } @@ -300,8 +310,10 @@ void ChatTab::chatLog(std::string line, Own own, || (Client::getIsMinimized() || (!Client::getMouseFocused() && !Client::getInputFocused())))) { - if (own != BY_SERVER) - sound.playGuiSound("soundwhisper"); + if (own == BY_GM) + sound.playGuiSound(SOUND_GLOBAL); + else if (own != BY_SERVER) + playNewMessageSound(); } } } @@ -468,3 +480,8 @@ void ChatTab::addNewRow(std::string &line) } mScrollArea->logic(); } + +void ChatTab::playNewMessageSound() +{ + sound.playGuiSound(SOUND_WHISPER); +} diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 912305a63..d67f56b54 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -162,6 +162,8 @@ class ChatTab : public Tab void addNewRow(std::string &line); + virtual void playNewMessageSound(); + protected: friend class ChatWindow; friend class WhisperWindow; diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp index a95fca3cf..bad34cfb3 100644 --- a/src/gui/widgets/guildchattab.cpp +++ b/src/gui/widgets/guildchattab.cpp @@ -27,6 +27,7 @@ #include "guild.h" #include "guildmanager.h" #include "localplayer.h" +#include "sound.h" #include "gui/theme.h" @@ -126,3 +127,8 @@ void GuildChatTab::saveToLogFile(std::string &msg) if (chatLogger) chatLogger->log("#Guild", msg); } + +void GuildChatTab::playNewMessageSound() +{ + sound.playGuiSound(SOUND_GUILD); +} diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h index be6f4d034..e729844f4 100644 --- a/src/gui/widgets/guildchattab.h +++ b/src/gui/widgets/guildchattab.h @@ -44,6 +44,8 @@ class GuildChatTab : public ChatTab int getType() const { return ChatTab::TAB_GUILD; } + void playNewMessageSound(); + protected: void handleInput(const std::string &msg); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index de1304240..f88423f8e 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -4148,7 +4148,7 @@ void LocalPlayer::checkNewName(Being *being) if (!mWaitFor.empty() && mWaitFor == nick) { debugMsg(_("You see ") + mWaitFor); - sound.playGuiSound("soundinfo"); + sound.playGuiSound(SOUND_INFO); mWaitFor = ""; } } diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 87fc34d94..bd1521b21 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -26,6 +26,7 @@ #include "commandhandler.h" #include "guild.h" #include "localplayer.h" +#include "sound.h" #include "gui/theme.h" @@ -151,4 +152,9 @@ void GuildTab::saveToLogFile(std::string &msg) chatLogger->log("#Guild", msg); } +void GuildTab::playNewMessageSound() +{ + sound.playGuiSound(SOUND_GUILD); +} + } // namespace Ea diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 81d971161..22a41ce80 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -47,6 +47,8 @@ class GuildTab : public ChatTab int getType() const { return ChatTab::TAB_GUILD; } + void playNewMessageSound(); + protected: void handleInput(const std::string &msg); diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index d5e344ac2..e69207842 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -26,6 +26,7 @@ #include "commandhandler.h" #include "localplayer.h" #include "party.h" +#include "sound.h" #include "gui/theme.h" @@ -241,4 +242,8 @@ void PartyTab::saveToLogFile(std::string &msg) chatLogger->log("#Party", msg); } +void PartyTab::playNewMessageSound() +{ + sound.playGuiSound(SOUND_GUILD); +} } // namespace Ea diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index 029d71ac7..931b283dd 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -47,6 +47,8 @@ class PartyTab : public ChatTab void saveToLogFile(std::string &msg); + void playNewMessageSound(); + protected: void handleInput(const std::string &msg); diff --git a/src/sound.h b/src/sound.h index cfa847a0b..a967d0a92 100644 --- a/src/sound.h +++ b/src/sound.h @@ -31,6 +31,15 @@ class Music; +const static std::string SOUND_INFO = "soundinfo"; +const static std::string SOUND_ERROR = "sounderror"; +const static std::string SOUND_REQUEST = "soundrequest"; +const static std::string SOUND_TRADE = "soundtrade"; +const static std::string SOUND_WHISPER = "soundwhisper"; +const static std::string SOUND_HIGHLIGHT = "soundhighlight"; +const static std::string SOUND_GLOBAL = "soundglobal"; +const static std::string SOUND_GUILD = "soundguild"; + /** Sound engine * * \ingroup CORE -- cgit v1.2.3-70-g09d2 From 16a5f224128acde7343c53c636ff53e7983ef754 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 22:33:42 +0300 Subject: Adjust label size in setupitem controls. --- src/gui/setup_visual.cpp | 2 ++ src/gui/widgets/setupitem.cpp | 12 ++++++++++++ src/gui/widgets/setupitem.h | 2 ++ src/gui/widgets/setuptabscroll.cpp | 7 ++----- src/gui/widgets/setuptabscroll.h | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index f7a083498..55e219bd7 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -39,6 +39,8 @@ Setup_Visual::Setup_Visual() ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); + mPreferredFirstItemSize = 150; + new SetupItemCheckBox(_("Show pickup notifications in chat"), "", "showpickupchat", this, "showpickupchatEvent"); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index b3a018813..93854e823 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -171,6 +171,12 @@ void SetupItem::externalUpdated(std::string eventName A_UNUSED) toWidget(); } +void SetupItem::fixFirstItemSize(gcn::Widget *widget) +{ + if (widget->getWidth() < mParent->getPreferredFirstItemSize()) + widget->setWidth(mParent->getPreferredFirstItemSize()); +} + SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, @@ -279,6 +285,7 @@ void SetupItemTextField::createControls() mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent); mWidget = mTextField; mTextField->setWidth(200); + fixFirstItemSize(mLabel); mHorizont->add(mLabel); mHorizont->add(mTextField); mHorizont->add(mButton); @@ -402,6 +409,7 @@ void SetupItemIntTextField::createControls() mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent); mWidget = mTextField; mTextField->setWidth(50); + fixFirstItemSize(mLabel); mHorizont->add(mLabel); mHorizont->add(mTextField); mHorizont->add(mButton); @@ -572,6 +580,7 @@ void SetupItemDropDown::createControls() mWidget = mDropDown; // mTextField->setWidth(50); + fixFirstItemSize(mLabel); mHorizont->add(mLabel); mHorizont->add(mDropDown); @@ -656,6 +665,7 @@ void SetupItemSlider::createControls() mWidget = mSlider; mSlider->setWidth(mWidth); mSlider->setHeight(40); + fixFirstItemSize(mLabel); mHorizont->add(mLabel); mHorizont->add(mSlider, -10); @@ -767,6 +777,7 @@ void SetupItemSlider2::createControls() mWidget = mSlider; mSlider->setWidth(150); mSlider->setHeight(40); + fixFirstItemSize(mLabel); mHorizont->add(mLabel); mHorizont->add(mSlider, -10); mHorizont->add(mLabel2); @@ -917,6 +928,7 @@ void SetupItemSliderList::createControls() mSlider->adjustSize(); mWidget = mSlider; + fixFirstItemSize(mLabel); mHorizont->add(mLabel, 5); mHorizont->add(mSlider); diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 38dec929e..86fdf95f9 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -97,6 +97,8 @@ class SetupItem : public gcn::ActionListener bool isMainConfig() const { return mMainConfig; } + void fixFirstItemSize(gcn::Widget *widget); + protected: std::string mText; diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 34cc993a9..f3f8b1526 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -28,17 +28,14 @@ #include "debug.h" SetupTabScroll::SetupTabScroll() : - SetupTab() + SetupTab(), + mPreferredFirstItemSize(200) { mContainer = new VertContainer(25, false, 8); mScroll = new ScrollArea(mContainer); mScroll->setOpaque(false); mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); - -// LayoutHelper h(this); -// ContainerPlacer place = h.getPlacer(0, 0); -// place(0, 0, mScroll, 10, 10); } SetupTabScroll::~SetupTabScroll() diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h index d471ecfbc..e7151769e 100644 --- a/src/gui/widgets/setuptabscroll.h +++ b/src/gui/widgets/setuptabscroll.h @@ -55,11 +55,15 @@ class SetupTabScroll : public SetupTab virtual void action(const gcn::ActionEvent &event A_UNUSED) { } + int getPreferredFirstItemSize() + { return mPreferredFirstItemSize; } + protected: VertContainer *mContainer; ScrollArea *mScroll; std::map mItems; std::set mAllItems; + int mPreferredFirstItemSize; }; #endif -- cgit v1.2.3-70-g09d2 From f540d735b639386b2753f5c2aede844b8dad5df8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 23:52:44 +0300 Subject: Fix code style. --- src/gui/widgets/button.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index b430dfebb..c99f46149 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -229,7 +229,7 @@ Button::~Button() if (mImages) { for (int f = 0; f < BUTTON_COUNT; f ++) - mImages[f] = 0; + mImages[f] = nullptr; delete [] mImages; mImages = nullptr; } @@ -366,7 +366,6 @@ void Button::draw(gcn::Graphics *graphics) case gcn::Graphics::CENTER: if (mImages) { - textX = getWidth() / 2; int width = getFont()->getWidth(mCaption) + mImageWidth + 2; imageX = getWidth() / 2 - width / 2; textX = imageX + mImageWidth + 2; -- cgit v1.2.3-70-g09d2 From e60a9be8c43b2cf0352053366b64f788fdf17318 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 03:50:47 +0300 Subject: Fix drawing big minimaps. --- src/gui/minimap.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 74da37341..5a1e66c25 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -229,13 +229,11 @@ void Minimap::draw(gcn::Graphics *graphics) mMapImage->mBounds.h > a.height) { const Vector &p = player_node->getPosition(); - mMapOriginX = ((a.width) / 2) - static_cast((p.x - + viewport->getCameraRelativeX()) * static_cast( - mWidthProportion)) / 32; + mMapOriginX = ((a.width) / 2) - (static_cast(p.x + + viewport->getCameraRelativeX()) * mWidthProportion) / 32; - mMapOriginY = ((a.height) / 2) - static_cast((p.y - + viewport->getCameraRelativeX()) * static_cast( - mHeightProportion)) / 32; + mMapOriginY = ((a.height) / 2) - (static_cast(p.y + + viewport->getCameraRelativeX()) * mHeightProportion) / 32; const int minOriginX = a.width - mMapImage->mBounds.w; const int minOriginY = a.height - mMapImage->mBounds.h; @@ -314,9 +312,9 @@ void Minimap::draw(gcn::Graphics *graphics) const Vector &pos = being->getPosition(); graphics->fillRectangle(gcn::Rectangle( - static_cast(pos.x * mWidthProportion) / 32 + static_cast(pos.x * mWidthProportion) / 32 + mMapOriginX - offsetWidth, - static_cast(pos.y * mHeightProportion) / 32 + static_cast(pos.y * mHeightProportion) / 32 + mMapOriginY - offsetHeight, dotSize, dotSize)); } @@ -367,10 +365,10 @@ void Minimap::draw(gcn::Graphics *graphics) const Vector &pos = player_node->getPosition(); // logger->log("width:" + toString(graph->getWidth())); - int x = static_cast((pos.x - (graph->getWidth() / 2) + int x = static_cast((pos.x - (graph->getWidth() / 2) + viewport->getCameraRelativeX()) * mWidthProportion) / 32 + mMapOriginX; - int y = static_cast((pos.y - (graph->getHeight() / 2) + int y = static_cast((pos.y - (graph->getHeight() / 2) + viewport->getCameraRelativeY()) * mHeightProportion) / 32 + mMapOriginY; -- cgit v1.2.3-70-g09d2 From ea92940149eb3f4e2590cfbd07f240000acbd460 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 03:55:12 +0300 Subject: Allow resize minimaps. --- src/gui/minimap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 5a1e66c25..b4747b7c0 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -60,7 +60,7 @@ Minimap::Minimap(): setDefaultSize(5, 25, 100, 100); // set this to false as the minimap window size is changed //depending on the map size - setResizable(false); + setResizable(true); setupWindow->registerWindowForReset(this); setDefaultVisible(true); -- cgit v1.2.3-70-g09d2 From 8e6dd0db3a9e1bfb15068098029c25c334ca8f67 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 04:27:38 +0300 Subject: Allow use context menu in minimap. --- src/gui/minimap.cpp | 26 +++++++++++++++++++------- src/gui/minimap.h | 2 ++ src/gui/popupmenu.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/gui/popupmenu.h | 2 ++ src/gui/viewport.cpp | 5 +++++ src/gui/viewport.h | 2 ++ 6 files changed, 67 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index b4747b7c0..b76e71069 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -401,17 +401,29 @@ void Minimap::mouseReleased(gcn::MouseEvent &event) { gcn::Window::mouseReleased(event); - if (!player_node) + if (!player_node || !viewport) return; if (event.getButton() == gcn::MouseEvent::LEFT) { - const gcn::Rectangle a = getChildrenArea(); - const int x = event.getX() - a.x; - const int y = event.getY() - a.y; + int x = event.getX(); + int y = event.getY(); + screenToMap(x, y); - player_node->navigateTo((x - mMapOriginX + mWidthProportion) - / mWidthProportion, (y - mMapOriginY + mHeightProportion) - / mHeightProportion); + player_node->navigateTo(x, y); } + else if (event.getButton() == gcn::MouseEvent::RIGHT) + { + int x = event.getX(); + int y = event.getY(); + screenToMap(x, y); + viewport->showMapPopup(x, y); + } +} + +void Minimap::screenToMap(int &x, int &y) +{ + const gcn::Rectangle a = getChildrenArea(); + x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion; + y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion; } diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 8b7da5849..12835edd5 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -60,6 +60,8 @@ class Minimap : public Window void mouseReleased(gcn::MouseEvent &event); + void screenToMap(int &x, int &y); + private: Image *mMapImage; float mWidthProportion; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 933d2c7cd..5e5f310dc 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -579,6 +579,25 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem) showPopup(x, y); } +void PopupMenu::showMapPopup(int x, int y, int x2, int y2) +{ + mX = x2; + mY = y2; + + mBrowserBox->clearRows(); + + mBrowserBox->addRow(_("Map Item")); + + if (player_node && player_node->isGM()) + mBrowserBox->addRow("warp map", _("Warp")); + mBrowserBox->addRow("move", _("Move")); + mBrowserBox->addRow("movecamera", _("Move camera")); + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow("cancel", _("Cancel")); + + showPopup(x, y); +} + void PopupMenu::showOutfitsPopup(int x, int y) { mX = x; @@ -1161,6 +1180,16 @@ void PopupMenu::handleLink(const std::string &link, } } } + else if (link == "move" && (mX || mY)) + { + if (player_node) + player_node->navigateTo(mX, mY); + } + else if (link == "movecamera" && (mX || mY)) + { + if (viewport) + viewport->moveCameraToPosition(mX * 32, mY * 32); + } else if (link == "split" && mItem) { ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, @@ -1304,6 +1333,14 @@ void PopupMenu::handleLink(const std::string &link, mMapItem->getX(), mMapItem->getY()); } } + else if (link == "warp map" && (mX || mY)) + { + if (Game::instance()) + { + Net::getAdminHandler()->warp(Game::instance()->getCurrentMapName(), + mX, mY); + } + } else if (link == "remove map" && mMapItem) { if (viewport) diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 8b9107300..f616e46ee 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -142,6 +142,8 @@ class PopupMenu : public Popup, public LinkHandler void showUndressPopup(int x, int y, Being *being, Item *item); + void showMapPopup(int x, int y, int x2, int y2); + /** * Shows the related popup menu when right click on the chat * at the specified mouse coordinates. diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 0c0f0d3d9..17f40121e 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -706,6 +706,11 @@ void Viewport::showUndressPopup(int x, int y, Being *being, Item *item) mPopupMenu->showUndressPopup(x, y, being, item); } +void Viewport::showMapPopup(int x, int y) +{ + mPopupMenu->showMapPopup(getMouseX(), getMouseY(), x, y); +} + void Viewport::closePopupMenu() { if (mPopupMenu) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index ccb8124ba..ae6ff3d49 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -173,6 +173,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void showUndressPopup(int x, int y, Being *being, Item *item); + void showMapPopup(int x, int y); + /** * Closes the popup menu. Needed for when the player dies or switching * maps. -- cgit v1.2.3-70-g09d2 From e70d551884c0e11408176086a25d359987090003 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 04:53:49 +0300 Subject: Allow open conext menu from free tile if in free camera mode. Menu is same as in minimap. --- src/gui/viewport.cpp | 9 +++++++-- src/net/ea/playerhandler.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 17f40121e..1ef7b1cba 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -413,7 +413,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event) return; // Check if we are alive and kickin' -// if (!mMap || !player_node || !player_node->isAlive()) if (!mMap || !player_node) return; @@ -422,7 +421,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (Being::isTalking()) return; - const int pixelX = event.getX() + static_cast(mPixelViewX); const int pixelY = event.getY() + static_cast(mPixelViewY); @@ -461,6 +459,13 @@ void Viewport::mousePressed(gcn::MouseEvent &event) mPopupMenu->showPopup(event.getX(), event.getY(), mHoverSign); return; } + else if (mCameraMode) + { + mPopupMenu->showMapPopup(event.getX(), event.getY(), + (getMouseX() + getCameraX()) / mMap->getTileWidth(), + (getMouseY() + getCameraY()) / mMap->getTileHeight()); + return; + } } // If a popup is active, just remove it diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index ddcf7d9c0..df28b4c1c 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -28,6 +28,7 @@ #include "playerinfo.h" #include "units.h" +#include "gui/ministatuswindow.h" #include "gui/okdialog.h" #include "gui/skilldialog.h" #include "gui/statuswindow.h" @@ -257,7 +258,12 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) static_cast(scrollOffsetY)); if (viewport) + { + viewport->returnCamera(); + if (miniStatusWindow) + miniStatusWindow->updateStatus(); viewport->scrollBy(scrollOffsetX, scrollOffsetY); + } } void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) -- cgit v1.2.3-70-g09d2 From 085abf777701c8bdb3091084fe851b125e787ae1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 18:57:34 +0300 Subject: Block special keys in npc menu selection. --- src/gui/npcdialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3e5b30a9c..362d9db9d 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -363,7 +363,8 @@ bool NpcDialog::isTextInputFocused() const bool NpcDialog::isInputFocused() const { - return mTextField->isFocused() || mIntField->isFocused(); + return mTextField->isFocused() || mIntField->isFocused() + || mItemList->isFocused(); } bool NpcDialog::isAnyInputFocused() -- cgit v1.2.3-70-g09d2 From 5b4160a49385bc6895681c5d103a4a5716829e4b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 20:45:54 +0300 Subject: Simplify remove listener calls. --- src/actorspritemanager.cpp | 6 +----- src/client.cpp | 6 +----- src/configuration.cpp | 16 ++++++++++++---- src/configuration.h | 2 ++ src/gui/viewport.cpp | 6 +----- src/gui/whoisonline.cpp | 3 +-- src/gui/widgets/avatarlistbox.cpp | 3 +-- src/localplayer.cpp | 11 +---------- src/map.cpp | 4 +--- src/sound.cpp | 6 +----- 10 files changed, 22 insertions(+), 41 deletions(-) (limited to 'src/gui') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 803a30e7e..758a452b1 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -203,11 +203,7 @@ ActorSpriteManager::ActorSpriteManager() : ActorSpriteManager::~ActorSpriteManager() { - config.removeListener("targetDeadPlayers", this); - config.removeListener("targetOnlyReachable", this); - config.removeListener("cyclePlayers", this); - config.removeListener("cycleMonsters", this); - config.removeListener("extMouseTargeting", this); + config.removeListeners(this); storeAttackList(); clear(); } diff --git a/src/client.cpp b/src/client.cpp index 0324bb8cc..95e49c6aa 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -707,11 +707,7 @@ void Client::gameClear() { if (logger) logger->log1("Quitting1"); - config.removeListener("fpslimit", this); - config.removeListener("guialpha", this); - config.removeListener("gamma", this); - config.removeListener("particleEmitterSkip", this); - config.removeListener("vsync", this); + config.removeListeners(this); SDL_RemoveTimer(mLogicCounterId); SDL_RemoveTimer(mSecondsCounterId); diff --git a/src/configuration.cpp b/src/configuration.cpp index 97540c385..624cf7865 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -617,14 +617,22 @@ void Configuration::write() xmlFreeTextWriter(writer); } -void Configuration::addListener( - const std::string &key, ConfigListener *listener) +void Configuration::addListener(const std::string &key, + ConfigListener *listener) { mListenerMap[key].push_front(listener); } -void Configuration::removeListener( - const std::string &key, ConfigListener *listener) +void Configuration::removeListener(const std::string &key, + ConfigListener *listener) { mListenerMap[key].remove(listener); } + +void Configuration::removeListeners(ConfigListener *listener) +{ + ListenerMapIterator it = mListenerMap.begin(); + ListenerMapIterator it_end = mListenerMap.end(); + for (; it != it_end; ++ it) + (it->second).remove(listener); +} diff --git a/src/configuration.h b/src/configuration.h index 122badfd5..2715ea59c 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -248,6 +248,8 @@ class Configuration : public ConfigurationObject */ void removeListener(const std::string &key, ConfigListener *listener); + void removeListeners(ConfigListener *listener); + void setValue(const std::string &key, const std::string &value); void setSilent(const std::string &key, const std::string &value); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1ef7b1cba..5c50836f6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -98,11 +98,7 @@ Viewport::Viewport(): Viewport::~Viewport() { - config.removeListener("ScrollLaziness", this); - config.removeListener("ScrollRadius", this); - config.removeListener("showBeingPopup", this); - config.removeListener("selfMouseHeal", this); - config.removeListener("enableLazyScrolling", this); + config.removeListeners(this); delete mPopupMenu; mPopupMenu = nullptr; diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index eba058bd7..734daa7a6 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -131,8 +131,7 @@ WhoIsOnline::WhoIsOnline(): WhoIsOnline::~WhoIsOnline() { - config.removeListener("updateOnlineList", this); - config.removeListener("groupFriends", this); + config.removeListeners(this); if (mThread && SDL_GetThreadID(mThread)) SDL_WaitThread(mThread, nullptr); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 822e71805..749837f7d 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -74,8 +74,7 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): AvatarListBox::~AvatarListBox() { - config.removeListener("showgender", this); - config.removeListener("showlevel", this); + config.removeListeners(this); instances--; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index f88423f8e..1acc6a938 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -205,17 +205,8 @@ LocalPlayer::~LocalPlayer() { logger->log1("LocalPlayer::~LocalPlayer"); - config.removeListener("showownname", this); - config.removeListener("targetDeadPlayers", this); + config.removeListeners(this); serverConfig.removeListener("enableBuggyServers", this); - config.removeListener("syncPlayerMove", this); - config.removeListener("drawPath", this); - config.removeListener("serverAttack", this); - config.removeListener("attackMoving", this); - config.removeListener("showJobExp", this); - config.removeListener("enableAdvert", this); - config.removeListener("tradebot", this); - config.removeListener("targetOnlyReachable", this); delete mAwayDialog; mAwayDialog = nullptr; diff --git a/src/map.cpp b/src/map.cpp index b8767e5e4..d983508b1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -177,9 +177,7 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): Map::~Map() { - config.removeListener("OverlayDetail", this); - config.removeListener("guialpha", this); - config.removeListener("beingopacity", this); + config.removeListeners(this); // delete metadata, layers, tilesets and overlays delete [] mMetaTiles; diff --git a/src/sound.cpp b/src/sound.cpp index 2c7ecb53d..5b7f1201d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -66,11 +66,7 @@ Sound::Sound(): Sound::~Sound() { - config.removeListener("playBattleSound", this); - config.removeListener("playGuiSound", this); - config.removeListener("playMusic", this); - config.removeListener("sfxVolume", this); - config.removeListener("musicVolume", this); + config.removeListeners(this); // Unlink the callback function. Mix_HookMusicFinished(nullptr); -- cgit v1.2.3-70-g09d2 From c53136fce2b1cca1bb9273255ad86f0aded747c2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 20:56:37 +0300 Subject: Fix code style in empty methods. --- src/actorspritelistener.h | 3 ++- src/commandhandler.h | 3 ++- src/configlistener.h | 3 ++- src/equipment.h | 5 ++++- src/gui/chatwindow.cpp | 3 ++- src/gui/editserverdialog.h | 3 ++- src/gui/sdlinput.h | 3 ++- src/gui/setup_relations.cpp | 6 ++++-- src/gui/textcommandeditor.cpp | 6 ++++-- src/gui/widgets/browserbox.h | 3 ++- src/gui/widgets/flowcontainer.h | 3 ++- src/gui/widgets/linkhandler.h | 3 ++- src/gui/widgets/tablemodel.h | 3 ++- src/gui/worldselectdialog.cpp | 3 ++- src/guichan/include/guichan/actionlistener.hpp | 7 ++++--- src/guichan/include/guichan/deathlistener.hpp | 7 ++++--- src/guichan/include/guichan/focushandler.hpp | 3 ++- src/guichan/include/guichan/focuslistener.hpp | 12 ++++++++---- src/guichan/include/guichan/graphics.hpp | 9 ++++++--- src/guichan/include/guichan/keylistener.hpp | 12 ++++++++---- src/guichan/include/guichan/listmodel.hpp | 3 ++- src/guichan/include/guichan/mouselistener.hpp | 6 ++++-- src/guichan/include/guichan/widget.hpp | 18 ++++++++++++------ src/guichan/include/guichan/widgetlistener.hpp | 19 ++++++++++++------- src/guichan/include/guichan/widgets/listbox.hpp | 3 ++- src/guichan/include/guichan/widgets/slider.hpp | 3 ++- src/logger.h | 6 ++++-- src/net/manaserv/gamehandler.h | 3 ++- src/particlecontainer.h | 3 ++- src/sprite.h | 3 ++- 30 files changed, 110 insertions(+), 57 deletions(-) (limited to 'src/gui') diff --git a/src/actorspritelistener.h b/src/actorspritelistener.h index 314825fc7..7fdb99dc4 100644 --- a/src/actorspritelistener.h +++ b/src/actorspritelistener.h @@ -30,7 +30,8 @@ class ActorSpriteListener /** * Destructor. */ - virtual ~ActorSpriteListener() {} + virtual ~ActorSpriteListener() + { } /** * Called when the ActorSprite has been destroyed. The listener will diff --git a/src/commandhandler.h b/src/commandhandler.h index cd25c234a..d399accf7 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -48,7 +48,8 @@ class CommandHandler /** * Destructor */ - ~CommandHandler() {} + ~CommandHandler() + { } /** * Parse and handle the given command. diff --git a/src/configlistener.h b/src/configlistener.h index e4bbbee53..28540c564 100644 --- a/src/configlistener.h +++ b/src/configlistener.h @@ -37,7 +37,8 @@ class ConfigListener /** * Destructor. */ - virtual ~ConfigListener() {} + virtual ~ConfigListener() + { } /** * Called when an option changed. The config listener will have to be diff --git a/src/equipment.h b/src/equipment.h index 50acd60d3..ed38d32ca 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -66,8 +66,11 @@ class Equipment { public: virtual Item *getEquipment(int index) const = 0; + virtual void clear() = 0; - virtual ~Backend() { } + + virtual ~Backend() + { } }; /** diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 69e4d703f..ac493b04e 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -133,7 +133,8 @@ const char *COLOR_NAME[14] = class ColorListModel : public gcn::ListModel { public: - virtual ~ColorListModel() { } + virtual ~ColorListModel() + { } virtual int getNumberOfElements() { diff --git a/src/gui/editserverdialog.h b/src/gui/editserverdialog.h index 6035b0e50..4ad6b8fcb 100644 --- a/src/gui/editserverdialog.h +++ b/src/gui/editserverdialog.h @@ -44,7 +44,8 @@ class TypeListModel; class TypeListModel : public gcn::ListModel { public: - TypeListModel() {} + TypeListModel() + { } /** * Used to get number of line in the list diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 17cb4ea8a..f68612793 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -147,7 +147,8 @@ public: * only use SDL and plan sticking with SDL you can safely ignore this * function as it in the SDL case does nothing. */ - virtual void _pollInput() { } + virtual void _pollInput() + { } // Inherited from Input diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index f3b664c9b..d9f7a362d 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -80,7 +80,8 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = class PlayerRelationListModel : public gcn::ListModel { public: - virtual ~PlayerRelationListModel() { } + virtual ~PlayerRelationListModel() + { } virtual int getNumberOfElements() { @@ -211,7 +212,8 @@ protected: class IgnoreChoicesListModel : public gcn::ListModel { public: - virtual ~IgnoreChoicesListModel() { } + virtual ~IgnoreChoicesListModel() + { } virtual int getNumberOfElements() { diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 7b9442318..3f98b4ea3 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -127,7 +127,8 @@ const char *MAGIC_SCHOOL_TEXT[6] = class TargetTypeModel : public gcn::ListModel { public: - virtual ~TargetTypeModel() { } + virtual ~TargetTypeModel() + { } virtual int getNumberOfElements() { @@ -146,7 +147,8 @@ public: class MagicSchoolModel : public gcn::ListModel { public: - virtual ~MagicSchoolModel() { } + virtual ~MagicSchoolModel() + { } virtual int getNumberOfElements() { diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index d82ebd758..b1582e077 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -104,7 +104,8 @@ class BrowserBox : public gcn::Widget, /** * Sets the maximum numbers of rows in the browser box. 0 = no limit. */ - void setMaxRow(unsigned max) {mMaxRows = max; }; + void setMaxRow(unsigned max) + { mMaxRows = max; }; /** * Disable links & user defined colors to be used in chat input. diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 677dd3661..e5eeebdcb 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -43,7 +43,8 @@ class FlowContainer : public Container, /** * Destructor. */ - ~FlowContainer() {} + ~FlowContainer() + { } /** * Invoked when a widget changes its size. This is used to determine diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index 366899ffc..703f593f2 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -34,7 +34,8 @@ class LinkHandler { public: - virtual ~LinkHandler() { } + virtual ~LinkHandler() + { } virtual void handleLink(const std::string &link, gcn::MouseEvent *event) = 0; diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index 40a350163..e931888e4 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -42,7 +42,8 @@ public: */ virtual void modelUpdated(bool completed) = 0; - virtual ~TableModelListener() {} + virtual ~TableModelListener() + { } }; /** diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 917605281..19e6b81f7 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -54,7 +54,8 @@ class WorldListModel : public gcn::ListModel { } - virtual ~WorldListModel() {} + virtual ~WorldListModel() + { } int getNumberOfElements() { diff --git a/src/guichan/include/guichan/actionlistener.hpp b/src/guichan/include/guichan/actionlistener.hpp index 28373f2df..5991486a7 100644 --- a/src/guichan/include/guichan/actionlistener.hpp +++ b/src/guichan/include/guichan/actionlistener.hpp @@ -67,7 +67,8 @@ namespace gcn /** * Destructor. */ - virtual ~ActionListener() { } + virtual ~ActionListener() + { } /** * Called when an action is recieved from a widget. It is used @@ -86,8 +87,8 @@ namespace gcn * You should not be able to make an instance of ActionListener, * therefore its constructor is protected. */ - ActionListener() { } - + ActionListener() + { } }; } diff --git a/src/guichan/include/guichan/deathlistener.hpp b/src/guichan/include/guichan/deathlistener.hpp index 5e983e02d..b2061e036 100644 --- a/src/guichan/include/guichan/deathlistener.hpp +++ b/src/guichan/include/guichan/deathlistener.hpp @@ -66,7 +66,8 @@ namespace gcn /** * Destructor. */ - virtual ~DeathListener() { } + virtual ~DeathListener() + { } /** * Called when a widget dies. It is used to be able to recieve @@ -83,8 +84,8 @@ namespace gcn * You should not be able to make an instance of DeathListener, * therefore its constructor is protected. */ - DeathListener() { } - + DeathListener() + { } }; } diff --git a/src/guichan/include/guichan/focushandler.hpp b/src/guichan/include/guichan/focushandler.hpp index 4caba6f7b..9fa7ddeb7 100644 --- a/src/guichan/include/guichan/focushandler.hpp +++ b/src/guichan/include/guichan/focushandler.hpp @@ -80,7 +80,8 @@ namespace gcn /** * Destructor. */ - virtual ~FocusHandler() { }; + virtual ~FocusHandler() + { }; /** * Requests focus for a widget. Focus will only be granted to a widget diff --git a/src/guichan/include/guichan/focuslistener.hpp b/src/guichan/include/guichan/focuslistener.hpp index 9ec53b860..3876e8518 100644 --- a/src/guichan/include/guichan/focuslistener.hpp +++ b/src/guichan/include/guichan/focuslistener.hpp @@ -72,21 +72,24 @@ namespace gcn /** * Destructor. */ - virtual ~FocusListener() { } + virtual ~FocusListener() + { } /** * Called when a widget gains focus. * * @param event Discribes the event. */ - virtual void focusGained(const Event& event A_UNUSED) { }; + virtual void focusGained(const Event& event A_UNUSED) + { }; /** * Called when a widget loses focus. * * @param event Discribes the event. */ - virtual void focusLost(const Event& event A_UNUSED) { }; + virtual void focusLost(const Event& event A_UNUSED) + { }; protected: /** @@ -95,7 +98,8 @@ namespace gcn * You should not be able to make an instance of FocusListener, * therefore its constructor is protected. */ - FocusListener() { } + FocusListener() + { } }; } diff --git a/src/guichan/include/guichan/graphics.hpp b/src/guichan/include/guichan/graphics.hpp index efefa3d73..d10c63ae1 100644 --- a/src/guichan/include/guichan/graphics.hpp +++ b/src/guichan/include/guichan/graphics.hpp @@ -113,7 +113,8 @@ namespace gcn /** * Destructor. */ - virtual ~Graphics() { } + virtual ~Graphics() + { } /** * Initializes drawing. Called by the Gui when Gui::draw() is called. @@ -126,7 +127,8 @@ namespace gcn * * @see _endDraw, Gui::draw */ - virtual void _beginDraw() { } + virtual void _beginDraw() + { } /** * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. @@ -137,7 +139,8 @@ namespace gcn * * @see _beginDraw, Gui::draw */ - virtual void _endDraw() { } + virtual void _endDraw() + { } /** * Pushes a clip area onto the stack. The x and y coordinates in the diff --git a/src/guichan/include/guichan/keylistener.hpp b/src/guichan/include/guichan/keylistener.hpp index a6d6f851d..9f90a1ffc 100644 --- a/src/guichan/include/guichan/keylistener.hpp +++ b/src/guichan/include/guichan/keylistener.hpp @@ -70,7 +70,8 @@ namespace gcn /** * Destructor. */ - virtual ~KeyListener() { } + virtual ~KeyListener() + { } /** * Called if a key is pressed when the widget has keyboard focus. @@ -79,14 +80,16 @@ namespace gcn * * @param keyEvent Discribes the event. */ - virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) { } + virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) + { } /** * Called if a key is released when the widget has keyboard focus. * * @param keyEvent Discribes the event. */ - virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) { } + virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) + { } protected: /** @@ -95,7 +98,8 @@ namespace gcn * You should not be able to make an instance of KeyListener, * therefore its constructor is protected. */ - KeyListener() { } + KeyListener() + { } }; } diff --git a/src/guichan/include/guichan/listmodel.hpp b/src/guichan/include/guichan/listmodel.hpp index 612a5d4bd..bf139afb1 100644 --- a/src/guichan/include/guichan/listmodel.hpp +++ b/src/guichan/include/guichan/listmodel.hpp @@ -65,7 +65,8 @@ namespace gcn /** * Destructor. */ - virtual ~ListModel() { } + virtual ~ListModel() + { } /** * Gets the number of elements in the list. diff --git a/src/guichan/include/guichan/mouselistener.hpp b/src/guichan/include/guichan/mouselistener.hpp index 2f12ecdac..b78f529e9 100644 --- a/src/guichan/include/guichan/mouselistener.hpp +++ b/src/guichan/include/guichan/mouselistener.hpp @@ -69,7 +69,8 @@ namespace gcn /** * Destructor. */ - virtual ~MouseListener() { } + virtual ~MouseListener() + { } /** * Called when the mouse has entered into the widget area. @@ -183,7 +184,8 @@ namespace gcn * You should not be able to make an instance of MouseListener, * therefore its constructor is protected. */ - MouseListener() { } + MouseListener() + { } }; } diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp index 69126e3df..b6146b791 100644 --- a/src/guichan/include/guichan/widget.hpp +++ b/src/guichan/include/guichan/widget.hpp @@ -173,7 +173,8 @@ namespace gcn * @see Gui::logic * @since 0.1.0 */ - virtual void logic() { } + virtual void logic() + { } /** * Gets the widget's parent container. @@ -686,7 +687,8 @@ namespace gcn * * @since 0.1.0 */ - virtual void fontChanged() { } + virtual void fontChanged() + { } /** * Checks if a widget exists or not, that is if it still exists @@ -895,7 +897,8 @@ namespace gcn * @see moveToBottom * @since 0.1.0 */ - virtual void moveToTop(Widget* widget A_UNUSED) { }; + virtual void moveToTop(Widget* widget A_UNUSED) + { }; /** * Moves a widget in this widget to the bottom of this widget. @@ -905,7 +908,8 @@ namespace gcn * @see moveToTop * @since 0.1.0 */ - virtual void moveToBottom(Widget* widget A_UNUSED) { }; + virtual void moveToBottom(Widget* widget A_UNUSED) + { }; /** * Focuses the next widget in the widget. @@ -913,7 +917,8 @@ namespace gcn * @see moveToBottom * @since 0.1.0 */ - virtual void focusNext() { }; + virtual void focusNext() + { }; /** * Focuses the previous widget in the widget. @@ -921,7 +926,8 @@ namespace gcn * @see moveToBottom * @since 0.1.0 */ - virtual void focusPrevious() { }; + virtual void focusPrevious() + { }; /** * Tries to show a specific part of a widget by moving it. Used if the diff --git a/src/guichan/include/guichan/widgetlistener.hpp b/src/guichan/include/guichan/widgetlistener.hpp index 0ede5b871..f0cb60fd3 100644 --- a/src/guichan/include/guichan/widgetlistener.hpp +++ b/src/guichan/include/guichan/widgetlistener.hpp @@ -74,7 +74,8 @@ namespace gcn /** * Destructor. */ - virtual ~WidgetListener() { } + virtual ~WidgetListener() + { } /** * Invoked when a widget changes its size. @@ -82,7 +83,8 @@ namespace gcn * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetResized(const Event& event A_UNUSED) { } + virtual void widgetResized(const Event& event A_UNUSED) + { } /** * Invoked when a widget is moved. @@ -90,7 +92,8 @@ namespace gcn * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetMoved(const Event& event A_UNUSED) { } + virtual void widgetMoved(const Event& event A_UNUSED) + { } /** * Invoked when a widget is hidden, i.e it's set to be @@ -99,7 +102,8 @@ namespace gcn * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetHidden(const Event& event A_UNUSED) { } + virtual void widgetHidden(const Event& event A_UNUSED) + { } /** * Invoked when a widget is shown, i.e it's set to be @@ -108,7 +112,8 @@ namespace gcn * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetShown(const Event& event A_UNUSED) { } + virtual void widgetShown(const Event& event A_UNUSED) + { } protected: /** @@ -117,8 +122,8 @@ namespace gcn * You should not be able to make an instance of WidgetListener, * therefore its constructor is protected. */ - WidgetListener() { } - + WidgetListener() + { } }; } diff --git a/src/guichan/include/guichan/widgets/listbox.hpp b/src/guichan/include/guichan/widgets/listbox.hpp index 1e73c2214..ce056acbd 100644 --- a/src/guichan/include/guichan/widgets/listbox.hpp +++ b/src/guichan/include/guichan/widgets/listbox.hpp @@ -89,7 +89,8 @@ namespace gcn /** * Destructor. */ - virtual ~ListBox() { } + virtual ~ListBox() + { } /** * Gets the selected item as an index in the list model. diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp index 77b0b8806..a22c36844 100644 --- a/src/guichan/include/guichan/widgets/slider.hpp +++ b/src/guichan/include/guichan/widgets/slider.hpp @@ -94,7 +94,8 @@ namespace gcn /** * Destructor. */ - virtual ~Slider() { } + virtual ~Slider() + { } /** * Sets the scale of the slider. diff --git a/src/logger.h b/src/logger.h index 3dc24420d..54b44cc0e 100644 --- a/src/logger.h +++ b/src/logger.h @@ -58,12 +58,14 @@ class Logger /** * Sets whether the log should be written to standard output. */ - void setLogToStandardOut(bool value) { mLogToStandardOut = value; } + void setLogToStandardOut(bool value) + { mLogToStandardOut = value; } /** * Enables logging to chat window */ - void setChatWindow(ChatWindow *window) { mChatWindow = window; } + void setChatWindow(ChatWindow *window) + { mChatWindow = window; } /** * Enters a message in the log. The message will be timestamped. diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index 83e636e0e..2019755ea 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -48,7 +48,8 @@ class GameHandler : public MessageHandler, public Net::GameHandler void quit(bool reconnectAccount); - void quit() { quit(false); } + void quit() + { quit(false); } void ping(int tick); diff --git a/src/particlecontainer.h b/src/particlecontainer.h index a8af163fd..4e402044b 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -57,7 +57,8 @@ public: /** * Kills and removes all particle effects (only in this container) */ - virtual void clearLocally() {} + virtual void clearLocally() + { } /** * Sets the positions of all elements diff --git a/src/sprite.h b/src/sprite.h index ffee97d49..ab2dcfc6a 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -32,7 +32,8 @@ class Image; class Sprite { public: - virtual ~Sprite() {} + virtual ~Sprite() + { } /** * Resets the sprite. -- cgit v1.2.3-70-g09d2 From b3f55809a8a56a5acf180371f05163091263cbda Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Feb 2012 22:44:19 +0300 Subject: Fix npc menu focus/defocus issue. --- src/game.cpp | 11 ++++++----- src/gui/npcdialog.cpp | 11 +++++++++++ src/gui/npcdialog.h | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/game.cpp b/src/game.cpp index ae8682972..a0c2a6151 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -803,12 +803,13 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) used = true; } } - if (dialog) + if (dialog && !dialog->isInputFocused()) { - if (keyboard.isActionActive(keyboard.KEY_MOVE_UP)) - dialog->move(1); - else if (keyboard.isActionActive(keyboard.KEY_MOVE_DOWN)) - dialog->move(-1); + if (keyboard.isActionActive(keyboard.KEY_MOVE_UP) + || keyboard.isActionActive(keyboard.KEY_MOVE_DOWN)) + { + dialog->refocus(); + } } } diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 362d9db9d..1aeb76ec2 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -342,9 +342,20 @@ void NpcDialog::parseListItems(const std::string &itemString) mItems.push_back(tmp); if (!mItems.empty()) + { mItemList->setSelected(0); + mItemList->requestFocus(); + } else + { mItemList->setSelected(-1); + } +} + +void NpcDialog::refocus() +{ + if (!mItems.empty()) + mItemList->requestFocus(); } void NpcDialog::textRequest(const std::string &defaultText) diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index d4288d5c9..7bd2ee76d 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -177,6 +177,8 @@ class NpcDialog : public Window, public gcn::ActionListener, void restoreCamera(); + void refocus(); + private: typedef std::list DialogList; static DialogList instances; -- cgit v1.2.3-70-g09d2 From 22736fba8a8dea5aa254e57db82c76d022718af0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 1 Mar 2012 01:40:49 +0300 Subject: Fix default npc dialog size. --- src/gui/npcdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 1aeb76ec2..dd9e79b46 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -78,7 +78,7 @@ NpcDialog::NpcDialog(int npcId) : setMinWidth(200); setMinHeight(150); - setDefaultSize(260, 200, ImageRect::CENTER); + setDefaultSize(400, 400, ImageRect::CENTER); mItemLinkHandler = new ItemLinkHandler; // Setup output text box -- cgit v1.2.3-70-g09d2 From f3a176b24ba76c23df7625e81639342385628066 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 1 Mar 2012 19:49:10 +0300 Subject: Replace client version in update news to latest manaplus version. Only for old servers. --- src/gui/updaterwindow.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index fe26d42eb..9bac5e311 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -298,9 +298,26 @@ void UpdaterWindow::loadNews() // Tokenize and add each line separately char *line = strtok(mMemoryBuffer, "\n"); + bool firstLine(true); while (line) { - mBrowserBox->addRow(line); + if (firstLine) + { + firstLine = false; + std::string str = line; + unsigned i = str.find("##9 Latest client version: ##6"); + if (!i) + { + line = strtok(nullptr, "\n"); + continue; + } + + mBrowserBox->addRow(str); + } + else + { + mBrowserBox->addRow(line); + } line = strtok(nullptr, "\n"); } @@ -332,6 +349,15 @@ void UpdaterWindow::loadPatch() if (line) { version = line; + if (serverVersion < 1) + { + line = strtok(nullptr, "\n"); + if (line) + { + mBrowserBox->addRow("##9 Latest client version: ##6ManaPlus " + + std::string(line), true); + } + } if (version > CHECK_VERSION) { mBrowserBox->addRow("", true); -- cgit v1.2.3-70-g09d2