summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp35
-rw-r--r--src/gui/char_select.cpp63
-rw-r--r--src/gui/char_server.cpp8
-rw-r--r--src/gui/confirm_dialog.cpp6
-rw-r--r--src/gui/connection.cpp6
-rw-r--r--src/gui/equipmentwindow.cpp4
-rw-r--r--src/gui/inventorywindow.cpp43
-rw-r--r--src/gui/item_amount.cpp34
-rw-r--r--src/gui/login.cpp21
-rw-r--r--src/gui/menuwindow.cpp38
-rw-r--r--src/gui/minimap.cpp6
-rw-r--r--src/gui/npc_text.cpp6
-rw-r--r--src/gui/npclistdialog.cpp8
-rw-r--r--src/gui/ok_dialog.cpp4
-rw-r--r--src/gui/popupmenu.cpp49
-rw-r--r--src/gui/register.cpp58
-rw-r--r--src/gui/sell.cpp40
-rw-r--r--src/gui/setup.cpp27
-rw-r--r--src/gui/setup_audio.cpp8
-rw-r--r--src/gui/setup_joystick.cpp18
-rw-r--r--src/gui/setup_video.cpp77
-rw-r--r--src/gui/trade.cpp43
22 files changed, 320 insertions, 282 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 597a7cad..a3424ab6 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -33,10 +33,11 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
BuyDialog::BuyDialog(Network *network):
- Window("Buy"), mNetwork(network),
+ Window(_("Buy")), mNetwork(network),
mMoney(0), mAmountItems(0), mMaxItems(0)
{
setWindowName("Buy");
@@ -51,13 +52,13 @@ BuyDialog::BuyDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label("Price : 0 GP / 0 GP");
+ mMoneyLabel = new gcn::Label(strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
- mBuyButton = new Button("Buy", "buy", this);
- mQuitButton = new Button("Quit", "quit", this);
- mItemDescLabel = new gcn::Label("Description:");
- mItemEffectLabel = new gcn::Label("Effect:");
+ mBuyButton = new Button(_("Buy"), "buy", this);
+ mQuitButton = new Button(_("Quit"), "quit", this);
+ mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), ""));
mIncreaseButton->setSize(20, 20);
mDecreaseButton->setSize(20, 20);
@@ -156,6 +157,9 @@ void BuyDialog::action(const gcn::ActionEvent &event)
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
+ // TODO: Actually we'd have a bug elsewhere if this check for the number
+ // of items to be bought ever fails, Bertram removed the assertions, is
+ // there a better way to ensure this fails in an _obvious_ way in C++?
else if (event.getId() == "buy" && mAmountItems > 0 &&
mAmountItems <= mMaxItems)
{
@@ -242,8 +246,10 @@ BuyDialog::updateButtonsAndLabels()
{
const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
- mItemDescLabel->setCaption("Description: " + info.getDescription());
- mItemEffectLabel->setCaption("Effect: " + info.getEffect());
+ mItemDescLabel->setCaption
+ (strprintf(_("Description: %s"), info.getDescription().c_str()));
+ mItemEffectLabel->setCaption
+ (strprintf(_("Effect: %s"), info.getEffect().c_str()));
int itemPrice = mShopItems->at(selectedItem)->getPrice();
@@ -259,8 +265,8 @@ BuyDialog::updateButtonsAndLabels()
}
else
{
- mItemDescLabel->setCaption("Description:");
- mItemEffectLabel->setCaption("Effect:");
+ mItemDescLabel->setCaption(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), ""));
mMaxItems = 0;
mAmountItems = 0;
}
@@ -272,8 +278,7 @@ BuyDialog::updateButtonsAndLabels()
mSlider->setEnabled(mMaxItems > 1);
// Update quantity and money labels
- mQuantityLabel->setCaption(
- toString(mAmountItems) + " / " + toString(mMaxItems));
- mMoneyLabel->setCaption("Price: " + toString(price) + " GP / "
- + toString(mMoney - price) + " GP" );
+ mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
+ mMoneyLabel->setCaption
+ (strprintf(_("Price: %d GP / Total: %d GP"), price, mMoney - price));
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 6a52a745..c89dadcd 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -37,7 +37,8 @@
#include "../net/charserverhandler.h"
#include "../net/messageout.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/trim.h"
// Defined in main.cpp, used here for setting the char create dialog
@@ -56,8 +57,8 @@ class CharDeleteConfirm : public ConfirmDialog
};
CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m):
- ConfirmDialog("Confirm", "Are you sure you want to delete this character?",
- m),
+ ConfirmDialog(_("Confirm Character Delete"),
+ _("Are you sure you want to delete this character?"), m),
master(m)
{
}
@@ -74,21 +75,23 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event)
CharSelectDialog::CharSelectDialog(Network *network,
LockedArray<LocalPlayer*> *charInfo,
Gender gender):
- Window("Select Character"), mNetwork(network),
+ Window(_("Select Character")), mNetwork(network),
mCharInfo(charInfo), mGender(gender), mCharSelected(false)
{
- mSelectButton = new Button("Ok", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mNewCharButton = new Button("New", "new", this);
- mDelCharButton = new Button("Delete", "delete", this);
- mPreviousButton = new Button("Previous", "previous", this);
- mNextButton = new Button("Next", "next", this);
-
- mNameLabel = new gcn::Label("Name");
- mLevelLabel = new gcn::Label("Level");
- mJobLevelLabel = new gcn::Label("Job Level");
- mMoneyLabel = new gcn::Label("Money");
- mPlayerBox = new PlayerBox();
+ mSelectButton = new Button(_("Ok"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mNewCharButton = new Button(_("New"), "new", this);
+ mDelCharButton = new Button(_("Delete"), "delete", this);
+ mPreviousButton = new Button(_("Previous"), "previous", this);
+ mNextButton = new Button(_("Next"), "next", this);
+
+ mNameLabel = new gcn::Label(strprintf(_("Name: %s"), ""));
+ mLevelLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
+ mJobLevelLabel = new gcn::Label(strprintf(_("Job Level: %d"), 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0));
+
+ // Control that shows the Player
+ mPlayerBox = new PlayerBox;
int w = 195;
int h = 220;
@@ -177,10 +180,10 @@ void CharSelectDialog::updatePlayerInfo()
if (pi)
{
- mNameLabel->setCaption(pi->getName());
- mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel));
- mJobLevelLabel->setCaption("Job Lvl: " + toString(pi->mJobLevel));
- mMoneyLabel->setCaption("Gold: " + toString(pi->mGp));
+ mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str()));
+ mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->mLevel));
+ mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), pi->mJobLevel));
+ mMoneyLabel->setCaption(strprintf(_("Gold: %d"), pi->mGp));
if (!mCharSelected)
{
mNewCharButton->setEnabled(false);
@@ -189,10 +192,10 @@ void CharSelectDialog::updatePlayerInfo()
}
}
else {
- mNameLabel->setCaption("Name");
- mLevelLabel->setCaption("Level");
- mJobLevelLabel->setCaption("Job Level");
- mMoneyLabel->setCaption("Money");
+ mNameLabel->setCaption(strprintf(_("Name: %s"), ""));
+ mLevelLabel->setCaption(strprintf(_("Level: %d"), 0));
+ mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), 0));
+ mMoneyLabel->setCaption(strprintf(_("Money: %d"), 0));
mNewCharButton->setEnabled(true);
mDelCharButton->setEnabled(false);
mSelectButton->setEnabled(false);
@@ -249,7 +252,7 @@ bool CharSelectDialog::selectByName(const std::string &name)
CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
Gender gender):
- Window("Create Character", true, parent), mNetwork(network), mSlot(slot)
+ Window(_("Create Character"), true, parent), mNetwork(network), mSlot(slot)
{
mPlayer = new Player(0, 0, NULL);
mPlayer->setGender(gender);
@@ -259,15 +262,15 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
mPlayer->setHairStyle(rand() % mPlayer->getNumOfHairstyles(), rand() % numberOfHairColors);
mNameField = new TextField("");
- mNameLabel = new gcn::Label("Name:");
+ mNameLabel = new gcn::Label(_("Name:"));
mNextHairColorButton = new Button(">", "nextcolor", this);
mPrevHairColorButton = new Button("<", "prevcolor", this);
- mHairColorLabel = new gcn::Label("Hair Color:");
+ mHairColorLabel = new gcn::Label(_("Hair Color:"));
mNextHairStyleButton = new Button(">", "nextstyle", this);
mPrevHairStyleButton = new Button("<", "prevstyle", this);
- mHairStyleLabel = new gcn::Label("Hair Style:");
- mCreateButton = new Button("Create", "create", this);
- mCancelButton = new Button("Cancel", "cancel", this);
+ mHairStyleLabel = new gcn::Label(_("Hair Style:"));
+ mCreateButton = new Button(_("Create"), "create", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
mPlayerBox = new PlayerBox(mPlayer);
mNameField->setActionEventId("create");
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 054aff84..ff401332 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -30,6 +30,8 @@
#include "../net/network.h" // TODO this is just for iptostring, move that?
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
extern SERVER_INFO **server_info;
@@ -46,15 +48,15 @@ class ServerListModel : public gcn::ListModel {
};
ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState):
- Window("Select Server"),
+ Window(_("Select Server")),
mLoginData(loginData),
mNextState(nextState)
{
mServerListModel = new ServerListModel();
mServerList = new ListBox(mServerListModel);
ScrollArea *mScrollArea = new ScrollArea(mServerList);
- mOkButton = new Button("OK", "ok", this);
- Button *mCancelButton = new Button("Cancel", "cancel", this);
+ mOkButton = new Button(_("OK"), "ok", this);
+ Button *mCancelButton = new Button(_("Cancel"), "cancel", this);
setContentSize(200, 100);
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 732f5769..72ce3e16 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -23,6 +23,8 @@
#include "confirm_dialog.h"
+#include "../utils/gettext.h"
+
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
Window *parent):
Window(title, true, parent)
@@ -32,8 +34,8 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
mTextBox->setOpaque(false);
mTextArea = new ScrollArea(mTextBox);
- gcn::Button *yesButton = new Button("Yes", "yes", this);
- gcn::Button *noButton = new Button("No", "no", this);
+ gcn::Button *yesButton = new Button(_("Yes"), "yes", this);
+ gcn::Button *noButton = new Button(_("No"), "no", this);
mTextArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 1204b203..174d98e7 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -29,6 +29,8 @@
#include "../main.h"
+#include "../utils/gettext.h"
+
namespace {
struct ConnectionActionListener : public gcn::ActionListener
{
@@ -41,9 +43,9 @@ ConnectionDialog::ConnectionDialog():
{
setContentSize(200, 100);
- Button *cancelButton = new Button("Cancel", "cancelButton", &listener);
+ Button *cancelButton = new Button(_("Cancel"), "cancelButton", &listener);
mProgressBar = new ProgressBar(0.0, 200 - 10, 20, 128, 128, 128);
- gcn::Label *label = new gcn::Label("Connecting...");
+ gcn::Label *label = new gcn::Label(_("Connecting..."));
cancelButton->setPosition(5, 100 - 5 - cancelButton->getHeight());
mProgressBar->setPosition(5, cancelButton->getY() - 25);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index f1cbb0da..47ca61df 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -33,10 +33,12 @@
#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
EquipmentWindow::EquipmentWindow(Equipment *equipment):
- Window("Equipment"), mEquipment(equipment)
+ Window(_("Equipment")),
+ mEquipment(equipment)
{
setWindowName("Equipment");
setCloseButton(true);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 621a85d3..8c5edec4 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -37,10 +37,12 @@
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
InventoryWindow::InventoryWindow():
- Window("Inventory")
+ Window(_("Inventory"))
{
setWindowName("Inventory");
setResizable(true);
@@ -49,8 +51,8 @@ InventoryWindow::InventoryWindow():
// If you adjust these defaults, don't forget to adjust the trade window's.
setDefaultSize(115, 25, 322, 200);
- mUseButton = new Button("Use", "use", this);
- mDropButton = new Button("Drop", "drop", this);
+ mUseButton = new Button(_("Use"), "use", this);
+ mDropButton = new Button(_("Drop"), "drop", this);
mItems = new ItemContainer(player_node->getInventory(), 2);
mItems->addSelectionListener(this);
@@ -61,14 +63,14 @@ InventoryWindow::InventoryWindow():
mTotalWeight = toString(player_node->mTotalWeight);
mMaxWeight = toString(player_node->mMaxWeight);
- mItemName = "Name:";
+ mItemName = _("Name:");
mItemNameLabel = new TextBox();
- mItemDescription = "Description:";
+ mItemDescription = _("Description:");
mItemDescriptionLabel = new TextBox();
- mItemEffect = "Effect:";
+ mItemEffect = _("Effect:");
mItemEffectLabel = new TextBox();
- mWeight = "Weight: " + mTotalWeight + " g / " +
- mMaxWeight + " g Slots: " +
+ mWeight = _("Weight: ") + mTotalWeight + " g / " +
+ mMaxWeight + _(" g Slots: ") +
toString(player_node->getInventory()->getNumberOfSlotsUsed()) +
"/" + toString(player_node->getInventory()->getInventorySize());
mWeightLabel = new TextBox();
@@ -105,8 +107,8 @@ void InventoryWindow::logic()
mMaxWeight = toString(player_node->mMaxWeight);
// Adjust widgets
- mWeight = "Weight: " + mTotalWeight + " g / " +
- mMaxWeight + " g Slots: " +
+ mWeight = _("Weight: ") + mTotalWeight + " g / " +
+ mMaxWeight + _(" g Slots: ") +
toString(player_node->getInventory()->getNumberOfSlotsUsed()) +
"/" + toString(player_node->getInventory()->getInventorySize());
@@ -153,21 +155,21 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
// Update name, effect and description
if (!item)
{
- mItemName = "Name:";
+ mItemName = _("Name:");
mItemNameLabel->setTextWrapped(mItemName);
- mItemEffect = "Effect:";
+ mItemEffect = _("Effect:");
mItemEffectLabel->setTextWrapped(mItemEffect);
- mItemDescription = "Description:";
+ mItemDescription = _("Description:");
mItemDescriptionLabel->setTextWrapped(mItemDescription);
}
else
{
const ItemInfo& itemInfo = item->getInfo();
- mItemName = "Name: " + itemInfo.getName();
+ mItemName = _("Name: ") + itemInfo.getName();
mItemNameLabel->setTextWrapped(mItemName);
- mItemEffect = "Effect: " + itemInfo.getEffect();
+ mItemEffect = _("Effect: ") + itemInfo.getEffect();
mItemEffectLabel->setTextWrapped(mItemEffect);
- mItemDescription = "Description: " + itemInfo.getDescription();
+ mItemDescription = _("Description: ") + itemInfo.getDescription();
mItemDescriptionLabel->setTextWrapped(mItemDescription);
}
@@ -182,7 +184,8 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Item *item = mItems->getSelectedItem();
- if (!item) return;
+ if (!item)
+ return;
/* Convert relative to the window coordinates to absolute screen
* coordinates.
@@ -249,14 +252,14 @@ void InventoryWindow::updateButtons()
if (selectedItem && selectedItem->isEquipment())
{
if (selectedItem->isEquipped()) {
- mUseButton->setCaption("Unequip");
+ mUseButton->setCaption(_("Unequip"));
}
else {
- mUseButton->setCaption("Equip");
+ mUseButton->setCaption(_("Equip"));
}
}
else {
- mUseButton->setCaption("Use");
+ mUseButton->setCaption(_("Use"));
}
mUseButton->setEnabled(selectedItem != 0);
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index 4ce8ac6c..191c7b8b 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -28,31 +28,33 @@
#include "../item.h"
#include "../localplayer.h"
+#include "../utils/gettext.h"
+
ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
- Window("Select amount of items to drop.", true, parent),
+ Window("", true, parent),
mItem(item)
{
- // New labels
+ // Integer field
mItemAmountTextBox = new IntTextBox(1);
-
- // New buttons
- Button *minusButton = new Button("-", "Minus", this);
- Button *plusButton = new Button("+", "Plus", this);
- Button *okButton = new Button("Okay", "Drop", this);
- Button *cancelButton = new Button("Cancel", "Cancel", this);
- mItemAmountSlide = new Slider(1.0, mItem->getQuantity());
-
mItemAmountTextBox->setRange(1, mItem->getQuantity());
- mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
- // Set button events Id
+ // Slider
+ mItemAmountSlide = new Slider(1.0, mItem->getQuantity());
mItemAmountSlide->setActionEventId("Slide");
+ mItemAmountSlide->addActionListener(this);
+
+ // Buttons
+ Button *minusButton = new Button("-", "Minus", this);
+ Button *plusButton = new Button("+", "Plus", this);
+ Button *okButton = new Button(_("Ok"), "Drop", this);
+ Button *cancelButton = new Button(_("Cancel"), "Cancel", this);
- // Set position
+ // Set positions
mItemAmountTextBox->setPosition(35, 10);
mItemAmountTextBox->setSize(24, 16);
plusButton->setPosition(60, 5);
minusButton->setPosition(10, 5);
+ mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
mItemAmountSlide->setPosition(10, 35);
okButton->setPosition(10, 50);
cancelButton->setPosition(60, 50);
@@ -65,17 +67,15 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
add(okButton);
add(cancelButton);
- mItemAmountSlide->addActionListener(this);
-
resetAmount();
switch (usage) {
case AMOUNT_TRADE_ADD:
- setCaption("Select amount of items to trade.");
+ setCaption(_("Select amount of items to trade."));
okButton->setActionEventId("AddTrade");
break;
case AMOUNT_ITEM_DROP:
- setCaption("Select amount of items to drop.");
+ setCaption(_("Select amount of items to drop."));
okButton->setActionEventId("Drop");
break;
default:
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index fa47af32..8fd77f44 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -35,6 +35,7 @@
#include "../logindata.h"
#include "../configuration.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
static const int MAX_SERVER_LIST_SIZE = 5;
@@ -43,13 +44,13 @@ static const int LOGIN_DIALOG_HEIGHT = 140;
static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70;
LoginDialog::LoginDialog(LoginData *loginData):
- Window("Login"), mLoginData(loginData)
+ Window(_("Login")), mLoginData(loginData)
{
- gcn::Label *userLabel = new gcn::Label("Name:");
- gcn::Label *passLabel = new gcn::Label("Password:");
- gcn::Label *serverLabel = new gcn::Label("Server:");
- gcn::Label *portLabel = new gcn::Label("Port:");
- gcn::Label *dropdownLabel = new gcn::Label("Recent:");
+ gcn::Label *userLabel = new gcn::Label(_("Name:"));
+ gcn::Label *passLabel = new gcn::Label(_("Password:"));
+ gcn::Label *serverLabel = new gcn::Label(_("Server:"));
+ gcn::Label *portLabel = new gcn::Label(_("Port:"));
+ gcn::Label *dropdownLabel = new gcn::Label(_("Recent:"));
std::vector<std::string> dfltServer;
dfltServer.push_back("www.aethyra.org");
dfltServer.push_back("www.aethyra.org");
@@ -69,10 +70,10 @@ LoginDialog::LoginDialog(LoginData *loginData):
mServerScrollArea,
mServerListBox);
- mKeepCheck = new CheckBox("Keep", mLoginData->remember);
- mOkButton = new Button("OK", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mRegisterButton = new Button("Register", "register", this);
+ mKeepCheck = new CheckBox(_("Keep"), mLoginData->remember);
+ mOkButton = new Button(_("OK"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mRegisterButton = new Button(_("Register"), "register", this);
setContentSize(LOGIN_DIALOG_WIDTH, LOGIN_DIALOG_HEIGHT);
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 56bc48fd..99eaca34 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -27,6 +27,8 @@
#include "menuwindow.h"
#include "windowcontainer.h"
+#include "../utils/gettext.h"
+
extern Window *chatWindow;
extern Window *equipmentWindow;
extern Window *inventoryWindow;
@@ -55,23 +57,23 @@ MenuWindow::MenuWindow():
setTitleBarHeight(0);
// Buttons
- const char *buttonNames[] =
+ static const char *buttonNames[] =
{
- "Chat",
- "Status",
- "Equipment",
- "Inventory",
- "Skills",
- "Shortcut",
- "Emote",
- "Setup",
+ _("Chat"),
+ _("Status"),
+ _("Equipment"),
+ _("Inventory"),
+ _("Skills"),
+ _("Shortcut"),
+ _("Emote"),
+ _("Setup"),
0
};
int x = 0, h = 0;
for (const char **curBtn = buttonNames; *curBtn; curBtn++)
{
- gcn::Button *btn = new Button(*curBtn, *curBtn, &listener);
+ gcn::Button *btn = new Button(gettext(*curBtn), *curBtn, &listener);
btn->setPosition(x, 0);
add(btn);
x += btn->getWidth() + 3;
@@ -92,35 +94,35 @@ void MenuWindowListener::action(const gcn::ActionEvent &event)
{
Window *window = NULL;
- if (event.getId() == "Chat")
+ if (event.getId() == _("Chat"))
{
window = chatWindow;
}
- else if (event.getId() == "Status")
+ else if (event.getId() == _("Status"))
{
window = statusWindow;
}
- else if (event.getId() == "Equipment")
+ else if (event.getId() == _("Equipment"))
{
window = equipmentWindow;
}
- else if (event.getId() == "Inventory")
+ else if (event.getId() == _("Inventory"))
{
window = inventoryWindow;
}
- else if (event.getId() == "Skills")
+ else if (event.getId() == _("Skills"))
{
window = skillDialog;
}
- else if (event.getId() == "Shortcut")
+ else if (event.getId() == _("Shortcut"))
{
window = itemShortcutWindow;
}
- else if (event.getId() == "Emote")
+ else if (event.getId() == _("Emote"))
{
window = smileyWindow;
}
- else if (event.getId() == "Setup")
+ else if (event.getId() == _("Setup"))
{
window = setupWindow;
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index fddd5199..8519b985 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -28,13 +28,15 @@
#include "../resources/image.h"
+#include "../utils/gettext.h"
+
Minimap::Minimap():
- Window("Map"),
+ Window(_("Map")),
mMapImage(NULL),
mProportion(0.5)
{
setCloseButton(true);
- setWindowName("MiniMap");
+ setWindowName(_("MiniMap"));
}
Minimap::~Minimap()
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index b53de828..0570d7a9 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -26,8 +26,10 @@
#include "../npc.h"
+#include "../utils/gettext.h"
+
NpcTextDialog::NpcTextDialog():
- Window("NPC")
+ Window(_("NPC"))
{
setResizable(true);
@@ -38,7 +40,7 @@ NpcTextDialog::NpcTextDialog():
mTextBox->setEditable(false);
scrollArea = new ScrollArea(mTextBox);
- okButton = new Button("OK", "ok", this);
+ okButton = new Button(_("OK"), "ok", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index c17cd4aa..34b5ab41 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -26,8 +26,10 @@
#include "../npc.h"
+#include "../utils/gettext.h"
+
NpcListDialog::NpcListDialog():
- Window("NPC")
+ Window(_("NPC"))
{
setResizable(true);
@@ -36,8 +38,8 @@ NpcListDialog::NpcListDialog():
mItemList = new ListBox(this);
scrollArea = new ScrollArea(mItemList);
- okButton = new Button("OK", "ok", this);
- cancelButton = new Button("Cancel", "cancel", this);
+ okButton = new Button(_("OK"), "ok", this);
+ cancelButton = new Button(_("Cancel"), "cancel", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 421c873e..ad7b879c 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -23,6 +23,8 @@
#include <guichan/font.hpp>
+#include "../utils/gettext.h"
+
OkDialog::OkDialog(const std::string &title, const std::string &msg,
Window *parent):
Window(title, true, parent)
@@ -32,7 +34,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
mTextBox->setOpaque(false);
mTextArea = new ScrollArea(mTextBox);
- okButton = new Button("Ok", "ok", this);
+ okButton = new Button(_("Ok"), "ok", this);
mTextArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index c0feb68d..2b2eb625 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -43,6 +43,9 @@
#include "../resources/itemdb.h"
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+
extern std::string tradePartnerName;
PopupMenu::PopupMenu():
@@ -75,35 +78,35 @@ void PopupMenu::showPopup(int x, int y, Being *being)
// Players can be traded with. Later also attack, follow and
// add as buddy will be options in this menu.
const std::string &name = mBeing->getName();
- mBrowserBox->addRow("@@trade|Trade With " + name + "@@");
- mBrowserBox->addRow("@@attack|Attack " + name + "@@");
+ mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@");
+ mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@");
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name)) {
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow("@@friend|Befriend " + name + "@@");
+ mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@");
case PlayerRelation::FRIEND:
- mBrowserBox->addRow("@@disregard|Disregard " + name + "@@");
- mBrowserBox->addRow("@@ignore|Ignore " + name + "@@");
+ mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@");
+ mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@");
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow("@@unignore|Un-Ignore " + name + "@@");
- mBrowserBox->addRow("@@ignore|Completely ignore " + name + "@@");
+ mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
+ mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@");
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow("@@unignore|Un-Ignore " + name + "@@");
+ mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
break;
}
- //mBrowserBox->addRow("@@follow|Follow " + name + "@@");
- //mBrowserBox->addRow("@@buddy|Add " + name + " to Buddy List@@");
+ //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@");
+ //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@party-invite|Invite " + name +
+ mBrowserBox->addRow(_("@@party-invite|Invite ") + name +
" to party@@");
}
break;
@@ -111,7 +114,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case Being::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow("@@talk|Talk To NPC@@");
+ mBrowserBox->addRow(_("@@talk|Talk To NPC@@"));
break;
default:
@@ -121,7 +124,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
//browserBox->addRow("@@look|Look To@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
@@ -133,11 +136,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
// Floor item can be picked up (single option, candidate for removal)
std::string name = ItemDB::get(mFloorItem->getItemId()).getName();
- mBrowserBox->addRow("@@pickup|Pick Up " + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@pickup|Pick Up %s@@"), name.c_str()));
//browserBox->addRow("@@look|Look To@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
@@ -285,18 +288,18 @@ void PopupMenu::showPopup(int x, int y, Item *item)
if (item->isEquipment())
{
- if (item->isEquipped())
- mBrowserBox->addRow("@@use|Unequip@@");
- else
- mBrowserBox->addRow("@@use|Equip@@");
+ if (item->isEquipped())
+ mBrowserBox->addRow(_("@@use|Unequip@@"));
+ else
+ mBrowserBox->addRow(_("@@use|Equip@@"));
}
else
- mBrowserBox->addRow("@@use|Use@@");
+ mBrowserBox->addRow(_("@@use|Use@@"));
- mBrowserBox->addRow("@@drop|Drop@@");
- mBrowserBox->addRow("@@description|Description@@");
+ mBrowserBox->addRow(_("@@drop|Drop@@"));
+ mBrowserBox->addRow(_("@@description|Description@@"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index ec6a9756..5d687425 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -40,6 +40,9 @@
#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+
void
WrongDataNoticeListener::setTarget(gcn::TextField *textField)
{
@@ -56,25 +59,24 @@ WrongDataNoticeListener::action(const gcn::ActionEvent &event)
}
RegisterDialog::RegisterDialog(LoginData *loginData):
- Window("Register"),
+ Window(_("Register")),
mWrongDataNoticeListener(new WrongDataNoticeListener()),
mLoginData(loginData)
{
- gcn::Label *userLabel = new gcn::Label("Name:");
- gcn::Label *passwordLabel = new gcn::Label("Password:");
- gcn::Label *confirmLabel = new gcn::Label("Confirm:");
- gcn::Label *serverLabel = new gcn::Label("Server:");
- gcn::Label *portLabel = new gcn::Label("Port:");
-
+ gcn::Label *userLabel = new gcn::Label(_("Name:"));
+ gcn::Label *passwordLabel = new gcn::Label(_("Password:"));
+ gcn::Label *confirmLabel = new gcn::Label(_("Confirm:"));
+ gcn::Label *serverLabel = new gcn::Label(_("Server:"));
+ gcn::Label *portLabel = new gcn::Label(_("Port:"));
mUserField = new TextField(loginData->username);
mPasswordField = new PasswordField(loginData->password);
mConfirmField = new PasswordField();
mServerField = new TextField(loginData->hostname);
mPortField = new TextField(toString(loginData->port));
- mMaleButton = new RadioButton("Male", "sex", true);
- mFemaleButton = new RadioButton("Female", "sex", false);
- mRegisterButton = new Button("Register", "register", this);
- mCancelButton = new Button("Cancel", "cancel", this);
+ mMaleButton = new RadioButton(_("Male"), "sex", true);
+ mFemaleButton = new RadioButton(_("Female"), "sex", false);
+ mRegisterButton = new Button(_("Register"), "register", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
const int WIDTH = 220;
const int HEIGHT = 170;
@@ -181,47 +183,47 @@ RegisterDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "register" && canSubmit())
{
const std::string user = mUserField->getText();
- logger->log("RegisterDialog::register Username is %s", user.c_str());
+ logger->log(_("RegisterDialog::register Username is %s"), user.c_str());
- std::stringstream errorMsg;
+ std::string errorMsg;
int error = 0;
if (user.length() < LEN_MIN_USERNAME)
{
// Name too short
- errorMsg << "The username needs to be at least "
- << LEN_MIN_USERNAME
- << " characters long.";
+ errorMsg = strprintf
+ (_("The username needs to be at least %d characters long."),
+ LEN_MIN_USERNAME);
error = 1;
}
else if (user.length() > LEN_MAX_USERNAME - 1 )
{
// Name too long
- errorMsg << "The username needs to be less than "
- << LEN_MAX_USERNAME
- << " characters long.";
+ errorMsg = strprintf
+ (_("The username needs to be less than %d characters long."),
+ LEN_MAX_USERNAME);
error = 1;
}
else if (mPasswordField->getText().length() < LEN_MIN_PASSWORD)
{
// Pass too short
- errorMsg << "The password needs to be at least "
- << LEN_MIN_PASSWORD
- << " characters long.";
+ errorMsg = strprintf
+ (_("The password needs to be at least %d characters long."),
+ LEN_MIN_PASSWORD);
error = 2;
}
else if (mPasswordField->getText().length() > LEN_MAX_PASSWORD - 1 )
{
// Pass too long
- errorMsg << "The password needs to be less than "
- << LEN_MAX_PASSWORD
- << " characters long.";
+ errorMsg = strprintf
+ (_("The password needs to be less than %d characters long."),
+ LEN_MAX_PASSWORD);
error = 2;
}
else if (mPasswordField->getText() != mConfirmField->getText())
{
// Password does not match with the confirmation one
- errorMsg << "Passwords do not match.";
+ errorMsg = _("Passwords do not match.");
error = 2;
}
@@ -240,8 +242,8 @@ RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *mWrongRegisterNotice = new OkDialog("Error",
- errorMsg.str());
+ OkDialog *mWrongRegisterNotice =
+ new OkDialog(_("Error"), errorMsg);
mWrongRegisterNotice->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 63af1aaa..567fa59c 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -38,10 +38,12 @@
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
SellDialog::SellDialog(Network *network):
- Window("Sell"),
+ Window(_("Sell")),
mNetwork(network),
mMaxItems(0), mAmountItems(0)
{
@@ -57,13 +59,14 @@ SellDialog::SellDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label("Money: 0 GP / Total: 0 GP");
+ mMoneyLabel = new gcn::Label(
+ strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
- mSellButton = new Button("Sell", "sell", this);
- mQuitButton = new Button("Quit", "quit", this);
- mItemDescLabel = new gcn::Label("Description:");
- mItemEffectLabel = new gcn::Label("Effect:");
+ mSellButton = new Button(_("Sell"), "sell", this);
+ mQuitButton = new Button(_("Quit"), "quit", this);
+ mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), ""));
mIncreaseButton->setSize(20, 20);
mDecreaseButton->setSize(20, 20);
@@ -260,14 +263,19 @@ void SellDialog::setMoney(int amount)
mShopItemList->setPlayersMoney(amount);
}
-void
-SellDialog::updateButtonsAndLabels()
+void SellDialog::updateButtonsAndLabels()
{
int selectedItem = mShopItemList->getSelected();
int income = 0;
if (selectedItem > -1)
{
+ const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
+ mItemDescLabel->setCaption
+ (strprintf(_("Description: %s"), info.getDescription().c_str()));
+ mItemEffectLabel->setCaption
+ (strprintf(_("Effect: %s"), info.getEffect().c_str()));
+
mMaxItems = mShopItems->at(selectedItem)->getQuantity();
if (mAmountItems > mMaxItems)
{
@@ -275,17 +283,13 @@ SellDialog::updateButtonsAndLabels()
}
income = mAmountItems * mShopItems->at(selectedItem)->getPrice();
-
- const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
- mItemDescLabel->setCaption("Description: " + info.getDescription());
- mItemEffectLabel->setCaption("Effect: " + info.getEffect());
}
else
{
+ mItemDescLabel->setCaption(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), ""));
mMaxItems = 0;
mAmountItems = 0;
- mItemDescLabel->setCaption("Description:");
- mItemEffectLabel->setCaption("Effect:");
}
// Update Buttons and slider
@@ -295,8 +299,8 @@ SellDialog::updateButtonsAndLabels()
mSlider->setEnabled(mMaxItems > 1);
// Update the quantity and money labels
- mQuantityLabel->setCaption(
- toString(mAmountItems) + " / " + toString(mMaxItems));
- mMoneyLabel->setCaption("Money: " + toString(income) + " GP / Total: "
- + toString(mPlayerMoney + income) + " GP");
+ mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
+ mMoneyLabel->setCaption
+ (strprintf(_("Price: %d GP / Total: %d GP"),
+ income, mPlayerMoney + income));
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index a61d3bb2..73023eba 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -33,6 +33,7 @@
#include "tabbedcontainer.h"
#include "../utils/dtor.h"
+#include "../utils/gettext.h"
extern Window *chatWindow;
extern Window *equipmentWindow;
@@ -52,19 +53,19 @@ Setup::Setup():
int height = 310;
setContentSize(width, height);
- const char *buttonNames[] = {
- "Apply", "Cancel", "Reset Windows", 0
+ static const char *buttonNames[] = {
+ N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0
};
int x = width;
for (const char **curBtn = buttonNames; *curBtn; ++curBtn)
{
- Button *btn = new Button(*curBtn, *curBtn, this);
+ Button *btn = new Button(gettext(*curBtn), *curBtn, this);
x -= btn->getWidth() + 5;
btn->setPosition(x, height - btn->getHeight() - 5);
add(btn);
// Disable this button when the windows aren't created yet
- if (!strcmp(*curBtn, "Reset Windows"))
+ if (!strcmp(*curBtn, _("Reset Windows")))
btn->setEnabled(statusWindow != NULL);
}
@@ -75,27 +76,27 @@ Setup::Setup():
SetupTab *tab;
tab = new Setup_Video();
- panel->addTab(tab, "Video");
+ panel->addTab(tab, _("Video"));
mTabs.push_back(tab);
tab = new Setup_Audio();
- panel->addTab(tab, "Audio");
+ panel->addTab(tab, _("Audio"));
mTabs.push_back(tab);
tab = new Setup_Joystick();
- panel->addTab(tab, "Joystick");
+ panel->addTab(tab, _("Joystick"));
mTabs.push_back(tab);
tab = new Setup_Keyboard();
- panel->addTab(tab, "Keyboard");
+ panel->addTab(tab, _("Keyboard"));
mTabs.push_back(tab);
tab = new Setup_Colours();
- panel->addTab(tab, "Colours");
+ panel->addTab(tab, _("Colours"));
mTabs.push_back(tab);
tab = new Setup_Players();
- panel->addTab(tab, "Players");
+ panel->addTab(tab, _("Players"));
mTabs.push_back(tab);
add(panel);
@@ -110,17 +111,17 @@ Setup::~Setup()
void Setup::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "Apply")
+ if (event.getId() == _("Apply"))
{
setVisible(false);
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply));
}
- else if (event.getId() == "Cancel")
+ else if (event.getId() == _("Cancel"))
{
setVisible(false);
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
}
- else if (event.getId() == "Reset Windows")
+ else if (event.getId() == _("Reset Windows"))
{
// Bail out if this action happens to be activated before the windows
// are created (though it should be disabled then)
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 70b34a31..bb824f33 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -30,18 +30,20 @@
#include "../log.h"
#include "../sound.h"
+#include "../utils/gettext.h"
+
Setup_Audio::Setup_Audio():
mMusicVolume((int)config.getValue("musicVolume", 60)),
mSfxVolume((int)config.getValue("sfxVolume", 100)),
mSoundEnabled(config.getValue("sound", 0)),
- mSoundCheckBox(new CheckBox("Sound", mSoundEnabled)),
+ mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mSfxSlider(new Slider(0, 128)),
mMusicSlider(new Slider(0, 128))
{
setOpaque(false);
- gcn::Label *sfxLabel = new gcn::Label("Sfx volume");
- gcn::Label *musicLabel = new gcn::Label("Music volume");
+ gcn::Label *sfxLabel = new gcn::Label(_("Sfx volume"));
+ gcn::Label *musicLabel = new gcn::Label(_("Music volume"));
mSfxSlider->setActionEventId("sfx");
mMusicSlider->setActionEventId("music");
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 723d0597..b55ccb7e 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -28,12 +28,14 @@
#include "../configuration.h"
#include "../joystick.h"
+#include "../utils/gettext.h"
+
extern Joystick *joystick;
Setup_Joystick::Setup_Joystick():
- mCalibrateLabel(new gcn::Label("Press the button to start calibration")),
- mCalibrateButton(new Button("Calibrate", "calibrate", this)),
- mJoystickEnabled(new CheckBox("Enable joystick"))
+ mCalibrateLabel(new gcn::Label(_("Press the button to start calibration"))),
+ mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
+ mJoystickEnabled(new CheckBox(_("Enable joystick")))
{
setOpaque(false);
mJoystickEnabled->setPosition(10, 10);
@@ -63,13 +65,13 @@ void Setup_Joystick::action(const gcn::ActionEvent &event)
else
{
if (joystick->isCalibrating()) {
- mCalibrateButton->setCaption("Calibrate");
- mCalibrateLabel->setCaption(
- "Press the button to start calibration");
+ mCalibrateButton->setCaption(_("Calibrate"));
+ mCalibrateLabel->setCaption
+ (_("Press the button to start calibration"));
joystick->finishCalibration();
} else {
- mCalibrateButton->setCaption("Stop");
- mCalibrateLabel->setCaption("Rotate the stick");
+ mCalibrateButton->setCaption(_("Stop"));
+ mCalibrateLabel->setCaption(_("Rotate the stick"));
joystick->startCalibration();
}
}
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 2e620095..f53a9716 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -42,6 +42,7 @@
#include "../main.h"
#include "../particle.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
extern Graphics *graphics;
@@ -109,13 +110,13 @@ Setup_Video::Setup_Video():
mFps((int) config.getValue("fpslimit", 0)),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
- mFsCheckBox(new CheckBox("Full screen", mFullScreenEnabled)),
- mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)),
- mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)),
- mParticleEffectsCheckBox(new CheckBox("Particle effects", mParticleEffectsEnabled)),
- mSpeechBubbleCheckBox(new CheckBox("Speech bubbles", mSpeechBubbleEnabled)),
+ mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
+ mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
+ mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)),
+ mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), mParticleEffectsEnabled)),
+ mSpeechBubbleCheckBox(new CheckBox(_("Speech bubbles"), mSpeechBubbleEnabled)),
mAlphaSlider(new Slider(0.2, 1.0)),
- mFpsCheckBox(new CheckBox("FPS Limit: ")),
+ mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
mFpsSlider(new Slider(10, 200)),
mFpsField(new TextField),
mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 16)),
@@ -134,7 +135,7 @@ Setup_Video::Setup_Video():
setOpaque(false);
ScrollArea *scrollArea = new ScrollArea(mModeList);
- gcn::Label *alphaLabel = new gcn::Label("Gui opacity");
+ gcn::Label *alphaLabel = new gcn::Label(_("Gui opacity"));
mModeList->setEnabled(true);
#ifndef USE_OPENGL
@@ -199,7 +200,7 @@ Setup_Video::Setup_Video():
mParticleDetailField->addKeyListener(this);
mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 140, 75, 10));
- gcn::Label *scrollRadiusLabel = new gcn::Label("Scroll radius");
+ gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius"));
scrollRadiusLabel->setPosition(90, 140);
mScrollRadiusField->setPosition(mFpsField->getX(), 140);
mScrollRadiusField->setWidth(30);
@@ -207,7 +208,7 @@ Setup_Video::Setup_Video():
mScrollRadiusSlider->setValue(mOriginalScrollRadius);
mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 160, 75, 10));
- gcn::Label *scrollLazinessLabel = new gcn::Label("Scroll laziness");
+ gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness"));
scrollLazinessLabel->setPosition(90, 160);
mScrollLazinessField->setPosition(mFpsField->getX(), 160);
mScrollLazinessField->setWidth(30);
@@ -215,42 +216,42 @@ Setup_Video::Setup_Video():
mScrollLazinessSlider->setValue(mOriginalScrollLaziness);
mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 180, 75, 10));
- gcn::Label *overlayDetailLabel = new gcn::Label("Ambient FX");
+ gcn::Label *overlayDetailLabel = new gcn::Label(_("Ambient FX"));
overlayDetailLabel->setPosition(90, 180);
mOverlayDetailField->setPosition(180, 180);
mOverlayDetailField->setWidth(30);
switch (mOverlayDetail)
{
case 0:
- mOverlayDetailField->setCaption("off");
+ mOverlayDetailField->setCaption(_("off"));
break;
case 1:
- mOverlayDetailField->setCaption("low");
+ mOverlayDetailField->setCaption(_("low"));
break;
case 2:
- mOverlayDetailField->setCaption("high");
+ mOverlayDetailField->setCaption(_("high"));
break;
}
mOverlayDetailSlider->setValue(mOverlayDetail);
mParticleDetailSlider->setDimension(gcn::Rectangle(10, 200, 75, 10));
- gcn::Label *particleDetailLabel = new gcn::Label("Particle Detail");
+ gcn::Label *particleDetailLabel = new gcn::Label(_("Particle Detail"));
particleDetailLabel->setPosition(90, 200);
mParticleDetailField->setPosition(180, 200);
mParticleDetailField->setWidth(60);
switch (mParticleDetail)
{
case 0:
- mParticleDetailField->setCaption("low");
+ mParticleDetailField->setCaption(_("low"));
break;
case 1:
- mParticleDetailField->setCaption("medium");
+ mParticleDetailField->setCaption(_("medium"));
break;
case 2:
- mParticleDetailField->setCaption("high");
+ mParticleDetailField->setCaption(_("high"));
break;
case 3:
- mParticleDetailField->setCaption("max");
+ mParticleDetailField->setCaption(_("max"));
break;
}
mParticleDetailSlider->setValue(mParticleDetail);
@@ -309,17 +310,17 @@ void Setup_Video::apply()
if (!graphics->setFullscreen(fullscreen))
{
std::stringstream error;
- error << "Failed to switch to " <<
- (fullscreen ? "windowed" : "fullscreen") <<
- "mode and restoration of old mode also failed!" <<
+ error << _("Failed to switch to ") <<
+ (fullscreen ? _("windowed") : _("fullscreen")) <<
+ _("mode and restoration of old mode also failed!") <<
std::endl;
logger->error(error.str());
}
}
#ifdef WIN32
} else {
- new OkDialog("Switching to full screen",
- "Restart needed for changes to take effect.");
+ new OkDialog(_("Switching to full screen"),
+ _("Restart needed for changes to take effect."));
}
#endif
config.setValue("screen", fullscreen ? 1 : 0);
@@ -331,8 +332,8 @@ void Setup_Video::apply()
config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0);
// OpenGL can currently only be changed by restarting, notify user.
- new OkDialog("Changing OpenGL",
- "Applying change to OpenGL requires restart.");
+ new OkDialog(_("Changing OpenGL"),
+ _("Applying change to OpenGL requires restart."));
}
// FPS change
@@ -405,8 +406,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
// Try to set the desired video mode
if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
{
- std::cerr << "Couldn't set "
- << width << "x" << height << "x" << bpp << " video mode: "
+ std::cerr << _("Couldn't set ")
+ << width << "x" << height << "x" << bpp << _(" video mode: ")
<< SDL_GetError() << std::endl;
exit(1);
}
@@ -417,8 +418,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
graphics->updateScreen();
// TODO: Find out why the drawing area doesn't resize without a restart.
- new OkDialog("Screen resolution changed",
- "Restart your client for the change to take effect.");
+ new OkDialog(_("Screen resolution changed"),
+ _("Restart your client for the change to take effect."));
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
@@ -436,8 +437,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("particleeffects",
mParticleEffectsCheckBox->isSelected() ? 1 : 0);
- new OkDialog("Particle effect settings changed",
- "Restart your client or change maps for the change to take effect.");
+ new OkDialog(_("Particle effect settings changed"),
+ _("Restart your client or change maps for the change to take effect."));
}
else if (event.getId() == "speechbubble")
{
@@ -467,13 +468,13 @@ void Setup_Video::action(const gcn::ActionEvent &event)
switch (val)
{
case 0:
- mOverlayDetailField->setCaption("off");
+ mOverlayDetailField->setCaption(_("off"));
break;
case 1:
- mOverlayDetailField->setCaption("low");
+ mOverlayDetailField->setCaption(_("low"));
break;
case 2:
- mOverlayDetailField->setCaption("high");
+ mOverlayDetailField->setCaption(_("high"));
break;
}
config.setValue("OverlayDetail", val);
@@ -484,16 +485,16 @@ void Setup_Video::action(const gcn::ActionEvent &event)
switch (val)
{
case 0:
- mParticleDetailField->setCaption("low");
+ mParticleDetailField->setCaption(_("low"));
break;
case 1:
- mParticleDetailField->setCaption("medium");
+ mParticleDetailField->setCaption(_("medium"));
break;
case 2:
- mParticleDetailField->setCaption("high");
+ mParticleDetailField->setCaption(_("high"));
break;
case 3:
- mParticleDetailField->setCaption("max");
+ mParticleDetailField->setCaption(_("max"));
break;
}
config.setValue("particleEmitterSkip", 3 - val);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index bae8daa6..4546cd9e 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -41,6 +41,8 @@
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
TradeWindow::TradeWindow(Network *network):
@@ -56,10 +58,10 @@ TradeWindow::TradeWindow(Network *network):
setMinWidth(342);
setMinHeight(209);
- mAddButton = new Button("Add", "add", this);
- mOkButton = new Button("Ok", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mTradeButton = new Button("Trade", "trade", this);
+ mAddButton = new Button(_("Add"), "add", this);
+ mOkButton = new Button(_("Ok"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mTradeButton = new Button(_("Trade"), "trade", this);
mMyItemContainer = new ItemContainer(mMyInventory.get(), 2);
mMyItemContainer->addSelectionListener(this);
@@ -75,8 +77,8 @@ TradeWindow::TradeWindow(Network *network):
mPartnerScroll = new ScrollArea(mPartnerItemContainer);
mPartnerScroll->setPosition(8, 64);
- mMoneyLabel = new gcn::Label("You get: 0 GP");
- mMoneyLabel2 = new gcn::Label("You give:");
+ mMoneyLabel = new gcn::Label(strprintf(_("You get %d GP."), 0));
+ mMoneyLabel2 = new gcn::Label(_("You give:"));
mMoneyField = new TextField;
mMoneyField->setWidth(50);
@@ -87,8 +89,9 @@ TradeWindow::TradeWindow(Network *network):
mTradeButton->setEnabled(false);
- mItemNameLabel = new gcn::Label("Name:");
- mItemDescriptionLabel = new gcn::Label("Description:");
+ mItemNameLabel = new gcn::Label(strprintf(_("Name: %s"), ""));
+ mItemDescriptionLabel = new gcn::Label(
+ strprintf(_("Description: %s"), ""));
add(mMyScroll);
add(mPartnerScroll);
@@ -150,7 +153,7 @@ void TradeWindow::widgetResized(const gcn::Event &event)
void TradeWindow::addMoney(int amount)
{
- mMoneyLabel->setCaption("You get: " + toString(amount) + " GP");
+ mMoneyLabel->setCaption(strprintf(_("You get %d GP."), amount));
mMoneyLabel->adjustSize();
}
@@ -198,7 +201,7 @@ void TradeWindow::reset()
mOkButton->setEnabled(true);
mOkOther = false;
mOkMe = false;
- mMoneyLabel->setCaption("You get: 0 GP");
+ mMoneyLabel->setCaption(strprintf(_("You get %d GP."), 0));
mMoneyField->setEnabled(true);
mMoneyField->setText("");
}
@@ -257,21 +260,11 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
}
// Update name and description
- if (!item)
- {
- mItemNameLabel->setCaption("Name:");
- mItemDescriptionLabel->setCaption("Description:");
- }
- else
- {
- std::string SomeText;
- SomeText = "Name: " + item->getInfo().getName();
- mItemNameLabel->setCaption(SomeText);
- mItemNameLabel->adjustSize();
- SomeText = "Description: " + item->getInfo().getDescription();
- mItemDescriptionLabel->setCaption(SomeText);
- mItemDescriptionLabel->adjustSize();
- }
+ ItemInfo const *info = item ? &item->getInfo() : NULL;
+ mItemNameLabel->setCaption(strprintf(_("Name: %s"),
+ info ? info->getName().c_str() : ""));
+ mItemDescriptionLabel->setCaption(strprintf(_("Description: %s"),
+ info ? info->getDescription().c_str() : ""));
}
void TradeWindow::action(const gcn::ActionEvent &event)