summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
committerReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
commit490862919d79369112c75955a9c36ff8a081efd3 (patch)
tree6fe89466b9c53ba811f298174e6d787bbae71e09 /src
parentdff814619d63496acd3c4e8730b828b5d4d931fb (diff)
parentd873da3e8e57480016596f714845c1bc7e712e68 (diff)
downloadplus-490862919d79369112c75955a9c36ff8a081efd3.tar.gz
plus-490862919d79369112c75955a9c36ff8a081efd3.tar.bz2
plus-490862919d79369112c75955a9c36ff8a081efd3.tar.xz
plus-490862919d79369112c75955a9c36ff8a081efd3.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/Makefile.am6
-rw-r--r--src/actorspritelistener.h3
-rw-r--r--src/actorspritemanager.cpp6
-rw-r--r--src/animatedsprite.cpp7
-rw-r--r--src/being.cpp8
-rw-r--r--src/chatlogger.cpp3
-rw-r--r--src/chatlogger.h3
-rw-r--r--src/client.cpp72
-rw-r--r--src/client.h6
-rw-r--r--src/commandhandler.h3
-rw-r--r--src/configlistener.h3
-rw-r--r--src/configuration.cpp71
-rw-r--r--src/configuration.h2
-rw-r--r--src/defaults.cpp15
-rw-r--r--src/dropshortcut.cpp5
-rw-r--r--src/dropshortcut.h5
-rw-r--r--src/effectmanager.cpp1
-rw-r--r--src/effectmanager.h2
-rw-r--r--src/emoteshortcut.cpp1
-rw-r--r--src/emoteshortcut.h1
-rw-r--r--src/equipment.h5
-rw-r--r--src/game.cpp25
-rw-r--r--src/graphics.cpp25
-rw-r--r--src/gui/botcheckerwindow.cpp5
-rw-r--r--src/gui/botcheckerwindow.h5
-rw-r--r--src/gui/changeemaildialog.cpp3
-rw-r--r--src/gui/changepassworddialog.cpp3
-rw-r--r--src/gui/charcreatedialog.cpp14
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/gui/confirmdialog.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/editdialog.cpp5
-rw-r--r--src/gui/editdialog.h5
-rw-r--r--src/gui/editserverdialog.cpp5
-rw-r--r--src/gui/editserverdialog.h3
-rw-r--r--src/gui/emotepopup.cpp9
-rw-r--r--src/gui/equipmentwindow.cpp10
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/killstats.cpp5
-rw-r--r--src/gui/killstats.h5
-rw-r--r--src/gui/minimap.cpp46
-rw-r--r--src/gui/minimap.h2
-rw-r--r--src/gui/npcdialog.cpp16
-rw-r--r--src/gui/npcdialog.h2
-rw-r--r--src/gui/okdialog.cpp10
-rw-r--r--src/gui/okdialog.h11
-rw-r--r--src/gui/outfitwindow.cpp2
-rw-r--r--src/gui/popupmenu.cpp39
-rw-r--r--src/gui/popupmenu.h2
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/sdlinput.h4
-rw-r--r--src/gui/serverdialog.cpp25
-rw-r--r--src/gui/serverdialog.h4
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup_audio.cpp226
-rw-r--r--src/gui/setup_audio.h19
-rw-r--r--src/gui/setup_chat.cpp3
-rw-r--r--src/gui/setup_chat.h3
-rw-r--r--src/gui/setup_joystick.cpp33
-rw-r--r--src/gui/setup_keyboard.cpp2
-rw-r--r--src/gui/setup_keyboard.h3
-rw-r--r--src/gui/setup_other.cpp3
-rw-r--r--src/gui/setup_other.h3
-rw-r--r--src/gui/setup_perfomance.cpp3
-rw-r--r--src/gui/setup_perfomance.h3
-rw-r--r--src/gui/setup_players.cpp3
-rw-r--r--src/gui/setup_players.h3
-rw-r--r--src/gui/setup_relations.cpp8
-rw-r--r--src/gui/setup_theme.cpp40
-rw-r--r--src/gui/setup_theme.h5
-rw-r--r--src/gui/setup_video.cpp247
-rw-r--r--src/gui/setup_video.h30
-rw-r--r--src/gui/setup_visual.cpp112
-rw-r--r--src/gui/setup_visual.h50
-rw-r--r--src/gui/shopwindow.cpp2
-rw-r--r--src/gui/socialwindow.cpp6
-rw-r--r--src/gui/spellpopup.cpp7
-rw-r--r--src/gui/spellpopup.h5
-rw-r--r--src/gui/statuspopup.cpp5
-rw-r--r--src/gui/statuspopup.h5
-rw-r--r--src/gui/textcommandeditor.cpp11
-rw-r--r--src/gui/textcommandeditor.h5
-rw-r--r--src/gui/textpopup.cpp3
-rw-r--r--src/gui/textpopup.h3
-rw-r--r--src/gui/theme.cpp19
-rw-r--r--src/gui/theme.h2
-rw-r--r--src/gui/unregisterdialog.cpp3
-rw-r--r--src/gui/updaterwindow.cpp32
-rw-r--r--src/gui/viewport.cpp25
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/whoisonline.cpp15
-rw-r--r--src/gui/whoisonline.h5
-rw-r--r--src/gui/widgets/avatarlistbox.cpp3
-rw-r--r--src/gui/widgets/browserbox.cpp22
-rw-r--r--src/gui/widgets/browserbox.h3
-rw-r--r--src/gui/widgets/button.cpp190
-rw-r--r--src/gui/widgets/button.h31
-rw-r--r--src/gui/widgets/chattab.cpp21
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/gui/widgets/desktop.cpp1
-rw-r--r--src/gui/widgets/desktop.h1
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h5
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp1
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h1
-rw-r--r--src/gui/widgets/flowcontainer.h3
-rw-r--r--src/gui/widgets/guildchattab.cpp6
-rw-r--r--src/gui/widgets/guildchattab.h2
-rw-r--r--src/gui/widgets/guitable.cpp9
-rw-r--r--src/gui/widgets/horizontcontainer.cpp7
-rw-r--r--src/gui/widgets/horizontcontainer.h2
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/label.h1
-rw-r--r--src/gui/widgets/linkhandler.h3
-rw-r--r--src/gui/widgets/namesmodel.cpp51
-rw-r--r--src/gui/widgets/namesmodel.h51
-rw-r--r--src/gui/widgets/setupitem.cpp416
-rw-r--r--src/gui/widgets/setupitem.h149
-rw-r--r--src/gui/widgets/setuptabscroll.cpp9
-rw-r--r--src/gui/widgets/setuptabscroll.h4
-rw-r--r--src/gui/widgets/sliderlist.cpp216
-rw-r--r--src/gui/widgets/sliderlist.h83
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h5
-rw-r--r--src/gui/widgets/tablemodel.h3
-rw-r--r--src/gui/widgets/textbox.cpp4
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/worldselectdialog.cpp3
-rw-r--r--src/guichan/color.cpp18
-rw-r--r--src/guichan/defaultfont.cpp2
-rw-r--r--src/guichan/focushandler.cpp20
-rw-r--r--src/guichan/include/guichan/actionlistener.hpp7
-rw-r--r--src/guichan/include/guichan/deathlistener.hpp7
-rw-r--r--src/guichan/include/guichan/focushandler.hpp3
-rw-r--r--src/guichan/include/guichan/focuslistener.hpp12
-rw-r--r--src/guichan/include/guichan/graphics.hpp9
-rw-r--r--src/guichan/include/guichan/keylistener.hpp12
-rw-r--r--src/guichan/include/guichan/listmodel.hpp3
-rw-r--r--src/guichan/include/guichan/mouselistener.hpp6
-rw-r--r--src/guichan/include/guichan/sdl/sdlpixel.hpp26
-rw-r--r--src/guichan/include/guichan/widget.hpp18
-rw-r--r--src/guichan/include/guichan/widgetlistener.hpp19
-rw-r--r--src/guichan/include/guichan/widgets/listbox.hpp3
-rw-r--r--src/guichan/include/guichan/widgets/slider.hpp3
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp23
-rw-r--r--src/guichan/sdl/sdlimage.cpp8
-rw-r--r--src/guichan/widgets/scrollarea.cpp8
-rw-r--r--src/guichan/widgets/slider.cpp4
-rw-r--r--src/guichan/widgets/tabbedarea.cpp2
-rw-r--r--src/guichan/widgets/textbox.cpp31
-rw-r--r--src/guichan/widgets/window.cpp2
-rw-r--r--src/guildmanager.cpp6
-rw-r--r--src/keyboardconfig.cpp2
-rw-r--r--src/keyboardconfig.h2
-rw-r--r--src/localplayer.cpp33
-rw-r--r--src/logger.cpp31
-rw-r--r--src/logger.h13
-rw-r--r--src/main.h4
-rw-r--r--src/map.cpp4
-rw-r--r--src/net/beinghandler.h5
-rw-r--r--src/net/ea/charserverhandler.cpp4
-rw-r--r--src/net/ea/gamehandler.cpp2
-rw-r--r--src/net/ea/gui/guildtab.cpp6
-rw-r--r--src/net/ea/gui/guildtab.h2
-rw-r--r--src/net/ea/gui/partytab.cpp5
-rw-r--r--src/net/ea/gui/partytab.h2
-rw-r--r--src/net/ea/partyhandler.cpp1
-rw-r--r--src/net/ea/partyhandler.h1
-rw-r--r--src/net/ea/playerhandler.cpp13
-rw-r--r--src/net/manaserv/beinghandler.cpp3
-rw-r--r--src/net/manaserv/charhandler.cpp4
-rw-r--r--src/net/manaserv/gamehandler.h3
-rw-r--r--src/net/manaserv/network.cpp10
-rw-r--r--src/net/messagein.cpp2
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/partyhandler.cpp1
-rw-r--r--src/net/tmwa/partyhandler.h1
-rw-r--r--src/net/tmwa/playerhandler.cpp4
-rw-r--r--src/opengl1graphics.cpp6
-rw-r--r--src/opengl1graphics.h4
-rw-r--r--src/openglgraphics.cpp10
-rw-r--r--src/openglgraphics.h6
-rw-r--r--src/particlecontainer.h3
-rw-r--r--src/particleemitterprop.h1
-rw-r--r--src/resources/action.cpp13
-rw-r--r--src/resources/action.h6
-rw-r--r--src/resources/animation.cpp14
-rw-r--r--src/resources/animation.h8
-rw-r--r--src/resources/dye.cpp2
-rw-r--r--src/resources/emotedb.cpp1
-rw-r--r--src/resources/emotedb.h1
-rw-r--r--src/resources/image.cpp18
-rw-r--r--src/resources/specialdb.cpp1
-rw-r--r--src/resources/spritedef.cpp22
-rw-r--r--src/resources/spritedef.h7
-rw-r--r--src/sound.cpp16
-rw-r--r--src/sound.h11
-rw-r--r--src/spellmanager.cpp5
-rw-r--r--src/spellmanager.h5
-rw-r--r--src/spellshortcut.cpp5
-rw-r--r--src/spellshortcut.h5
-rw-r--r--src/sprite.h3
-rw-r--r--src/textcommand.cpp4
-rw-r--r--src/textcommand.h5
-rw-r--r--src/textmanager.cpp1
-rw-r--r--src/textmanager.h1
-rw-r--r--src/utils/checkutils.cpp2
-rw-r--r--src/utils/copynpaste.cpp12
-rw-r--r--src/utils/copynpaste.h1
-rw-r--r--src/utils/langs.cpp8
-rw-r--r--src/utils/mathutils.h7
-rw-r--r--src/utils/physfsrwops.cpp24
-rw-r--r--src/utils/process.cpp8
-rw-r--r--src/utils/stringutils.cpp22
-rw-r--r--src/utils/stringutils.h2
-rw-r--r--src/utils/translation/poparser.cpp2
-rw-r--r--src/winver.h20
219 files changed, 2556 insertions, 962 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3289aed66..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
@@ -197,6 +199,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
@@ -327,6 +331,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..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 \
@@ -200,6 +202,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 \
@@ -330,6 +334,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/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/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/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/being.cpp b/src/being.cpp
index e1cb9b0ae..664eecd1d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1380,8 +1380,10 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
{
- if (EmoteDB::getAnimation(emotionIndex))
+ if (EmoteDB::getAnimation(emotionIndex, true))
EmoteDB::getAnimation(emotionIndex)->draw(graphics, px, py);
+ else
+ mEmotion = 0;
}
}
@@ -2320,7 +2322,7 @@ void Being::recalcSpritesOrder()
int val = slotRemap.at(slot);
int id = 0;
- if ((int)mSpriteIDs.size() > val)
+ if (static_cast<int>(mSpriteIDs.size()) > val)
id = mSpriteIDs[val];
int idx = -1;
@@ -2525,7 +2527,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 +2549,7 @@ void Being::setEmote(Uint8 emotion, int emote_time)
if ((emotion & FLAG_SPECIAL) == FLAG_SPECIAL)
{
setState(emotion);
+ mAdvanced = true;
}
else
{
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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#ifndef M_CHATLOGGER_H
diff --git a/src/client.cpp b/src/client.cpp
index fa8f032fa..95e49c6aa 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -276,7 +276,6 @@ Client::Client(const Options &options):
void Client::testsInit()
{
- printf ("testInit\n");
if (!mOptions.test.empty())
{
gameInit();
@@ -342,6 +341,10 @@ void Client::gameInit()
textdomain("manaplus");
#endif
+#if defined(WIN32) || defined(__APPLE__)
+ putenv("SDL_VIDEO_CENTERED=1");
+#endif
+
chatLogger = new ChatLogger;
if (mOptions.chatLogDir == "")
chatLogger->setBaseLogDir(mLocalDataDir + std::string("/logs/"));
@@ -360,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);
@@ -552,13 +555,17 @@ 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()));
}
}
}
+ applyGrabMode();
+ applyGamma();
+ applyVSync();
+
// Initialize for drawing
mainGraphics->_beginDraw();
@@ -660,6 +667,9 @@ void Client::gameInit()
setFramerate(fpsLimit);
config.addListener("fpslimit", this);
config.addListener("guialpha", this);
+ config.addListener("gamma", this);
+ config.addListener("particleEmitterSkip", this);
+ config.addListener("vsync", this);
setGuiAlpha(config.getFloatValue("guialpha"));
optionChanged("fpslimit");
@@ -697,8 +707,7 @@ void Client::gameClear()
{
if (logger)
logger->log1("Quitting1");
- config.removeListener("fpslimit", this);
- config.removeListener("guialpha", this);
+ config.removeListeners(this);
SDL_RemoveTimer(mLogicCounterId);
SDL_RemoveTimer(mSecondsCounterId);
@@ -866,7 +875,7 @@ int Client::gameExec()
Net::getGeneralHandler()->flushNetwork();
int k = 0;
- while (lastTickTime != tick_time && k < 2)
+ while (lastTickTime != tick_time && k < 40)
{
if (gui)
gui->logic();
@@ -1094,6 +1103,7 @@ int Client::gameExec()
case STATE_WORLD_SELECT:
logger->log1("State: WORLD SELECT");
{
+ TranslationManager::loadCurrentLang();
Worlds worlds = Net::getLoginHandler()->getWorlds();
if (worlds.empty())
@@ -1193,6 +1203,8 @@ int Client::gameExec()
if (!BeingInfo::unknown)
BeingInfo::unknown = new BeingInfo;
+ TranslationManager::loadCurrentLang();
+
Event evt2(EVENT_STATECHANGE);
evt2.setInt("newState", STATE_LOAD_DATA);
evt2.setInt("oldState", mOldState);
@@ -1311,14 +1323,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;
@@ -1354,7 +1368,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;
@@ -1374,7 +1388,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;
@@ -1395,7 +1409,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);
@@ -1452,7 +1466,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();
@@ -1484,6 +1499,19 @@ 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;
+ }
+ else if (name == "vsync")
+ {
+ applyVSync();
}
}
@@ -1665,6 +1693,7 @@ void Client::initServerConfig(std::string serverName)
{
fclose(configFile);
serverConfig.init(configPath);
+ serverConfig.setDefaultValues(getConfigDefaults());
logger->log("serverConfigPath: " + configPath);
}
initPacketLimiter();
@@ -2423,3 +2452,22 @@ 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);
+}
+
+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 6c93adbdf..54de27824 100644
--- a/src/client.h
+++ b/src/client.h
@@ -273,6 +273,12 @@ public:
static bool isTmw();
+ static void applyGrabMode();
+
+ void applyGamma();
+
+ void applyVSync();
+
void optionChanged(const std::string &name);
void action(const gcn::ActionEvent &event);
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/configuration.cpp b/src/configuration.cpp
index c4f1cc360..624cf7865 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -217,6 +217,11 @@ int Configuration::getIntValue(const std::string &key) const
defaultValue = 0;
}
}
+ else if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ defaultValue = static_cast<int>(
+ (static_cast<FloatData*>(itdef->second))->getData());
+ }
}
else
{
@@ -321,11 +326,38 @@ float Configuration::getFloatValue(const std::string &key) const
{
DefaultsData::const_iterator itdef = mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second
- && itdef->second->getType() == VariableData::DATA_FLOAT)
+ if (itdef != mDefaultsData->end() && itdef->second)
{
- defaultValue = static_cast<float>(
- (static_cast<FloatData*>(itdef->second))->getData());
+ if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ defaultValue = static_cast<float>(
+ (static_cast<FloatData*>(itdef->second))->getData());
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_STRING)
+ {
+ defaultValue = atof((static_cast<StringData*>(
+ itdef->second))->getData().c_str());
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_BOOL)
+ {
+ if ((static_cast<BoolData*>(
+ itdef->second))->getData())
+ {
+ defaultValue = 1;
+ }
+ else
+ {
+ defaultValue = 0;
+ }
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_INT)
+ {
+ defaultValue = (static_cast<IntData*>(
+ itdef->second))->getData();
+ }
}
else
{
@@ -385,6 +417,18 @@ bool Configuration::getBoolValue(const std::string &key) const
defaultValue = false;
}
}
+ if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ if (static_cast<int>((static_cast<FloatData*>(
+ itdef->second))->getData()) != 0)
+ {
+ defaultValue = true;
+ }
+ else
+ {
+ defaultValue = false;
+ }
+ }
}
else
{
@@ -528,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);
}
@@ -572,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/defaults.cpp b/src/defaults.cpp
index a439701a3..87771c427 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -226,6 +226,18 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "enableresize", true);
AddDEF(configData, "noframe", false);
AddDEF(configData, "groupFriends", true);
+ AddDEF(configData, "grabinput", false);
+ AddDEF(configData, "gamma", 1);
+ AddDEF(configData, "vsync", 0);
+ AddDEF(configData, "enableBuggyServers", true);
+ 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");
+ AddDEF(configData, "soundguild", "newmessage");
return configData;
}
@@ -243,6 +255,7 @@ DefaultsData* getBrandingDefaults()
AddDEF(brandingData, "defaultServerType", "tmwathena");
AddDEF(brandingData, "onlineServerList",
"http://manaplus.evolonline.org/serverlist.xml");
+ AddDEF(brandingData, "onlineServerFile", "serverlistplus.xml");
AddDEF(brandingData, "appShort", "mana");
AddDEF(brandingData, "defaultUpdateHost", "");
AddDEF(brandingData, "helpPath", "");
@@ -259,6 +272,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/dropshortcut.cpp b/src/dropshortcut.cpp
index 5b01f7f4f..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "dropshortcut.h"
diff --git a/src/dropshortcut.h b/src/dropshortcut.h
index 31c20677d..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef DROPSHORTCUT_H
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 <fate.tmw@googlemail.com>
* Copyright (C) 2008 Chuck Miller <shadowmil@gmail.com>
+ * 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 df19a0040..7b71069fe 100644
--- a/src/effectmanager.h
+++ b/src/effectmanager.h
@@ -2,6 +2,7 @@
* An effects manager
* Copyright (C) 2008 Fate <fate.tmw@googlemail.com>
* Copyright (C) 2008 Chuck Miller <shadowmil@gmail.com>
+ * Copyright (C) 2011-2012 The ManaPlus developers
*
* This file is part of The ManaPlus Client.
*
@@ -24,6 +25,7 @@
#include <list>
#include <string>
+#include <vector>
class Being;
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/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/game.cpp b/src/game.cpp
index 6adf62f12..70d794ce8 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();
}
@@ -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();
+ }
}
}
@@ -1316,7 +1317,8 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown)
if (player_node->isAlive() && (!Being::isTalking()
|| keyboard.getKeyIndex(event.key.keysym.sym)
== KeyboardConfig::KEY_TALK)
- && chatWindow && !chatWindow->isInputFocused() && !quitDialog)
+ && chatWindow && !chatWindow->isInputFocused()
+ && !InventoryWindow::isAnyInputFocused() && !quitDialog)
{
// Get the state of the keyboard keys
keyboard.refreshActiveKeys();
@@ -1420,7 +1422,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown)
Net::getPlayerHandler()->setDirection(direction);
}
}
- direction = 0;
+// direction = 0;
}
else
{
@@ -1695,7 +1697,7 @@ void Game::handleInput()
{
if (emoteShortcut)
emoteShortcut->useEmote(emotion);
- used = true;
+// used = true;
setValidSpeed();
return;
}
@@ -1796,8 +1798,9 @@ 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, false);
}
if (mCurrentMap)
diff --git a/src/graphics.cpp b/src/graphics.cpp
index e98b1a283..e6841fa5c 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();
@@ -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<Uint8 *>(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<Uint8 *>(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<Uint16 *>(p) = gcn::SDLAlpha16(
+ pixel, *reinterpret_cast<Uint32 *>(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<Uint8 *>(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<Uint8 *>(mTarget->pixels)
+ + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
Uint8 *p = p0 + x * 4;
- Uint32 dst = *(Uint32 *)p;
+ Uint32 dst = *reinterpret_cast<Uint32 *>(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<Uint32 *>(p) = ((b & 0xff)
+ | (g & 0xff00) | (r & 0xff0000));
}
}
break;
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 4a092ab55..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 ManaPlus developers
+ * Copyright (C) 2011-2012 The ManaPlus developers
*
* This file is part of The ManaPlus Client.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "botcheckerwindow.h"
diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h
index 86d5ef290..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 ManaPlus developers
+ * Copyright (C) 2011-2012 The ManaPlus developers
*
* This file is part of The ManaPlus Client.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef BOTCHECKER_H
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 8d4767a15..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")
@@ -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<signed>(minHairStyle)
+ || mHairStyle > static_cast<signed>(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<signed>(minHairColor)
+ || mHairColor > static_cast<signed>(maxHairColor))
+ {
mHairColor = minHairColor;
+ }
mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor));
mHairColorNameLabel->adjustSize();
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/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/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index 22acf5116..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.playGuiSfx("system/newmessage.ogg");
+ sound.playGuiSound(SOUND_REQUEST);
}
void ConfirmDialog::action(const gcn::ActionEvent &event)
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<int>(player_node->getPingTime())).c_str()));
}
else
{
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index 84f4f6ddf..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/editdialog.h"
diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h
index ef260acfb..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef EDIT_DIALOG_H
diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp
index 8a4a9579d..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
@@ -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<short>(atoi(
+ mPortField->getText().c_str()));
if (mTypeField)
{
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/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/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<signed>(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<signed>(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<unsigned>(getWidth()) < minWidth)
setWidth(minWidth);
}
}
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index 357a016f2..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/killstats.h"
diff --git a/src/gui/killstats.h b/src/gui/killstats.h
index 9773190de..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef KILLSTATS_H
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 74da37341..b76e71069 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);
@@ -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<int>((p.x
- + viewport->getCameraRelativeX()) * static_cast<int>(
- mWidthProportion)) / 32;
+ mMapOriginX = ((a.width) / 2) - (static_cast<float>(p.x
+ + viewport->getCameraRelativeX()) * mWidthProportion) / 32;
- mMapOriginY = ((a.height) / 2) - static_cast<int>((p.y
- + viewport->getCameraRelativeX()) * static_cast<int>(
- mHeightProportion)) / 32;
+ mMapOriginY = ((a.height) / 2) - (static_cast<float>(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<int>(pos.x * mWidthProportion) / 32
+ static_cast<float>(pos.x * mWidthProportion) / 32
+ mMapOriginX - offsetWidth,
- static_cast<int>(pos.y * mHeightProportion) / 32
+ static_cast<float>(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<int>((pos.x - (graph->getWidth() / 2)
+ int x = static_cast<float>((pos.x - (graph->getWidth() / 2)
+ viewport->getCameraRelativeX())
* mWidthProportion) / 32 + mMapOriginX;
- int y = static_cast<int>((pos.y - (graph->getHeight() / 2)
+ int y = static_cast<float>((pos.y - (graph->getHeight() / 2)
+ viewport->getCameraRelativeY())
* mHeightProportion) / 32 + mMapOriginY;
@@ -403,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/npcdialog.cpp b/src/gui/npcdialog.cpp
index 3e5b30a9c..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
@@ -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)
@@ -363,7 +374,8 @@ bool NpcDialog::isTextInputFocused() const
bool NpcDialog::isInputFocused() const
{
- return mTextField->isFocused() || mIntField->isFocused();
+ return mTextField->isFocused() || mIntField->isFocused()
+ || mItemList->isFocused();
}
bool NpcDialog::isAnyInputFocused()
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<NpcDialog*> DialogList;
static DialogList instances;
diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp
index 4a3bdf731..3259cb6d6 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(SOUND_INFO);
+ else if (soundEvent == DIALOG_ERROR)
+ sound.playGuiSound(SOUND_ERROR);
}
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/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<int>(mItemColors[o][i]));
if (i < OUTFIT_ITEM_COUNT - 1)
outfitColorsStr += " ";
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index c987843d3..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)
@@ -2205,7 +2242,7 @@ void PlayerListener::action(const gcn::ActionEvent &event)
{
std::string comment = mDialog->getText();
Being* being = actorSpriteManager->findBeingByName(
- mNick, (ActorSprite::Type)mType);
+ mNick, static_cast<ActorSprite::Type>(mType));
if (being)
being->setComment(comment);
Being::saveComment(mNick, comment, mType);
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/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/sdlinput.h b/src/gui/sdlinput.h
index b441380a4..f68612793 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
@@ -146,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/serverdialog.cpp b/src/gui/serverdialog.cpp
index ce61f6572..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<int>(mVersionStrings.size()))
return;
if (version.empty())
@@ -305,7 +305,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
loadServers(true);
- if (mServers.empty())
+ if (needUpdateServers())
downloadServerList();
}
@@ -484,13 +484,17 @@ void ServerDialog::downloadServerList()
}
mDownload = new Net::Download(this, listFile, &downloadUpdate);
- mDownload->setFile(mDir + "/serverlist.xml");
+ mDownload->setFile(mDir + "/" + branding.getStringValue(
+ "onlineServerFile"));
mDownload->start();
+
+ config.setValue("serverslistupdate", getDateString());
}
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"))
@@ -628,7 +632,7 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
// Make sure the current server is mentioned first
if (currentServer.isValid())
{
- if (index >= 0 && (unsigned)index < mServers.size())
+ if (index >= 0 && static_cast<unsigned>(index) < mServers.size())
{
mServers[index] = currentServer;
}
@@ -740,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 &currentServer = ServerInfo(),
int index = -1);
+ bool needUpdateServers();
+
static int downloadUpdate(void *ptr, DownloadStatus status,
size_t total, size_t remaining);
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_audio.cpp b/src/gui/setup_audio.cpp
index bc058faf9..69ca4e759 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -23,179 +23,125 @@
#include "gui/setup_audio.h"
#include "configuration.h"
-#include "logger.h"
#include "sound.h"
-#include "gui/okdialog.h"
+#include "gui/theme.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/namesmodel.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()))
+class SoundsModel : public NamesModel
+{
+public:
+ SoundsModel()
+ {
+ mNames.push_back(gettext("(no sound)"));
+ Theme::fillSoundsList(mNames);
+ }
+
+ virtual ~SoundsModel()
+ { }
+};
+
+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);
+
+ mSoundModel = new SoundsModel();
- mSfxSlider->setActionEventId("sfx");
- mMusicSlider->setActionEventId("music");
+ new SetupItemLabel(_("Basic settings"), "", this);
- mSfxSlider->addActionListener(this);
- mMusicSlider->addActionListener(this);
+ new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent");
- mAudioCheckBox->setPosition(10, 10);
+ new SetupItemCheckBox(_("Enable music"), "",
+ "playMusic", this, "playMusicEvent");
- mSfxSlider->setValue(mSfxVolume);
- mMusicSlider->setValue(mMusicVolume);
+ new SetupItemCheckBox(_("Enable game sfx"), "",
+ "playBattleSound", this, "playBattleSoundEvent");
- mSfxSlider->setWidth(90);
- mMusicSlider->setWidth(90);
+ new SetupItemCheckBox(_("Enable gui sfx"), "",
+ "playGuiSound", this, "playGuiSoundEvent");
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
+ new SetupItemSlider(_("Sfx volume"), "", "sfxVolume",
+ this, "sfxVolumeEvent", 0, sound.getMaxVolume(), 150, true);
+
+ 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(_("Guild / Party message sound"), "",
+ "soundguild", this, "soundguildEvent", 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");
- 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()
+Setup_Audio::~Setup_Audio()
{
- 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);
+ delete mSoundModel;
+ mSoundModel = nullptr;
+}
- if (mAudioEnabled)
+void Setup_Audio::apply()
+{
+ SetupTabScroll::apply();
+ if (config.getBoolValue("sound"))
{
- try
- {
- sound.init();
- }
- catch (const char *err)
+ sound.init();
+ if (viewport && config.getBoolValue("playMusic"))
{
- new OkDialog(_("Sound Engine"), err);
- logger->log("Warning: %s", err);
+ Map *map = viewport->getMap();
+ if (map)
+ sound.playMusic(map->getMusicFile());
}
- 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<int>(mSfxSlider->getValue()));
- sound.setSfxVolume(static_cast<int>(mSfxSlider->getValue()));
- }
- else if (event.getId() == "music")
- {
- config.setValueInt("musicVolume",
- static_cast<int>(mMusicSlider->getValue()));
- sound.setMusicVolume(static_cast<int>(mMusicSlider->getValue()));
- }
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 88869d730..21b661bcb 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -25,30 +25,21 @@
#include "guichanfwd.h"
-#include "gui/widgets/setuptab.h"
+#include "gui/widgets/setuptabscroll.h"
#include <guichan/actionlistener.hpp>
-class Setup_Audio : public SetupTab
+class Setup_Audio : public SetupTabScroll
{
public:
Setup_Audio();
- void apply();
- void cancel();
+ ~Setup_Audio();
- void action(const gcn::ActionEvent &event);
+ void apply();
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;
+ gcn::ListModel *mSoundModel;
};
#endif
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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#ifndef GUI_SETUP_CHAT_H
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 290607be4..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<int>(mNames.size());
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return _("???");
-
- return mNames[i];
- }
-
- std::vector<std::string> 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);
}
@@ -146,7 +121,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/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_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 <joshlangley@optusnet.com.au>
+ * 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_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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#ifndef GUI_SETUP_PLAYERS_H
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
index 47d53620c..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()
{
@@ -194,7 +195,7 @@ public:
std::string getPlayerAt(int index) const
{
- if (index < 0 || index >= (signed)mPlayers->size())
+ if (index < 0 || index >= static_cast<signed>(mPlayers->size()))
return "";
return (*mPlayers)[index];
}
@@ -211,7 +212,8 @@ protected:
class IgnoreChoicesListModel : public gcn::ListModel
{
public:
- virtual ~IgnoreChoicesListModel() { }
+ virtual ~IgnoreChoicesListModel()
+ { }
virtual int getNumberOfElements()
{
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 67936f698..7386f496a 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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/setup_theme.h"
@@ -30,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"
@@ -54,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<int>(mNames.size());
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return _("???");
-
- return mNames[i];
- }
-
-protected:
- std::vector<std::string> mNames;
-};
-
class ThemesModel : public NamesModel
{
public:
@@ -375,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_theme.h b/src/gui/setup_theme.h
index 1ff159195..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef GUI_Setup_Theme_H
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 6b3d6d4d3..24d42c83d 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"
@@ -40,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"
@@ -214,106 +214,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");
- }
- return "";
-}
-
-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")),
- mPickupChatEnabled(config.getBoolValue("showpickupchat")),
- mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
- mOpacity(config.getFloatValue("guialpha")),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
mEnableResize(config.getBoolValue("enableresize")),
mNoFrame(config.getBoolValue("noframe")),
- mSpeechMode(static_cast<Being::Speech>(
- 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)),
- 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)),
- mSpeechLabel(new Label("")),
- mAlphaSlider(new Slider(0.1, 1.0)),
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"));
@@ -322,11 +242,6 @@ Setup_Video::Setup_Video():
scrollArea->setWidth(150);
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"));
-
mOpenGLListModel = new OpenGLListModel;
mOpenGLDropDown = new DropDown(mOpenGLListModel),
mOpenGLDropDown->setSelected(mOpenGLEnabled);
@@ -337,9 +252,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
@@ -358,57 +270,28 @@ 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");
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);
- mPickupChatCheckBox->addActionListener(this);
- mPickupParticleCheckBox->addActionListener(this);
- mAlphaSlider->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, 6, mHwAccelCheckBox, 6);
+ place(0, 0, scrollArea, 1, 5).setPadding(2);
+ place(0, 5, mOpenGLDropDown, 1);
place(1, 0, mFsCheckBox, 2);
@@ -417,33 +300,34 @@ 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);
+// 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, 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;
@@ -501,7 +385,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__)
@@ -509,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);
@@ -522,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() ?
@@ -541,15 +425,8 @@ 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<Being::Speech>(
- config.getIntValue("speech"));
- 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");
}
@@ -560,15 +437,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);
- mAlphaSlider->setValue(mOpacity);
- mOverlayDetailSlider->setValue(mOverlayDetail);
- mParticleDetailSlider->setValue(mParticleDetail);
mFpsLabel->setCaption(mFpsCheckBox->isSelected()
? toString(mFps) : _("None"));
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
@@ -585,13 +457,7 @@ void Setup_Video::cancel()
config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("particleeffects", mParticleEffectsEnabled);
- config.setValue("speech", static_cast<int>(mSpeechMode));
- 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);
}
@@ -632,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
@@ -654,57 +524,10 @@ 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());
}
- 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 == "pickupchat")
- {
- config.setValue("showpickupchat", mPickupChatCheckBox->isSelected());
- }
- else if (id == "pickupparticle")
- {
- config.setValue("showpickupparticle",
- mPickupParticleCheckBox->isSelected());
- }
- else if (id == "speech")
- {
- Being::Speech val = static_cast<Being::Speech>(
- mSpeechSlider->getValue());
- mSpeechLabel->setCaption(speechModeToString(val));
- mSpeechSlider->setValue(val);
- config.setValue("speech", static_cast<int>(val));
- }
- else if (id == "overlaydetailslider")
- {
- int val = static_cast<int>(mOverlayDetailSlider->getValue());
- mOverlayDetailField->setCaption(overlayDetailToString(val));
- config.setValue("OverlayDetail", val);
- }
- else if (id == "particledetailslider")
- {
- int val = static_cast<int>(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<int>(mFpsSlider->getValue());
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 31d45d93d..0e7bc0f21 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -46,68 +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;
- bool mPickupChatEnabled;
- bool mPickupParticleEnabled;
- float mOpacity;
int mFps;
int mAltFps;
bool mEnableResize;
bool mNoFrame;
- Being::Speech mSpeechMode;
ModeListModel *mModeListModel;
OpenGLListModel *mOpenGLListModel;
- gcn::Label *speechLabel;
- gcn::Label *alphaLabel;
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::Label *mPickupNotifyLabel;
- gcn::CheckBox *mPickupChatCheckBox;
- gcn::CheckBox *mPickupParticleCheckBox;
gcn::CheckBox *mEnableResizeCheckBox;
gcn::CheckBox *mNoFrameCheckBox;
- gcn::Slider *mSpeechSlider;
- gcn::Label *mSpeechLabel;
- gcn::Slider *mAlphaSlider;
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
new file mode 100644
index 000000000..55e219bd7
--- /dev/null
+++ b/src/gui/setup_visual.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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/widgets/layouthelper.h"
+#include "gui/widgets/scrollarea.h"
+
+#include "client.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);
+
+ mPreferredFirstItemSize = 150;
+
+ new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
+ "showpickupchat", this, "showpickupchatEvent");
+
+ new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
+ "", "showpickupparticle", this, "showpickupparticleEvent");
+
+ new SetupItemCheckBox(_("Grab mouse and keyboard input"),
+ "", "grabinput", this, "grabinputEvent");
+
+ new SetupItemSlider(_("Gui opacity"), "", "guialpha",
+ this, "guialphaEvent", 0.1, 1.0, 150, true);
+
+ 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, true))->setInvertValue(3);
+
+ 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));
+}
+
+Setup_Visual::~Setup_Visual()
+{
+ delete mSpeachList;
+ mSpeachList = nullptr;
+ delete mAmbientFxList;
+ mAmbientFxList = nullptr;
+ delete mParticleList;
+ mParticleList = nullptr;
+ delete mVSyncList;
+ mVSyncList = nullptr;
+}
+
+void Setup_Visual::apply()
+{
+ SetupTabScroll::apply();
+ Client::applyGrabMode();
+}
diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h
new file mode 100644
index 000000000..028f366b8
--- /dev/null
+++ b/src/gui/setup_visual.h
@@ -0,0 +1,50 @@
+/*
+ * 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/setupitem.h"
+#include "gui/widgets/setuptabscroll.h"
+
+class Setup_Visual : public SetupTabScroll
+{
+ public:
+ Setup_Visual();
+
+ ~Setup_Visual();
+
+ void apply();
+
+ private:
+ SetupItemNames *mSpeachList;
+
+ SetupItemNames *mAmbientFxList;
+
+ SetupItemNames *mParticleList;
+
+ SetupItemNames *mVSyncList;
+};
+
+#endif
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 1a27b8b0c..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.playGuiSfx("system/newmessage.ogg");
+ sound.playGuiSound(SOUND_TRADE);
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/spellpopup.cpp b/src/gui/spellpopup.cpp
index 66d69b197..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/spellpopup.h"
@@ -114,8 +113,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/spellpopup.h b/src/gui/spellpopup.h
index 883b2bfe0..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef SPELLPOPUP_H
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index 3e1f68d09..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/statuspopup.h"
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index 976b5e57b..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef StatusPopup_H
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 7d97549f3..3f98b4ea3 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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/textcommandeditor.h"
@@ -128,7 +127,8 @@ const char *MAGIC_SCHOOL_TEXT[6] =
class TargetTypeModel : public gcn::ListModel
{
public:
- virtual ~TargetTypeModel() { }
+ virtual ~TargetTypeModel()
+ { }
virtual int getNumberOfElements()
{
@@ -147,7 +147,8 @@ public:
class MagicSchoolModel : public gcn::ListModel
{
public:
- virtual ~MagicSchoolModel() { }
+ virtual ~MagicSchoolModel()
+ { }
virtual int getNumberOfElements()
{
diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h
index d0b2f0a54..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#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 <http://www.gnu.org/licenses/>.
*/
#ifndef TEXTPOPUP_H
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<std::string> &list)
PHYSFS_permitSymbolicLinks(0);
}
+void Theme::fillSoundsList(std::vector<std::string> &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<std::string> &list);
+ static void fillSoundsList(std::vector<std::string> &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/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/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 3aaf93557..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);
@@ -554,8 +580,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<int>(mUpdateFiles.size())
+ + static_cast<int>(mTempUpdateFiles.size()) + 1));
}
else
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 2e1e15c92..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;
@@ -199,7 +195,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<int>(mPixelViewX),
+ static_cast<int>(mPixelViewY));
if (player_node)
{
logger->log("tile position: %d, %d",
@@ -412,7 +409,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;
@@ -421,7 +417,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (Being::isTalking())
return;
-
const int pixelX = event.getX() + static_cast<int>(mPixelViewX);
const int pixelY = event.getY() + static_cast<int>(mPixelViewY);
@@ -460,6 +455,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
@@ -705,6 +707,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)
@@ -879,7 +886,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/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.
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 1efa9c22d..734daa7a6 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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/whoisonline.h"
@@ -132,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);
@@ -230,7 +228,7 @@ void WhoIsOnline::updateWindow(std::vector<OnlinePlayer*> &friends,
if (addedFromSection == true && !disregard.empty())
{
mBrowserBox->addRow("---");
- addedFromSection = false;
+// addedFromSection = false;
}
for (int i = 0; i < static_cast<int>(disregard.size()); i++)
{
@@ -739,7 +737,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)
diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h
index 1607286a9..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef WHOISONLINE_H
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/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<unsigned>(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<unsigned>(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<int>(
- 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<unsigned>(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<unsigned>(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<unsigned>(getWidth()));
if (forced)
{
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/button.cpp b/src/gui/widgets/button.cpp
index 2867e3d39..c99f46149 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] = nullptr;
+ 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*>(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*>(
- 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*>(graphics)->getRedraw())
+ else if (g2->getRedraw())
{
recalc = true;
}
@@ -230,45 +328,73 @@ void Button::draw(gcn::Graphics *graphics)
{
mRedraw = false;
mMode = mode;
- static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0,
- getWidth(), getHeight(), button[mode]);
+ g2->calcWindow(mVertexes, 0, 0, getWidth(), getHeight(), button[mode]);
}
- static_cast<Graphics*>(graphics)->drawImageRect2(
- mVertexes, button[mode]);
+ g2->drawImageRect2(mVertexes, button[mode]);
-// static_cast<Graphics*>(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)
+ {
+ 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 +424,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 <guichan/widgetlistener.hpp>
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.
*
@@ -51,6 +55,23 @@ class Button : public gcn::Button, public gcn::WidgetListener
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.
*/
~Button();
@@ -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
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 018e35030..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.playGuiSfx("system/newmessage.ogg");
+ 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/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 8335a61bc..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/widgets/dropshortcutcontainer.h"
diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h
index 1f03fd53b..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef DROPSHORTCUTCONTAINER_H
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/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/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/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<unsigned>(
+ 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<unsigned>(mSelectedColumn)
+ && r == static_cast<unsigned>(mSelectedRow))
{
graphics->fillRectangle(gcn::Rectangle(
x_offset, y_offset, width, height));
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
@@ -34,11 +34,16 @@ 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/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/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/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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/namesmodel.h"
+
+#include "logger.h"
+
+#include "utils/gettext.h"
+
+#include <guichan/exception.hpp>
+#include <guichan/font.hpp>
+
+#include "debug.h"
+
+NamesModel::NamesModel()
+{
+}
+
+NamesModel::~NamesModel()
+{
+}
+
+int NamesModel::getNumberOfElements()
+{
+ return static_cast<int>(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..dc694fc46
--- /dev/null
+++ b/src/gui/widgets/namesmodel.h
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WIDGETS_NAMESMODEL_H
+#define GUI_WIDGETS_NAMESMODEL_H
+
+//#include "guichanfwd.h"
+
+#include <guichan/listmodel.hpp>
+
+#include <vector>
+
+class NamesModel : public gcn::ListModel
+{
+ public:
+ NamesModel();
+
+ virtual ~NamesModel();
+
+ virtual int getNumberOfElements();
+
+ virtual std::string getElementAt(int i);
+
+ std::vector<std::string> &getNames()
+ { return mNames; }
+
+ size_t size()
+ { return mNames.size(); }
+
+ protected:
+ std::vector<std::string> mNames;
+};
+
+#endif
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 56ce0a25a..93854e823 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -23,8 +23,10 @@
#include "configuration.h"
#include "main.h"
#include "logger.h"
+#include "sound.h"
#include "gui/editdialog.h"
+#include "gui/gui.h"
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
@@ -33,13 +35,19 @@
#include "gui/widgets/inttextfield.h"
#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"
#include "utils/dtor.h"
#include "utils/gettext.h"
+#include "utils/mathutils.h"
+#include <guichan/font.hpp>
+
+#include "debug.h"
SetupItem::SetupItem(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
@@ -163,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,
@@ -271,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);
@@ -394,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);
@@ -564,6 +580,7 @@ void SetupItemDropDown::createControls()
mWidget = mDropDown;
// mTextField->setWidth(50);
+ fixFirstItemSize(mLabel);
mHorizont->add(mLabel);
mHorizont->add(mDropDown);
@@ -588,3 +605,402 @@ 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,
+ int width, bool onTheFly, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ 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, int width, bool onTheFly,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ 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(mWidth);
+ mSlider->setHeight(40);
+ fixFirstItemSize(mLabel);
+ 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();
+ if (mOnTheFly)
+ save();
+}
+
+void SetupItemSlider::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ 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 onTheFly,
+ 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),
+ mOnTheFly(onTheFly)
+{
+ 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 onTheFly, 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),
+ mOnTheFly(onTheFly)
+{
+ 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);
+ fixFirstItemSize(mLabel);
+ 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();
+ if (mOnTheFly)
+ save();
+}
+
+void SetupItemSlider2::updateLabel()
+{
+ int val = mSlider->getValue() - mMin;
+ if (val < 0)
+ val = 0;
+ else if (val >= static_cast<signed>(mValues->size()))
+ val = static_cast<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();
+}
+
+
+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;
+ fixFirstItemSize(mLabel);
+ mHorizont->add(mLabel, 5);
+ mHorizont->add(mSlider);
+
+ addMoreControls();
+
+ 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();
+}
+
+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(BUTTON_PLAY, 16, 16, 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 71856d6e2..86fdf95f9 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -41,6 +41,8 @@ class EditDialog;
class HorizontContainer;
class IntTextField;
class Label;
+class Slider;
+class SliderList;
class TextField;
class SetupItem : public gcn::ActionListener
@@ -91,11 +93,12 @@ 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; }
+ void fixFirstItemSize(gcn::Widget *widget);
+
protected:
std::string mText;
@@ -264,4 +267,148 @@ 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,
+ 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, int width = 150,
+ bool onTheFly = false, bool mainConfig = true);
+
+ ~SetupItemSlider();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ void updateLabel();
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ Slider *mSlider;
+ double mMin;
+ double mMax;
+ int mWidth;
+ bool mOnTheFly;
+};
+
+typedef std::vector<std::string> 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 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 onTheFly = false, 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;
+ 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();
+
+ virtual void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ virtual void addMoreControls() = 0;
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ SliderList *mSlider;
+ gcn::ListModel *mModel;
+ int mWidth;
+ 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/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index ab8f61a40..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(32, false, 8);
+ 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<std::string, SetupItem*> mItems;
std::set<SetupItem*> mAllItems;
+ int mPreferredFirstItemSize;
};
#endif
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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 <guichan/font.hpp>
+
+#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..b2239834d
--- /dev/null
+++ b/src/gui/widgets/sliderlist.h
@@ -0,0 +1,83 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WIDGETS_SLIDERLIST_H
+#define GUI_WIDGETS_SLIDERLIST_H
+
+#include <guichan/actionlistener.hpp>
+#include <guichan/listmodel.hpp>
+#include <guichan/mouselistener.hpp>
+
+#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();
+
+ int getSelected()
+ { return mSelectedIndex; }
+
+ 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
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 5c4dbc9a1..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "gui/widgets/spellshortcutcontainer.h"
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 4191f9921..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef SPELLSHORTCUTCONTAINER_H
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/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/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<signed>(mMaximum))
return mMaximum;
return value;
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/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<int>(r * value),
+ static_cast<int>(g * value),
+ static_cast<int>(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<int>(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<int>(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<int>(mWidgets.size());
do
{
++ focusedWidget;
@@ -180,7 +180,7 @@ namespace gcn
-- i;
- if (focusedWidget >= (int)mWidgets.size())
+ if (focusedWidget >= static_cast<int>(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<int>(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<int>(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<int>(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<int>(mWidgets.size());
do
{
++ focusedWidget;
@@ -365,7 +365,7 @@ namespace gcn
-- i;
- if (focusedWidget >= (int)mWidgets.size())
+ if (focusedWidget >= static_cast<int>(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<int>(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<int>(mWidgets.size());
do
{
-- focusedWidget;
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/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp
index a0221ca7c..23298ef37 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<Uint8*>(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<Uint16*>(p);
break;
case 3:
@@ -90,7 +91,7 @@ namespace gcn
break;
case 4:
- color = *(Uint32 *)p;
+ color = *reinterpret_cast<Uint32*>(p);
break;
default:
@@ -123,7 +124,8 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
@@ -134,7 +136,7 @@ namespace gcn
break;
case 2:
- *(Uint16 *)p = pixel;
+ *reinterpret_cast<Uint16*>(p) = pixel;
break;
case 3:
@@ -153,7 +155,7 @@ namespace gcn
break;
case 4:
- *(Uint32 *)p = pixel;
+ *reinterpret_cast<Uint32*>(p) = pixel;
break;
default:
@@ -199,7 +201,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<unsigned short>((b & f->Rmask)
| (g & f->Gmask) | (r & f->Bmask));
}
@@ -230,7 +232,8 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
@@ -241,8 +244,8 @@ namespace gcn
break;
case 2:
- *(Uint16 *)p = SDLAlpha16(pixel, *(Uint32 *)p,
- color.a, surface->format);
+ *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel,
+ *reinterpret_cast<Uint32*>(p), color.a, surface->format);
break;
case 3:
@@ -275,7 +278,8 @@ namespace gcn
break;
case 4:
- *(Uint32 *)p = SDLAlpha32(pixel, *(Uint32 *)p, color.a);
+ *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
+ *reinterpret_cast<Uint32*>(p), color.a);
break;
default:
break;
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/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<Uint8*>(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<Uint16*>(p);
for (; x1 <= x2; ++x1)
*(q++) = pixel;
break;
@@ -329,7 +330,7 @@ namespace gcn
case 4:
{
- Uint32* q = (Uint32*)p;
+ Uint32 *q = reinterpret_cast<Uint32*>(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<Uint8*>(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<Uint16*>(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<Uint32*>(p) = SDLAlpha32(pixel,
+ *reinterpret_cast<Uint32*>(p), mColor.a);
+ }
else
- *(Uint32*)p = pixel;
+ {
+ *reinterpret_cast<Uint32*>(p) = pixel;
+ }
p += mTarget->pitch;
}
break;
diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp
index e4aadc465..cf8505c4e 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<unsigned int*>(mSurface->pixels))[i]
+ == SDL_MapRGB(mSurface->format, 255, 0, 255))
{
hasPink = true;
break;
@@ -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<unsigned int*>(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<int>(getChildrenArea().height * 0.95));
}
else
{
setVerticalScrollAmount(getVerticalScrollAmount()
- + (int)(getChildrenArea().height * 0.95));
+ + static_cast<int>(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<int>(getChildrenArea().width * 0.95));
}
else
{
setHorizontalScrollAmount(getHorizontalScrollAmount()
- + (int)(getChildrenArea().width * 0.95));
+ + static_cast<int>(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<double>(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<int>((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<int>(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<int>(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<int>(mTextRows[mCaretRow].size()))
{
- ++mCaretRow;
+ ++ mCaretRow;
- if (mCaretRow >= (int)mTextRows.size())
+ if (mCaretRow >= static_cast<int>(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<int>(
+ 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<int>(
+ mTextRows[mCaretRow].size())
+ && mCaretRow < (static_cast<int>(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<int>(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<char>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(std::string::npos))
return false;
msg = msg.substr(0, pos);
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 <joshlangley@optusnet.com.au>
+ * 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 <joshlangley@optusnet.com.au>
+ * 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/localplayer.cpp b/src/localplayer.cpp
index 0576c8ddb..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;
@@ -1677,7 +1668,7 @@ void LocalPlayer::processEvent(Channels channel,
- event.getInt("oldValue");
if (change != 0)
- addMessageToQueue(toString(change) + " xp");
+ addMessageToQueue(strprintf("%d %s", change, _("xp")));
break;
}
case LEVEL:
@@ -1711,7 +1702,8 @@ void LocalPlayer::processEvent(Channels channel,
MessagePair pair = mMessages.back();
// TRANSLATORS: this is normal experience
if (pair.first.find(strprintf(" %s",
- _("xp"))) == pair.first.size() - 3)
+ _("xp"))) == pair.first.size()
+ - strlen(_("xp")) - 1)
{
mMessages.pop_back();
// TRANSLATORS: this is job experience
@@ -2063,7 +2055,7 @@ std::string LocalPlayer::getQuickDropCounterString()
void LocalPlayer::setQuickDropCounter(int n)
{
- if (n < 1 || n >= (signed)quickDropCounterSize)
+ if (n < 1 || n >= static_cast<signed>(quickDropCounterSize))
return;
mQuickDropCounter = n;
config.setValue("quickDropCounter", mQuickDropCounter);
@@ -2152,7 +2144,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")
};
@@ -2203,7 +2195,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();
}
@@ -3168,15 +3161,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)
@@ -4150,7 +4139,7 @@ void LocalPlayer::checkNewName(Being *being)
if (!mWaitFor.empty() && mWaitFor == nick)
{
debugMsg(_("You see ") + mWaitFor);
- sound.playGuiSfx("system/newmessage.ogg");
+ sound.playGuiSound(SOUND_INFO);
mWaitFor = "";
}
}
diff --git a/src/logger.cpp b/src/logger.cpp
index 1541616f2..9c9c6efef 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -189,7 +189,8 @@ void Logger::log(const char *log_text, ...)
delete [] buf;
}
-void Logger::error(const std::string &error_text)
+// 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
@@ -214,3 +215,31 @@ void Logger::error(const std::string &error_text)
#endif
exit(1);
}
+
+// here string can be unsafe strings
+void Logger::error(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 happend. "
+ "Please see log file for more information.\"";
+ if (system(msg.c_str()) == -1)
+ std::cerr << "Error: " << error_text << std::endl;
+#else
+ std::cerr << "Error: " << error_text << std::endl;
+#endif
+ exit(1);
+}
diff --git a/src/logger.h b/src/logger.h
index db618b275..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.
@@ -98,6 +100,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/main.h b/src/main.h
index fbc672939..abc152ed3 100644
--- a/src/main.h
+++ b/src/main.h
@@ -45,8 +45,8 @@
* different interfaces, which have different implementations for each server.
*/
-#define SMALL_VERSION "1.2.2.5"
-#define CHECK_VERSION "01.02.02.05"
+#define SMALL_VERSION "1.2.2.19"
+#define CHECK_VERSION "01.02.02.19"
#ifdef HAVE_CONFIG_H
#include "../config.h"
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/net/beinghandler.h b/src/net/beinghandler.h
index bc1491ada..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef BEINGHANDLER_H
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/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/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 <lloyd_bryant@netzero.net>
+ * 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 <lloyd_bryant@netzero.net>
+ * Copyright (C) 2011-2012 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 27aa4da80..bfbef0798 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<int>(scrollOffsetY));
if (viewport)
+ {
+ viewport->returnCamera();
+ if (miniStatusWindow)
+ miniStatusWindow->updateStatus();
viewport->scrollBy(scrollOffsetX, scrollOffsetY);
+ }
}
void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
@@ -336,7 +342,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_OK, false);
weightNotice->addActionListener(
&weightListener);
}
@@ -346,7 +352,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_OK, false);
weightNotice->addActionListener(
&weightListener);
}
@@ -426,8 +432,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
if (PlayerInfo::getAttribute(HP) == 0 && !deathNotice)
{
deathNotice = new OkDialog(_("Message"),
- randomDeathMessage(),
- false);
+ randomDeathMessage(), DIALOG_OK, 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/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/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 84e71eaf3..05041c56a 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,8 +76,8 @@ void finalize()
if (connections)
{
- logger->error("Tried to shutdown the network subsystem while there "
- "are network connections left!");
+ logger->safeError("Tried to shutdown the network subsystem "
+ "while there are network connections left!");
}
clearNetworkHandlers();
@@ -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/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<unsigned>(buf[f]));
str += " ";
for (int f = 0; f < length; f ++)
{
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())
{
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 <lloyd_bryant@netzero.net>
+ * 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 <lloyd_bryant@netzero.net>
+ * Copyright (C) 2011-2012 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
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<char*>(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<char*>(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<float>(scaledWidth)
+ / image->getWidth();
+ const float scaleFactorH = static_cast<float>(scaledHeight)
+ / image->getHeight();
for (int py = 0; py < h; py += ih)
{
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 <SDL_opengl.h>
-#endif
class OpenGL1Graphics : public Graphics
{
@@ -140,5 +139,6 @@ class OpenGL1Graphics : public Graphics
bool mColorAlpha;
bool mSync;
};
+#endif
#endif
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<float>(width)
+ / scaledWidth;
+ const float visibleFractionH = static_cast<float>(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<float>(scaledWidth) / iw;
+ const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
for (int py = 0; py < h; py += scaledHeight)
{
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 <SDL_opengl.h>
-#endif
class OpenGLGraphics : public Graphics
{
@@ -154,5 +153,6 @@ class OpenGLGraphics : public Graphics
bool mColorAlpha;
bool mSync;
};
+#endif
#endif
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/particleemitterprop.h b/src/particleemitterprop.h
index cadfa0f3a..2b6b7ba1a 100644
--- a/src/particleemitterprop.h
+++ b/src/particleemitterprop.h
@@ -21,6 +21,7 @@
*/
#include <cmath>
+#include <cstdlib>
/**
* Returns a random numeric value that is larger than or equal min and smaller
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index e1f88ecb7..6c799cdfa 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -69,3 +69,16 @@ void Action::setAnimation(int direction, Animation *animation)
{
mAnimations[direction] = animation;
}
+
+void Action::setLastFrameDelay(int delay)
+{
+ AnimationIter it = mAnimations.begin();
+ AnimationIter it_end = mAnimations.end();
+ for (; it != it_end; ++ it)
+ {
+ Animation *animation = (*it).second;
+ if (!animation)
+ continue;
+ animation->setLastFrameDelay(delay);
+ }
+}
diff --git a/src/resources/action.h b/src/resources/action.h
index 3951cc02c..f9c5da75b 100644
--- a/src/resources/action.h
+++ b/src/resources/action.h
@@ -29,6 +29,7 @@
class Animation;
+
/**
* An action consists of several animations, one for each direction.
*/
@@ -49,9 +50,12 @@ class Action
void setNumber(unsigned n)
{ mNumber = n; }
+ void setLastFrameDelay(int delay);
+
protected:
typedef std::map<int, Animation*> Animations;
- typedef Animations::iterator AnimationIterator;
+ typedef Animations::iterator AnimationIter;
+
Animations mAnimations;
unsigned mNumber;
};
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 1c1da6ca5..388c1301e 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -69,3 +69,17 @@ void Animation::addGoto(std::string name, int rand)
Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name };
mFrames.push_back(frame);
}
+
+void Animation::setLastFrameDelay(int delay)
+{
+ FramesRevIter it = mFrames.rbegin();
+ FramesRevIter it_end = mFrames.rend();
+ for (; it != it_end; ++ it)
+ {
+ if ((*it).type == Frame::ANIMATION && (*it).image)
+ {
+ (*it).delay = delay;
+ break;
+ }
+ }
+}
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 33bfd76e9..53e9adbea 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -102,13 +102,19 @@ class Animation
void addGoto(std::string name, int rand);
+ void setLastFrameDelay(int delay);
+
/**
* Determines whether the given animation frame is a terminator.
*/
static bool isTerminator(const Frame &phase);
protected:
- std::vector<Frame> mFrames;
+ typedef std::vector<Frame> Frames;
+ typedef Frames::iterator FramesIter;
+ typedef Frames::reverse_iterator FramesRevIter;
+
+ Frames mFrames;
int mDuration;
};
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/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/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<short>(y);
mBounds.w = static_cast<Uint16>(width);
mBounds.h = static_cast<Uint16>(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/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 0d9b95f6f..02b46f1cf 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -36,6 +36,7 @@
#include "debug.h"
SpriteReference *SpriteReference::Empty = nullptr;
+extern int serverVersion;
Action *SpriteDef::getAction(std::string action, unsigned num) const
{
@@ -99,13 +100,30 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
def->mProcessedFiles.insert(animationFile);
def->loadSprite(rootNode, variant, palettes);
def->substituteActions();
+ if (serverVersion < 1)
+ def->fixDeadAction();
return def;
}
+void SpriteDef::fixDeadAction()
+{
+ ActionsIter it = mActions.begin();
+ ActionsIter it_end = mActions.end();
+ for (; it != it_end; ++ it)
+ {
+ ActionMap *d = (*it).second;
+ if (!d)
+ continue;
+ ActionMap::iterator i = d->find("dead");
+ if (i != d->end() && i->second)
+ (i->second)->setLastFrameDelay(0);
+ }
+}
+
void SpriteDef::substituteAction(std::string complete, std::string with)
{
- Actions::const_iterator it = mActions.begin();
- Actions::const_iterator it_end = mActions.end();
+ ActionsConstIter it = mActions.begin();
+ ActionsConstIter it_end = mActions.end();
for (; it != it_end; ++ it)
{
ActionMap *d = (*it).second;
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 0490bdcb3..e167cf188 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -176,6 +176,11 @@ class SpriteDef : public Resource
void substituteActions();
/**
+ * Fix bad timeout in last dead action frame
+ */
+ void fixDeadAction();
+
+ /**
* When there are no animations defined for the action "complete", its
* animations become a copy of those of the action "with".
*/
@@ -185,6 +190,8 @@ class SpriteDef : public Resource
typedef ImageSets::iterator ImageSetIterator;
typedef std::map<std::string, Action*> ActionMap;
typedef std::map<unsigned, ActionMap*> Actions;
+ typedef Actions::const_iterator ActionsConstIter;
+ typedef Actions::iterator ActionsIter;
ImageSets mImageSets;
Actions mActions;
diff --git a/src/sound.cpp b/src/sound.cpp
index 913b55656..5b7f1201d 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -66,9 +66,7 @@ Sound::Sound():
Sound::~Sound()
{
- config.removeListener("playBattleSound", this);
- config.removeListener("playGuiSound", this);
- config.removeListener("playMusic", this);
+ config.removeListeners(this);
// Unlink the callback function.
Mix_HookMusicFinished(nullptr);
@@ -82,6 +80,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 +100,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)
{
@@ -317,6 +321,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..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
@@ -109,6 +118,8 @@ class Sound : public ConfigListener
*/
void playGuiSfx(const std::string &path);
+ void playGuiSound(const std::string &name);
+
void changeAudio();
void volumeOff();
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index ebdff6382..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "spellmanager.h"
diff --git a/src/spellmanager.h b/src/spellmanager.h
index 651ada56c..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef SPELLMANAGER_H
diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp
index 67171524c..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "configuration.h"
diff --git a/src/spellshortcut.h b/src/spellshortcut.h
index 047ccdef3..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef SPELLSHORTCUT_H
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.
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 8801ef149..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.
*
@@ -16,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 <http://www.gnu.org/licenses/>.
*/
#include "textcommand.h"
diff --git a/src/textcommand.h b/src/textcommand.h
index 6677b97e9..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.
*
@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TEXTCOMMAND_H
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 <DougABoffey@netscape.net>
+ * 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 <DougABoffey@netscape.net>
+ * Copyright (C) 2011-2012 The ManaPlus developers
*
* This file is part of The ManaPlus Client.
*
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/copynpaste.cpp b/src/utils/copynpaste.cpp
index d918c8108..763b579d0 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 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -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<char *>(nullptr));
+ }
else
- execl("/usr/bin/xsel", "xsel", p1, (char *)nullptr);
+ {
+ execl("/usr/bin/xsel", "xsel", p1,
+ static_cast<char *>(nullptr));
+ }
exit(1);
}
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
index 03596d5d1..5e95a1152 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 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
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<std::string> getLang()
}
int dot = lang.find(".");
- if (dot != (signed)std::string::npos)
+ if (dot != static_cast<signed>(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<signed>(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<signed>(std::string::npos))
lang = lang.substr(0, dot);
dot = lang.find("_");
- if (dot != (signed)std::string::npos)
+ if (dot != static_cast<signed>(std::string::npos))
return lang.substr(0, dot);
return lang;
}
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 9f6818146..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 <string>
#include <stdint.h>
+#include <cstring>
static uint16_t crc_table[256] =
{
@@ -112,4 +114,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
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index 1960f0dee..19b08d4c7 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -27,9 +27,11 @@
#include "localconsts.h"
+#include "debug.h"
+
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<PHYSFS_file *>(rw->hidden.unknown.data1);
int pos = 0;
if (whence == SEEK_SET)
@@ -46,8 +48,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<int>(current);
+ if (static_cast<PHYSFS_sint64>(pos) != current)
{
SDL_SetError("Can't fit current file position in an int!");
return -1;
@@ -67,8 +69,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<int>(len);
+ if (static_cast<PHYSFS_sint64>(pos) != len)
{
SDL_SetError("Can't fit end-of-file position in an int!");
return -1;
@@ -88,7 +90,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<PHYSFS_uint64>(pos)))
{
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return -1;
@@ -99,7 +101,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<PHYSFS_file*>(rw->hidden.unknown.data1);
PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum);
if (rc != maxnum)
{
@@ -107,22 +109,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<int>(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<PHYSFS_file*>(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<int>(rc);
} /* physfsrwops_write */
static int physfsrwops_close(SDL_RWops *rw)
{
- PHYSFS_file *handle = (PHYSFS_file*)rw->hidden.unknown.data1;
+ PHYSFS_file *handle = static_cast<PHYSFS_file*>(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 4a2081514..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<char *>(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<char *>(nullptr));
}
exit(-1);
}
@@ -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);
}
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 9184ba79d..5a7ea87fd 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -28,6 +28,8 @@
#include <cstdio>
#include <list>
+#include <sys/time.h>
+
#include "debug.h"
static int UTF8_MAX_SIZE = 10;
@@ -520,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<int>(str[0]));
for (unsigned f = 1; f < str.size(); f ++)
- hex += strprintf("%%%2x", (int)str[f]);
+ hex += strprintf("%%%2x", static_cast<int>(str[f]));
return hex;
}
@@ -598,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<int>(std::string::npos))
url = url.substr(i + 3);
return url;
}
@@ -609,3 +611,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
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();
}
}
diff --git a/src/winver.h b/src/winver.h
index 4ff552db1..164c304ba 100644
--- a/src/winver.h
+++ b/src/winver.h
@@ -1,3 +1,23 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
/* VERSION DEFINITIONS */
#define VER_MAJOR 1
#define VER_MINOR 0