summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-08-10 20:16:22 -0600
committerJared Adams <jaxad0127@gmail.com>2009-08-10 20:16:22 -0600
commit56865a2c98a589a1e530e296b1681e369e2ae48f (patch)
treec3ea1115b5afcca197c87e1a257f34583b2d57ce /src
parent7a7018c517948c2cc567d28d221c5cd8a91f2c12 (diff)
parent0ebdce30ee61d7b038e81bc64ae7d1e27d98a144 (diff)
downloadmana-56865a2c98a589a1e530e296b1681e369e2ae48f.tar.gz
mana-56865a2c98a589a1e530e296b1681e369e2ae48f.tar.bz2
mana-56865a2c98a589a1e530e296b1681e369e2ae48f.tar.xz
mana-56865a2c98a589a1e530e296b1681e369e2ae48f.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp1
-rw-r--r--src/commandhandler.cpp2
-rw-r--r--src/game.cpp1
-rw-r--r--src/gui/charcreatedialog.cpp4
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/chat.cpp1
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/guildwindow.cpp10
-rw-r--r--src/gui/login.cpp2
-rw-r--r--src/gui/npcdialog.cpp3
-rw-r--r--src/gui/palette.cpp12
-rw-r--r--src/gui/popupmenu.cpp7
-rw-r--r--src/gui/recorder.cpp1
-rw-r--r--src/gui/setup_keyboard.cpp2
-rw-r--r--src/gui/setup_video.cpp16
-rw-r--r--src/gui/skilldialog.cpp13
-rw-r--r--src/gui/speechbubble.cpp2
-rw-r--r--src/gui/statuswindow.cpp4
-rw-r--r--src/gui/trade.cpp4
-rw-r--r--src/gui/updatewindow.cpp5
-rw-r--r--src/gui/widgets/channeltab.cpp9
-rw-r--r--src/gui/widgets/whispertab.cpp2
-rw-r--r--src/gui/windowmenu.cpp4
-rw-r--r--src/localplayer.cpp1
-rw-r--r--src/net/ea/charserverhandler.cpp6
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/generalhandler.cpp14
-rw-r--r--src/net/ea/loginhandler.cpp22
-rw-r--r--src/net/ea/maphandler.cpp4
-rw-r--r--src/net/ea/playerhandler.cpp3
-rw-r--r--src/net/tmwserv/beinghandler.cpp14
-rw-r--r--src/net/tmwserv/charserverhandler.cpp30
-rw-r--r--src/net/tmwserv/chathandler.cpp31
-rw-r--r--src/net/tmwserv/loginhandler.cpp40
-rw-r--r--src/net/tmwserv/partyhandler.cpp7
-rw-r--r--src/playerrelations.cpp11
-rw-r--r--src/resources/wallpaper.cpp91
38 files changed, 219 insertions, 168 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 70be4ddb..23b87e6c 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -49,7 +49,6 @@
#include "gui/speechbubble.h"
#include "utils/dtor.h"
-#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 4396a1d0..e64da120 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -397,7 +397,7 @@ void CommandHandler::handleParty(const std::string &args, ChatTab *tab)
if (args != "")
Net::getPartyHandler()->invite(args);
else
- tab->chatLog("Please specify a name.", BY_SERVER);
+ tab->chatLog(_("Please specify a name."), BY_SERVER);
}
void CommandHandler::handleMe(const std::string &args, ChatTab *tab)
diff --git a/src/game.cpp b/src/game.cpp
index f424ad50..ff0d84f7 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -406,6 +406,7 @@ static bool saveScreenshot()
if (success)
{
std::stringstream chatlogentry;
+ // TODO: Make it one complete gettext string below
chatlogentry << _("Screenshot saved to ~/") << filenameSuffix.str();
localChatTab->chatLog(chatlogentry.str(), BY_SERVER);
}
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index f679072d..e09eee55 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -70,10 +70,10 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot):
// TRANSLATORS: This is a narrow symbol used to denote 'previous'.
// You may change this symbol if your language uses another.
mPrevHairColorButton = new Button(_("<"), "prevcolor", this);
- mHairColorLabel = new Label(_("Hair Color:"));
+ mHairColorLabel = new Label(_("Hair color:"));
mNextHairStyleButton = new Button(_(">"), "nextstyle", this);
mPrevHairStyleButton = new Button(_("<"), "prevstyle", this);
- mHairStyleLabel = new Label(_("Hair Style:"));
+ mHairStyleLabel = new Label(_("Hair style:"));
mCreateButton = new Button(_("Create"), "create", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
mMale = new RadioButton(_("Male"), "gender");
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1387bce5..69a627e1 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -118,7 +118,7 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
mNameLabel = new Label(strprintf(_("Name: %s"), ""));
mLevelLabel = new Label(strprintf(_("Level: %d"), 0));
- mMoneyLabel = new Label(strprintf(_("Money: %d"), 0));
+ mMoneyLabel = new Label(strprintf(_("Money: %s"), ""));
// Control that shows the Player
mPlayerBox = new PlayerBox;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index fa078983..c337d33b 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -40,6 +40,7 @@
#include "net/net.h"
#include "utils/dtor.h"
+#include "utils/gettext.h"
#include "utils/stringutils.h"
#include <guichan/focushandler.hpp>
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 1ddadba4..59c0f254 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -51,7 +51,7 @@ DebugWindow::DebugWindow():
mMapLabel = new Label(strprintf(_("Map: %s"), ""));
mMinimapLabel = new Label(strprintf(_("Minimap: %s"), ""));
mTileMouseLabel = new Label(strprintf(_("Tile: (%d, %d)"), 0, 0));
- mParticleCountLabel = new Label(strprintf(_("Particle Count: %d"), 0));
+ mParticleCountLabel = new Label(strprintf(_("Particle count: %d"), 0));
place(0, 0, mFPSLabel, 3);
place(3, 0, mTileMouseLabel);
diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp
index 8e37be72..c087fc7e 100644
--- a/src/gui/emoteshortcutcontainer.cpp
+++ b/src/gui/emoteshortcutcontainer.cpp
@@ -39,8 +39,6 @@
#include "resources/resourcemanager.h"
#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
static const int MAX_ITEMS = 12;
diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp
index 5b525b83..05af7780 100644
--- a/src/gui/guildwindow.cpp
+++ b/src/gui/guildwindow.cpp
@@ -114,7 +114,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
// Set focus so that guild name to be created can be typed.
mFocus = true;
guildDialog = new TextDialog(_("Guild Name"),
- _("Choose your guild's name"), this);
+ _("Choose your guild's name."), this);
guildDialog->setOKButtonActionId("CREATE_GUILD_OK");
guildDialog->addActionListener(this);
}
@@ -133,7 +133,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
if (guild)
{
Net::ChatServer::Guild::quitGuild(guild);
- localChatTab->chatLog(strprintf(_("Guild %s quit"),
+ localChatTab->chatLog(strprintf(_("Guild %s quit."),
mGuildTabs->getSelectedTab()->getCaption().c_str()), BY_SERVER);
}
}
@@ -150,7 +150,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
// Defocus dialog
mFocus = false;
- localChatTab->chatLog(strprintf(_("Creating Guild called %s"),
+ localChatTab->chatLog(strprintf(_("Creating guild called %s."),
name.c_str()), BY_SERVER);
guildDialog->scheduleDelete();
}
@@ -164,7 +164,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
// Defocus dialog
mFocus = false;
- localChatTab->chatLog(strprintf(_("Invited user %s"), name.c_str()), BY_SERVER);
+ localChatTab->chatLog(strprintf(_("Invited user %s."), name.c_str()), BY_SERVER);
inviteDialog->scheduleDelete();
}
else if (eventId == "yes")
@@ -240,7 +240,7 @@ short GuildWindow::getSelectedGuild()
void GuildWindow::openAcceptDialog(const std::string &inviterName,
const std::string &guildName)
{
- std::string msg = strprintf(_("%s has invited you to join the guild %s"),
+ std::string msg = strprintf(_("%s has invited you to join the guild %s."),
inviterName.c_str(), guildName.c_str());
localChatTab->chatLog(msg, BY_SERVER);
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 77f2e137..3b63eff1 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -70,7 +70,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
mServerDropDown = new DropDown(mServerList);
#endif
- mKeepCheck = new CheckBox(_("Remember Username"), mLoginData->remember);
+ mKeepCheck = new CheckBox(_("Remember username"), mLoginData->remember);
mOkButton = new Button(_("OK"), "ok", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
mRegisterButton = new Button(_("Register"), "register", this);
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 186a99a9..1956ba85 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -156,7 +156,8 @@ void NpcDialog::action(const gcn::ActionEvent &event)
if (mActionState == NPC_ACTION_NEXT)
{
nextDialog();
- addText("\n> Next\n");
+ // TRANSLATORS: Please leave the \n sequences intact.
+ addText(_("\n> Next\n"));
}
else if (mActionState == NPC_ACTION_CLOSE)
{
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index ac04d9b5..a807dcd6 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -90,8 +90,8 @@ Palette::Palette() :
addColor(HIGHLIGHT, 0xebc873, STATIC, _("Highlight"), 'H');
addColor(TAB_HIGHLIGHT, 0xff0000, PULSE, indent + _("Tab Highlight"));
- addColor(SHOP_WARNING, 0x910000, STATIC, indent + _("Item too expensive"));
- addColor(ITEM_EQUIPPED, 0x000091, STATIC, indent + _("Item is equipped"));
+ addColor(SHOP_WARNING, 0x910000, STATIC, indent + _("Item Too Expensive"));
+ addColor(ITEM_EQUIPPED, 0x000091, STATIC, indent + _("Item Is Equipped"));
addColor(CHAT, 0x000000, STATIC, _("Chat"), 'C');
addColor(GM, 0xff0000, STATIC, indent + _("GM"), 'G');
@@ -115,10 +115,10 @@ Palette::Palette() :
addColor(HEAD, 0x527fa4, STATIC, indent + _("Hats"));
addColor(USABLE, 0x268d24, STATIC, indent + _("Usables"));
addColor(TORSO, 0xd12aa4, STATIC, indent + _("Shirts"));
- addColor(ONEHAND, 0xf42a2a, STATIC, indent + _("1 Handed Weapons"));
+ addColor(ONEHAND, 0xf42a2a, STATIC, indent + _("One Handed Weapons"));
addColor(LEGS, 0x699900, STATIC, indent + _("Pants"));
addColor(FEET, 0xaa1d48, STATIC, indent + _("Shoes"));
- addColor(TWOHAND, 0xf46d0e, STATIC, indent + _("2 Handed Weapons"));
+ addColor(TWOHAND, 0xf46d0e, STATIC, indent + _("Two Handed Weapons"));
addColor(SHIELD, 0x9c2424, STATIC, indent + _("Shields"));
addColor(RING, 0x0000ff, STATIC, indent + _("Rings"));
addColor(NECKLACE, 0xff00ff, STATIC, indent + _("Necklaces"));
@@ -129,9 +129,9 @@ Palette::Palette() :
addColor(PICKUP_INFO, 0x28dc28, STATIC, indent + _("Pickup Notification"));
addColor(EXP_INFO, 0xffff00, STATIC, indent + _("Exp Notification"));
addColor(HIT_PLAYER_MONSTER, 0x0064ff, STATIC,
- indent + _("Player hits Monster"));
+ indent + _("Player Hits Monster"));
addColor(HIT_MONSTER_PLAYER, 0xff3232, STATIC,
- indent + _("Monster hits Player"));
+ indent + _("Monster Hits Player"));
addColor(HIT_CRITICAL, 0xff0000, RAINBOW, indent + _("Critical Hit"));
addColor(MISS, 0xffff00, STATIC, indent + _("Misses"));
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 3e3f0a78..0f0df756 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -84,8 +84,9 @@ void PopupMenu::showPopup(int x, int y, Being *being)
// Players can be traded with. Later also follow and
// add as buddy will be options in this menu.
mBrowserBox->addRow(strprintf("@@trade|%s@@",
- strprintf(_("Trade With %s"),
+ strprintf(_("Trade with %s"),
name.c_str()).c_str()));
+ // TRANSLATORS: Attacking a player.
mBrowserBox->addRow(strprintf("@@attack|%s@@",
strprintf(_("Attack %s"),
name.c_str()).c_str()));
@@ -109,7 +110,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case PlayerRelation::DISREGARDED:
mBrowserBox->addRow(strprintf("@@unignore|%s@@",
- strprintf(_("Un-Ignore %s"),
+ strprintf(_("Unignore %s"),
name.c_str()).c_str()));
mBrowserBox->addRow(strprintf("@@ignore|%s@@",
strprintf(_("Completely ignore %s"),
@@ -118,7 +119,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case PlayerRelation::IGNORED:
mBrowserBox->addRow(strprintf("@@unignore|%s@@",
- strprintf(_("Un-Ignore %s"),
+ strprintf(_("Unignore %s"),
name.c_str()).c_str()));
break;
}
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 3307d904..b2679553 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -28,6 +28,7 @@
#include "gui/widgets/layout.h"
#include "gui/widgets/windowcontainer.h"
+#include "utils/gettext.h"
#include "utils/stringutils.h"
#include <physfs.h>
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 938c1c4e..d9117b8a 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -116,7 +116,7 @@ void Setup_Keyboard::apply()
if (keyboard.hasConflicts())
{
- new OkDialog(_("Key Conflict(s) Detected."),
+ new OkDialog(_("Key Conflict(s) Detected"),
_("Resolve them, or gameplay may result in strange "
"behaviour."));
}
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 903196c6..f21f20e0 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -194,13 +194,15 @@ Setup_Video::Setup_Video():
mParticleEffectsEnabled)),
mNameCheckBox(new CheckBox(_("Show own name"), mNameEnabled)),
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)),
mSpeechSlider(new Slider(0, 3)),
mSpeechLabel(new Label("")),
mAlphaSlider(new Slider(0.2, 1.0)),
- mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
+ mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(10, 120)),
mFpsField(new TextField),
mOverlayDetail((int) config.getValue("OverlayDetail", 2)),
@@ -219,7 +221,7 @@ Setup_Video::Setup_Video():
speechLabel = new Label(_("Overhead text"));
alphaLabel = new Label(_("Gui opacity"));
overlayDetailLabel = new Label(_("Ambient FX"));
- particleDetailLabel = new Label(_("Particle Detail"));
+ particleDetailLabel = new Label(_("Particle detail"));
fontSizeLabel = new Label(_("Font size"));
mFontSizeDropDown = new DropDown(new FontSizeChoiceListModel);
@@ -372,7 +374,7 @@ void Setup_Video::apply()
}
else
{
- new OkDialog(_("Switching to full screen"),
+ new OkDialog(_("Switching to Full Screen"),
_("Restart needed for changes to take effect."));
}
#endif
@@ -385,7 +387,7 @@ void Setup_Video::apply()
config.setValue("opengl", mOpenGLCheckBox->isSelected());
// OpenGL can currently only be changed by restarting, notify user.
- new OkDialog(_("Changing OpenGL"),
+ new OkDialog(_("Changing to OpenGL"),
_("Applying change to OpenGL requires restart."));
}
@@ -448,12 +450,12 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (width != graphics->getWidth() || height != graphics->getHeight())
{
if (width < graphics->getWidth() || height < graphics->getHeight())
- new OkDialog(_("Screen resolution changed"),
+ 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."));
else
- new OkDialog(_("Screen resolution changed"),
+ new OkDialog(_("Screen Resolution Changed"),
_("Restart your client for the change to take effect."));
}
@@ -478,7 +480,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
mParticleEffectsCheckBox->isSelected());
if (engine)
{
- new OkDialog(_("Particle effect settings changed."),
+ new OkDialog(_("Particle Effect Settings Changed."),
_("Changes will take effect on map change."));
}
}
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 2f970184..a0bfaf53 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -340,9 +340,18 @@ void SkillEntry::update()
setVisible(true);
- std::string skillLevel("Lvl: " + toString(baseLevel));
+ std::string skillLevel;
+
if (effLevel != baseLevel)
- skillLevel += strprintf(" (%+d)", baseLevel - effLevel);
+ {
+ skillLevel = strprintf(_("Lvl: %d (%+d)"),
+ baseLevel, baseLevel - effLevel);
+ }
+ else
+ {
+ skillLevel = strprintf(_("Lvl: %d"), baseLevel);
+ }
+
mLevelLabel->setCaption(skillLevel);
std::pair<int, int> exp = player_node->getExperience(mInfo->id);
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 959e47ee..c2703327 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -28,8 +28,6 @@
#include "graphics.h"
-#include "utils/gettext.h"
-
#include <guichan/font.hpp>
#include <guichan/widgets/label.hpp>
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index f23f6e4f..6f5f72fa 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -223,11 +223,11 @@ std::string StatusWindow::update(int id)
#endif
else if (id == CHAR_POINTS)
{
- mCharacterPointsLabel->setCaption(strprintf(_("Character Points: %d"),
+ mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"),
player_node->getCharacterPoints()));
mCharacterPointsLabel->adjustSize();
- mCorrectionPointsLabel->setCaption(strprintf(_("Correction Points: %d"),
+ mCorrectionPointsLabel->setCaption(strprintf(_("Correction points: %d"),
player_node->getCorrectionPoints()));
mCorrectionPointsLabel->adjustSize();
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 77296e64..22eefc14 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -94,7 +94,7 @@ TradeWindow::TradeWindow():
ScrollArea *partnerScroll = new ScrollArea(mPartnerItemContainer);
partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mMoneyLabel = new Label(strprintf(_("You get %s."), ""));
+ mMoneyLabel = new Label(strprintf(_("You get %s"), ""));
gcn::Label *mMoneyLabel2 = new Label(_("You give:"));
mMoneyField = new TextField;
@@ -130,7 +130,7 @@ TradeWindow::~TradeWindow()
void TradeWindow::setMoney(int amount)
{
- mMoneyLabel->setCaption(strprintf(_("You get %s."),
+ mMoneyLabel->setCaption(strprintf(_("You get %s"),
Units::formatCurrency(amount).c_str()));
mMoneyLabel->adjustSize();
}
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 6ea5e1ca..bb2128b4 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -444,10 +444,13 @@ void UpdaterWindow::logic()
}
mThread = NULL;
}
+ // TODO: Only send complete sentences to gettext
mBrowserBox->addRow("");
mBrowserBox->addRow(_("##1 The update process is incomplete."));
+ // TRANSLATORS: Continues "you try again later.".
mBrowserBox->addRow(_("##1 It is strongly recommended that"));
- mBrowserBox->addRow(_("##1 you try again later"));
+ // TRANSLATORS: Begins "It is strongly recommended that".
+ mBrowserBox->addRow(_("##1 you try again later."));
mBrowserBox->addRow(mCurlError);
mScrollArea->setVerticalScrollAmount(
mScrollArea->getVerticalMaxScroll());
diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp
index e3edbba0..8b055a22 100644
--- a/src/gui/widgets/channeltab.cpp
+++ b/src/gui/widgets/channeltab.cpp
@@ -72,23 +72,24 @@ bool ChannelTab::handleCommand(const std::string &type,
{
chatLog(_("Command: /quit"));
chatLog(_("This command leaves the current channel."));
- chatLog(_("If you're the last person in the channel, it will be deleted."));
+ chatLog(_("If you're the last person in the channel, "
+ "it will be deleted."));
}
else if (args == "op")
{
chatLog(_("Command: /op <nick>"));
chatLog(_("This command makes <nick> a channel operator."));
chatLog(_("If the <nick> has spaces in it, enclose it in "
- "double quotes (\")."));
+ "double quotes (\")."));
chatLog(_("Channel operators can kick and op other users "
- "from the channel."));
+ "from the channel."));
}
else if (args == "kick")
{
chatLog(_("Command: /kick <nick>"));
chatLog(_("This command makes <nick> leave the channel."));
chatLog(_("If the <nick> has spaces in it, enclose it in "
- "double quotes (\")."));
+ "double quotes (\")."));
}
else
return false;
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index bc0d54d0..5509a589 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -91,7 +91,7 @@ bool WhisperTab::handleCommand(const std::string &type,
{
chatLog(_("Command: /unignore <player>"));
chatLog(_("This command stops ignoring the other player if they "
- "are being ignored"));
+ "are being ignored."));
}
else
return false;
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 8964f072..96776617 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -62,7 +62,7 @@ WindowMenu::WindowMenu():
#ifdef TMWSERV_SUPPORT
N_("Magic"),
N_("Guilds"),
- N_("Buddys"),
+ N_("Buddies"),
#endif
N_("Shortcut"),
N_("Setup"),
@@ -138,7 +138,7 @@ void WindowMenu::action(const gcn::ActionEvent &event)
{
window = guildWindow;
}
- else if (event.getId() == "Buddys")
+ else if (event.getId() == "Buddies")
{
window = buddyWindow;
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 57dc8981..9e4d6ab5 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -65,6 +65,7 @@
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
+#include <libintl.h>
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 762652a0..6fae1864 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -90,13 +90,13 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case SMSG_CHAR_LOGIN_ERROR:
switch (msg.readInt8()) {
case 0:
- errorMessage = _("Access denied");
+ errorMessage = _("Access denied.");
break;
case 1:
- errorMessage = _("Cannot use this ID");
+ errorMessage = _("Cannot use this ID.");
break;
default:
- errorMessage = _("Unknown failure to select character");
+ errorMessage = _("Unknown failure to select character.");
break;
}
mCharInfo->unlock();
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 49f83e67..65f1db3c 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -166,7 +166,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
case SMSG_MVP:
// Display MVP player
msg.readInt32(); // id
- localChatTab->chatLog("MVP player", BY_SERVER);
+ localChatTab->chatLog(_("MVP player."), BY_SERVER);
break;
}
}
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 0750ee86..1d500d62 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -117,26 +117,26 @@ void GeneralHandler::handleMessage(MessageIn &msg)
switch (code) {
case 0:
- errorMessage = _("Authentication failed");
+ errorMessage = _("Authentication failed.");
break;
case 1:
- errorMessage = _("No servers available");
+ errorMessage = _("No servers available.");
break;
case 2:
if (state == STATE_GAME)
errorMessage = _("Someone else is trying to use this "
- "account");
+ "account.");
else
- errorMessage = _("This account is already logged in");
+ errorMessage = _("This account is already logged in.");
break;
case 3:
- errorMessage = _("Speed hack detected");
+ errorMessage = _("Speed hack detected.");
break;
case 8:
- errorMessage = _("Duplicated login");
+ errorMessage = _("Duplicated login.");
break;
default:
- errorMessage = _("Unknown connection error");
+ errorMessage = _("Unknown connection error.");
break;
}
state = STATE_ERROR;
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 54e31cf3..8e7187c0 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -76,13 +76,13 @@ void LoginHandler::handleMessage(MessageIn &msg)
errorMessage = _("Account was not found. Please re-login.");
break;
case 2:
- errorMessage = _("Old password incorrect");
+ errorMessage = _("Old password incorrect.");
break;
case 3:
- errorMessage = _("New password too short");
+ errorMessage = _("New password too short.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_ACCOUNTCHANGE_ERROR;
@@ -96,7 +96,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
len = msg.readInt16() - 4;
mUpdateHost = msg.readString(len);
- logger->log("Received update host \"%s\" from login server",
+ logger->log("Received update host \"%s\" from login server.",
mUpdateHost.c_str());
break;
@@ -139,21 +139,21 @@ void LoginHandler::handleMessage(MessageIn &msg)
switch (code) {
case 0:
- errorMessage = _("Unregistered ID");
+ errorMessage = _("Unregistered ID.");
break;
case 1:
- errorMessage = _("Wrong password");
+ errorMessage = _("Wrong password.");
break;
case 2:
- errorMessage = _("Account expired");
+ errorMessage = _("Account expired.");
break;
case 3:
- errorMessage = _("Rejected from server");
+ errorMessage = _("Rejected from server.");
break;
case 4:
errorMessage = _("You have been permanently banned from "
- "the game. Please contact the GM Team.");
+ "the game. Please contact the GM team.");
break;
case 6:
errorMessage = strprintf(_("You have been temporarily "
@@ -163,10 +163,10 @@ void LoginHandler::handleMessage(MessageIn &msg)
msg.readString(20).c_str());
break;
case 9:
- errorMessage = _("This user name is already taken");
+ errorMessage = _("This user name is already taken.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_ERROR;
diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp
index 3036612e..c3c9437c 100644
--- a/src/net/ea/maphandler.cpp
+++ b/src/net/ea/maphandler.cpp
@@ -79,8 +79,8 @@ void MapHandler::handleMessage(MessageIn &msg)
break;
case SMSG_WHO_ANSWER:
- localChatTab->chatLog("Online users: " + toString(msg.readInt32()),
- BY_SERVER);
+ localChatTab->chatLog(strprintf(_("Online users: %d"),
+ msg.readInt32()), BY_SERVER);
break;
}
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index edd58562..3e379d82 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -317,7 +317,8 @@ void PlayerHandler::handleMessage(MessageIn &msg)
int curGp = player_node->getMoney();
player_node->setMoney(msg.readInt32());
if (player_node->getMoney() > curGp)
- localChatTab->chatLog(strprintf(_("You picked up %s"),
+ localChatTab->chatLog(strprintf(_("You picked up "
+ "%s."),
Units::formatCurrency(player_node->getMoney()
- curGp).c_str()), BY_SERVER);
}
diff --git a/src/net/tmwserv/beinghandler.cpp b/src/net/tmwserv/beinghandler.cpp
index 93f76ce7..acd6b62c 100644
--- a/src/net/tmwserv/beinghandler.cpp
+++ b/src/net/tmwserv/beinghandler.cpp
@@ -268,18 +268,22 @@ void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
static char const *const deadMsg[] =
{
_("You are dead."),
- _("We regret to inform you that your character was killed in battle."),
+ _("We regret to inform you that your character was killed in "
+ "battle."),
_("You are not that alive anymore."),
_("The cold hands of the grim reaper are grabbing for your soul."),
_("Game Over!"),
- _("No, kids. Your character did not really die. It... err... went to a better place."),
- _("Your plan of breaking your enemies weapon by bashing it with your throat failed."),
+ _("No, kids. Your character did not really die. It... err... "
+ "went to a better place."),
+ _("Your plan of breaking your enemies weapon by bashing it with "
+ "your throat failed."),
_("I guess this did not run too well."),
_("Do you want your possessions identified?"), // Nethack reference
_("Sadly, no trace of you was ever found..."), // Secret of Mana reference
_("Annihilated."), // Final Fantasy VI reference
- _("Looks like you got your head handed to you."), //Earthbound reference
- _("You screwed up again, dump your body down the tubes and get you another one.") // Leisure Suit Larry 1 Reference
+ _("Looks like you got your head handed to you."), // Earthbound reference
+ _("You screwed up again, dump your body down the tubes and get "
+ "you another one.") // Leisure Suit Larry 1 Reference
};
std::string message(deadMsg[rand()%13]);
diff --git a/src/net/tmwserv/charserverhandler.cpp b/src/net/tmwserv/charserverhandler.cpp
index 010c49d5..0146babb 100644
--- a/src/net/tmwserv/charserverhandler.cpp
+++ b/src/net/tmwserv/charserverhandler.cpp
@@ -81,7 +81,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
delete mCharInfo->getEntry();
mCharInfo->setEntry(0);
mCharInfo->unlock();
- new OkDialog(_("Info"), _("Player deleted"));
+ new OkDialog(_("Info"), _("Player deleted."));
}
// Character deletion failed
else
@@ -90,13 +90,13 @@ void CharServerHandler::handleMessage(MessageIn &msg)
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
- errorMessage = _("Not logged in");
+ errorMessage = _("Not logged in.");
break;
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("Selection out of range");
+ errorMessage = _("Selection out of range.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
}
mCharInfo->unlock();
new OkDialog(_("Error"), errorMessage);
@@ -135,37 +135,37 @@ void CharServerHandler::handleCharCreateResponse(MessageIn &msg)
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
- errorMessage = _("Not logged in");
+ errorMessage = _("Not logged in.");
break;
case CREATE_TOO_MUCH_CHARACTERS:
- errorMessage = _("No empty slot");
+ errorMessage = _("No empty slot.");
break;
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("Invalid name");
+ errorMessage = _("Invalid name.");
break;
case CREATE_EXISTS_NAME:
- errorMessage = _("Character's name already exists");
+ errorMessage = _("Character's name already exists.");
break;
case CREATE_INVALID_HAIRSTYLE:
- errorMessage = _("Invalid hairstyle");
+ errorMessage = _("Invalid hairstyle.");
break;
case CREATE_INVALID_HAIRCOLOR:
- errorMessage = _("Invalid hair color");
+ errorMessage = _("Invalid hair color.");
break;
case CREATE_INVALID_GENDER:
- errorMessage = _("Invalid gender");
+ errorMessage = _("Invalid gender.");
break;
case CREATE_RAW_STATS_TOO_HIGH:
- errorMessage = _("Character's stats are too high");
+ errorMessage = _("Character's stats are too high.");
break;
case CREATE_RAW_STATS_TOO_LOW:
- errorMessage = _("Character's stats are too low");
+ errorMessage = _("Character's stats are too low.");
break;
case CREATE_RAW_STATS_EQUAL_TO_ZERO:
- errorMessage = _("One stat is zero");
+ errorMessage = _("One stat is zero.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
new OkDialog(_("Error"), errorMessage);
diff --git a/src/net/tmwserv/chathandler.cpp b/src/net/tmwserv/chathandler.cpp
index e2d09534..c95f6ac5 100644
--- a/src/net/tmwserv/chathandler.cpp
+++ b/src/net/tmwserv/chathandler.cpp
@@ -159,7 +159,7 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
std::string user;
std::string userModes;
- tab->chatLog("Players in this channel:", BY_CHANNEL);
+ tab->chatLog(_("Players in this channel:"), BY_CHANNEL);
while(msg.getUnreadLength())
{
user = msg.readString();
@@ -176,13 +176,13 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
}
else
{
- localChatTab->chatLog("Error joining channel.", BY_SERVER);
+ localChatTab->chatLog(_("Error joining channel."), BY_SERVER);
}
}
void ChatHandler::handleListChannelsResponse(MessageIn &msg)
{
- localChatTab->chatLog("Listing channels", BY_SERVER);
+ localChatTab->chatLog(_("Listing channels."), BY_SERVER);
while(msg.getUnreadLength())
{
std::string channelName = msg.readString();
@@ -194,7 +194,7 @@ void ChatHandler::handleListChannelsResponse(MessageIn &msg)
channelName += numUsers.str();
localChatTab->chatLog(channelName, BY_SERVER);
}
- localChatTab->chatLog("End of channel list.", BY_SERVER);
+ localChatTab->chatLog(_("End of channel list."), BY_SERVER);
}
void ChatHandler::handlePrivateMessage(MessageIn &msg)
@@ -237,7 +237,7 @@ void ChatHandler::handleListChannelUsersResponse(MessageIn &msg)
std::string userNick;
std::string userModes;
Channel *channel = channelManager->findByName(channelName);
- channel->getTab()->chatLog("Players in this channel:", BY_CHANNEL);
+ channel->getTab()->chatLog(_("Players in this channel:"), BY_CHANNEL);
while(msg.getUnreadLength())
{
userNick = msg.readString();
@@ -266,15 +266,18 @@ void ChatHandler::handleChannelEvent(MessageIn &msg)
switch(eventId)
{
case CHAT_EVENT_NEW_PLAYER:
- line += " entered the channel.";
+ channel->getTab()->chatLog(strprintf(_("%s entered the "
+ "channel."), line.c_str()), BY_CHANNEL);
break;
case CHAT_EVENT_LEAVING_PLAYER:
- line += " left the channel.";
+ channel->getTab()->chatLog(strprintf(_("%s left the channel."),
+ line.c_str()), BY_CHANNEL);
break;
case CHAT_EVENT_TOPIC_CHANGE:
- line = "Topic: " + line;
+ channel->getTab()->chatLog(strprintf(_("Topic: %s"),
+ line.c_str()), BY_CHANNEL);
break;
case CHAT_EVENT_MODE_CHANGE:
@@ -284,7 +287,9 @@ void ChatHandler::handleChannelEvent(MessageIn &msg)
std::string user1 = line.substr(0, first);
std::string user2 = line.substr(first+1, second);
std::string mode = line.substr(second+1, line.length());
- line = user1 + " has set mode " + mode + " on user " + user2;
+ channel->getTab()->chatLog(strprintf(_("%s has set mode %s "
+ "on user %s."), user1.c_str(), mode.c_str(),
+ user2.c_str()), BY_CHANNEL);
} break;
case CHAT_EVENT_KICKED_PLAYER:
@@ -292,14 +297,14 @@ void ChatHandler::handleChannelEvent(MessageIn &msg)
int first = line.find(":");
std::string user1 = line.substr(0, first);
std::string user2 = line.substr(first+1, line.length());
- line = user1 + " has kicked " + user2;
+ channel->getTab()->chatLog(strprintf(_("%s has kicked %s."),
+ user1.c_str(), user2.c_str()), BY_CHANNEL);
} break;
default:
- line = "Unknown channel event.";
+ channel->getTab()->chatLog(_("Unknown channel event."),
+ BY_CHANNEL);
}
-
- channel->getTab()->chatLog(line, BY_CHANNEL);
}
}
diff --git a/src/net/tmwserv/loginhandler.cpp b/src/net/tmwserv/loginhandler.cpp
index 4f14a635..f728d831 100644
--- a/src/net/tmwserv/loginhandler.cpp
+++ b/src/net/tmwserv/loginhandler.cpp
@@ -77,16 +77,16 @@ void LoginHandler::handleMessage(MessageIn &msg)
{
switch (errMsg) {
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("Wrong magic_token");
+ errorMessage = _("Wrong magic_token.");
break;
case ERRMSG_FAILURE:
- errorMessage = _("Already logged in");
+ errorMessage = _("Already logged in.");
break;
case LOGIN_SERVER_FULL:
- errorMessage = _("Server is full");
+ errorMessage = _("Server is full.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_ERROR;
@@ -107,16 +107,16 @@ void LoginHandler::handleMessage(MessageIn &msg)
{
switch (errMsg) {
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("New password incorrect");
+ errorMessage = _("New password incorrect.");
break;
case ERRMSG_FAILURE:
- errorMessage = _("Old password incorrect");
+ errorMessage = _("Old password incorrect.");
break;
case ERRMSG_NO_LOGIN:
errorMessage = _("Account not connected. Please login first.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_ACCOUNTCHANGE_ERROR;
@@ -137,10 +137,10 @@ void LoginHandler::handleMessage(MessageIn &msg)
{
switch (errMsg) {
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("New email address incorrect");
+ errorMessage = _("New email address incorrect.");
break;
case ERRMSG_FAILURE:
- errorMessage = _("Old email address incorrect");
+ errorMessage = _("Old email address incorrect.");
break;
case ERRMSG_NO_LOGIN:
errorMessage = _("Account not connected. Please login first.");
@@ -149,7 +149,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
errorMessage = _("The new email address already exists.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_ACCOUNTCHANGE_ERROR;
@@ -173,19 +173,19 @@ void LoginHandler::handleLoginResponse(MessageIn &msg)
{
switch (errMsg) {
case LOGIN_INVALID_VERSION:
- errorMessage = _("Client version is too old");
+ errorMessage = _("Client version is too old.");
break;
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("Wrong username or password");
+ errorMessage = _("Wrong username or password.");
break;
case ERRMSG_FAILURE:
- errorMessage = _("Already logged in");
+ errorMessage = _("Already logged in.");
break;
case LOGIN_SERVER_FULL:
- errorMessage = _("Server is full");
+ errorMessage = _("Server is full.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_LOGIN_ERROR;
@@ -205,19 +205,19 @@ void LoginHandler::handleRegisterResponse(MessageIn &msg)
{
switch (errMsg) {
case REGISTER_INVALID_VERSION:
- errorMessage = _("Client version is too old");
+ errorMessage = _("Client version is too old.");
break;
case ERRMSG_INVALID_ARGUMENT:
- errorMessage = _("Wrong username, password or email address");
+ errorMessage = _("Wrong username, password or email address.");
break;
case REGISTER_EXISTS_USERNAME:
- errorMessage = _("Username already exists");
+ errorMessage = _("Username already exists.");
break;
case REGISTER_EXISTS_EMAIL:
- errorMessage = _("Email address already exists");
+ errorMessage = _("Email address already exists.");
break;
default:
- errorMessage = _("Unknown error");
+ errorMessage = _("Unknown error.");
break;
}
state = STATE_LOGIN_ERROR;
diff --git a/src/net/tmwserv/partyhandler.cpp b/src/net/tmwserv/partyhandler.cpp
index 557a3a43..220d20c0 100644
--- a/src/net/tmwserv/partyhandler.cpp
+++ b/src/net/tmwserv/partyhandler.cpp
@@ -100,8 +100,8 @@ void PartyHandler::handleMessage(MessageIn &msg)
int id = msg.readInt16(); // being id
std::string name = msg.readString();
- localChatTab->chatLog(strprintf(_("%s joined the "
- "party."), name.c_str()));
+ localChatTab->chatLog(strprintf(_("%s joined the party."),
+ name.c_str()));
if (!player_node->isInParty())
player_node->setInParty(true);
@@ -117,7 +117,8 @@ void PartyHandler::handleMessage(MessageIn &msg)
case CPMSG_PARTY_REJECTED:
{
std::string name = msg.readString();
- localChatTab->chatLog(name + "rejected your invite.");
+ localChatTab->chatLog(strprintf(_("%s rejected your invite."),
+ name.c_str()));
} break;
}
}
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 316bd9ed..7bc1b14d 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -29,6 +29,7 @@
#include "playerrelations.h"
#include "utils/dtor.h"
+#include "utils/gettext.h"
#define PLAYER_IGNORE_STRATEGY_NOP "nop"
#define PLAYER_IGNORE_STRATEGY_EMOTE0 "emote0"
@@ -292,7 +293,7 @@ class PIS_nothing : public PlayerIgnoreStrategy
public:
PIS_nothing()
{
- mDescription = "completely ignore";
+ mDescription = _("Completely ignore");
mShortName = PLAYER_IGNORE_STRATEGY_NOP;
}
@@ -306,7 +307,7 @@ class PIS_dotdotdot : public PlayerIgnoreStrategy
public:
PIS_dotdotdot()
{
- mDescription = "print '...'";
+ mDescription = _("Print '...'");
mShortName = "dotdotdot";
}
@@ -322,7 +323,7 @@ class PIS_blinkname : public PlayerIgnoreStrategy
public:
PIS_blinkname()
{
- mDescription = "blink name";
+ mDescription = _("Blink name");
mShortName = "blinkname";
}
@@ -359,10 +360,10 @@ PlayerRelationsManager::getPlayerIgnoreStrategies()
{
// not initialised yet?
mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE,
- "floating '...' bubble",
+ _("Floating '...' bubble"),
PLAYER_IGNORE_STRATEGY_EMOTE0));
mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE + 1,
- "floating bubble",
+ _("Floating bubble"),
"emote1"));
mIgnoreStrategies.push_back(new PIS_nothing());
mIgnoreStrategies.push_back(new PIS_dotdotdot());
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index bc9728d0..f0e834b1 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -32,18 +32,19 @@
#include <physfs.h>
#define WALLPAPER_FOLDER "graphics/images/"
-#define WALLPAPER_BASE "login_wallpaper"
+#define WALLPAPER_BASE "login_wallpaper.png"
-struct WallpaperSize
+struct WallpaperData
{
+ std::string filename;
int width;
int height;
};
-static std::vector<WallpaperSize> wallpaperSizes;
+static std::vector<WallpaperData> wallpaperData;
static bool haveBackup; // Is the backup (no size given) version available?
-bool wallpaperCompare(WallpaperSize a, WallpaperSize b)
+bool wallpaperCompare(WallpaperData a, WallpaperData b)
{
int aa = a.width * a.height;
int ab = b.width * b.height;
@@ -53,60 +54,82 @@ bool wallpaperCompare(WallpaperSize a, WallpaperSize b)
void Wallpaper::loadWallpapers()
{
- wallpaperSizes.clear();
-
- size_t baseLen = strlen(WALLPAPER_BASE);
- haveBackup = false;
+ wallpaperData.clear();
char **imgs = PHYSFS_enumerateFiles(WALLPAPER_FOLDER);
for (char **i = imgs; *i != NULL; i++)
{
- if (strncmp(*i, WALLPAPER_BASE, baseLen) == 0)
+ int width;
+ int height;
+
+ // If the backup file is found, we tell it.
+ if (strncmp (*i, WALLPAPER_BASE, strlen(*i)) == 0)
+ haveBackup = true;
+
+ // If the image format is terminated by: "_<width>x<height>.png"
+ // It is taken as a potential wallpaper.
+
+ // First, get the base filename of the image:
+ std::string filename = *i;
+ int separator = filename.rfind("_");
+ filename = filename.substr(0, separator);
+
+ // Then, append the width and height search mask.
+ filename.append("_%dx%d.png");
+
+ if (sscanf(*i, filename.c_str(), &width, &height) == 2)
{
- int width;
- int height;
-
- if (strlen(*i) == baseLen + 4)
- {
- if (haveBackup)
- logger->log("Duplicate default wallpaper!");
- else
- haveBackup = true;
- }
- else if (sscanf(*i, WALLPAPER_BASE "_%dx%d.png",
- &width, &height) == 2)
- {
- WallpaperSize wp;
- wp.width = width;
- wp.height = height;
- wallpaperSizes.push_back(wp);
- }
+ WallpaperData wp;
+ wp.filename = WALLPAPER_FOLDER;
+ wp.filename.append(*i);
+ wp.width = width;
+ wp.height = height;
+ wallpaperData.push_back(wp);
}
}
PHYSFS_freeList(imgs);
- std::sort(wallpaperSizes.begin(), wallpaperSizes.end(), wallpaperCompare);
+ std::sort(wallpaperData.begin(), wallpaperData.end(), wallpaperCompare);
}
std::string Wallpaper::getWallpaper(int width, int height)
{
- std::vector<WallpaperSize>::iterator iter;
- WallpaperSize wp;
+ std::vector<WallpaperData>::iterator iter;
+ WallpaperData wp;
- for (iter = wallpaperSizes.begin(); iter != wallpaperSizes.end(); iter++)
+ // Wallpaper filename container
+ std::vector<std::string> wallPaperVector;
+
+ for (iter = wallpaperData.begin(); iter != wallpaperData.end(); iter++)
{
wp = *iter;
if (wp.width <= width && wp.height <= height)
+ wallPaperVector.push_back(wp.filename);
+ }
+
+
+ if (!wallPaperVector.empty())
+ {
+ // If we've got more than one occurence of a valid wallpaper...
+ if (wallPaperVector.size() > 0)
{
- return std::string(strprintf(WALLPAPER_FOLDER WALLPAPER_BASE
- "_%dx%d.png", wp.width, wp.height));
+ // Return randomly a wallpaper between vector[0] and
+ // vector[vector.size() - 1]
+ srand((unsigned)time(0));
+ return wallPaperVector
+ [int(wallPaperVector.size() * rand() / (RAND_MAX + 1.0))];
}
+ else // If there at least one, we return it
+ return wallPaperVector[0];
}
+ // Return the backup file if everything else failed...
if (haveBackup)
- return std::string(WALLPAPER_FOLDER WALLPAPER_BASE ".png");
+ return std::string(WALLPAPER_FOLDER WALLPAPER_BASE);
+ // Return an empty string if everything else failed
return std::string();
+
}