From 827f91446c550fdf066cb9bec1d6b15ae8662b78 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 Jan 2011 04:52:43 +0200 Subject: Add gettext to missing strings. Update POTFILES.in and update russian translation. --- src/gui/charselectdialog.cpp | 2 +- src/gui/login.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index d95930108..da1f59e46 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -433,7 +433,7 @@ void CharacterDisplay::update() mButton->setCaption(_("Choose")); mButton->setActionEventId("use"); mName->setCaption(strprintf("%s", character->getName().c_str())); - mLevel->setCaption(strprintf("Level %d", + mLevel->setCaption(strprintf(_("Level %d"), mCharacter->data.mAttributes[LEVEL])); mMoney->setCaption(Units::formatCurrency( mCharacter->data.mAttributes[MONEY])); diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 997895c95..b6139c6d0 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -53,9 +53,9 @@ std::string LoginDialog::savedPasswordKey = ""; const char *UPDATE_TYPE_TEXT[3] = { - _("Normal"), - _("Auto Close"), - _("Skip"), + N_("Normal"), + N_("Auto Close"), + N_("Skip"), }; class UpdateTypeModel : public gcn::ListModel @@ -74,7 +74,7 @@ public: if (i >= getNumberOfElements() || i < 0) return _("???"); - return UPDATE_TYPE_TEXT[i]; + return gettext(UPDATE_TYPE_TEXT[i]); } }; -- cgit v1.2.3-70-g09d2 From 1c49a83df05dbf6837687e1bfc5b142a680144ed Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 Jan 2011 22:56:42 +0200 Subject: Add hp bar to local player. --- src/being.cpp | 46 ++++++++++++++++++++++++++-------------------- src/being.h | 3 ++- src/defaults.cpp | 1 + src/gui/setup_colors.cpp | 2 ++ src/gui/setup_other.cpp | 17 ++++++++++++++++- src/gui/setup_other.h | 3 +++ src/gui/userpalette.cpp | 5 +++++ src/gui/userpalette.h | 2 ++ 8 files changed, 57 insertions(+), 22 deletions(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index 3a9285750..2372cfe1b 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -169,6 +169,7 @@ bool Being::mLowTraffic = true; bool Being::mDrawHotKeys = true; bool Being::mShowBattleEvents = false; bool Being::mShowMobHP = false; +bool Being::mShowOwnHP = false; std::list beingInfoCache; @@ -1551,6 +1552,7 @@ void Being::reReadConfig() mDrawHotKeys = config.getBoolValue("drawHotKeys"); mShowBattleEvents = config.getBoolValue("showBattleEvents"); mShowMobHP = config.getBoolValue("showMobHP"); + mShowOwnHP = config.getBoolValue("showOwnHP"); mUpdateConfigTime = cur_time; } @@ -1745,42 +1747,48 @@ bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const 2 * attackRange + 32, 2 * attackRange + 32)); } - if (mShowMobHP && player_node && player_node->getTarget() == this + if (mShowMobHP && mInfo && player_node && player_node->getTarget() == this && getType() == MONSTER) { // show hp bar here - drawHpBar(graphics, x - 50 + 16, y + 32 - 6, 2 * 50, 4); + int maxHP = mMaxHP; + if (!maxHP) + maxHP = mInfo->getMaxHP(); + + drawHpBar(graphics, maxHP, mHP, mDamageTaken, + UserPalette::MONSTER_HP, UserPalette::MONSTER_HP2, + x - 50 + 16, y + 32 - 6, 2 * 50, 4); + } + if (mShowOwnHP && player_node == this) + { + drawHpBar(graphics, PlayerInfo::getAttribute(MAX_HP), + PlayerInfo::getAttribute(HP), 0, + UserPalette::PLAYER_HP, UserPalette::PLAYER_HP2, + x - 50 + 16, y + 32 - 6, 2 * 50, 4); } return res; } -void Being::drawHpBar(Graphics *graphics, int x, int y, +void Being::drawHpBar(Graphics *graphics, int maxHP, int hp, int damage, + int color1, int color2, int x, int y, int width, int height) const { - if (!mInfo) - return; - - int maxHP = mMaxHP; - - if (!maxHP) - maxHP = mInfo->getMaxHP(); - if (maxHP <= 0) return; - if (!mHP && maxHP < mHP) + if (!hp && maxHP < hp) return; float p; - if (mHP) + if (hp) { - p = static_cast(maxHP) / static_cast(mHP); + p = static_cast(maxHP) / static_cast(hp); } - else if (maxHP != mDamageTaken) + else if (maxHP != damage) { p = static_cast(maxHP) - / static_cast(maxHP - mDamageTaken); + / static_cast(maxHP - damage); } else { @@ -1792,8 +1800,7 @@ void Being::drawHpBar(Graphics *graphics, int x, int y, int dx = width / p; - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::MONSTER_HP)); + graphics->setColor(userPalette->getColorWithAlpha(color1)); graphics->fillRectangle(gcn::Rectangle( x, y, dx, height)); @@ -1801,8 +1808,7 @@ void Being::drawHpBar(Graphics *graphics, int x, int y, if (width - dx <= 0) return; - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::MONSTER_HP2)); + graphics->setColor(userPalette->getColorWithAlpha(color2)); graphics->fillRectangle(gcn::Rectangle( x + dx, y, width - dx, height)); diff --git a/src/being.h b/src/being.h index 09466f5af..f9731366a 100644 --- a/src/being.h +++ b/src/being.h @@ -520,6 +520,7 @@ class Being : public ActorSprite, public ConfigListener int posX, int posY) const; void drawHpBar(Graphics *graphics, int x, int y, + int maxHP, int hp, int damage, int color1, int color2, int width, int height) const; static void load(); @@ -751,7 +752,7 @@ class Being : public ActorSprite, public ConfigListener static bool mDrawHotKeys; static bool mShowBattleEvents; static bool mShowMobHP; -// std::string mDisplayName; + static bool mShowOwnHP; unsigned int mMoveTime; unsigned int mAttackTime; diff --git a/src/defaults.cpp b/src/defaults.cpp index 916c20398..190c1816c 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -189,6 +189,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "enableBattleTab", false); AddDEF(configData, "showBattleEvents", false); AddDEF(configData, "showMobHP", true); + AddDEF(configData, "showOwnHP", true); return configData; } diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 76510a283..68d517cae 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -302,6 +302,8 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event _UNUSED_) case UserPalette::ROAD_POINT: case UserPalette::MONSTER_HP: case UserPalette::MONSTER_HP2: + case UserPalette::PLAYER_HP: + case UserPalette::PLAYER_HP2: mGradDelayLabel->setCaption(_("Alpha:")); mGradDelayText->setRange(0, 255); mGradDelaySlider->setScale(0, 255); diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index 54ec1c65d..5a2b77a81 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -63,6 +63,7 @@ #define ACTION_WARP_PARTICLE "warp particle" #define ACTION_AUTO_SHOP "auto shop" #define ACTION_SHOW_MOB_HP "show mob hp" +#define ACTION_SHOW_OWN_HP "show own hp" Setup_Other::Setup_Other(): mShowMonstersTakedDamage(config.getBoolValue("showMonstersTakedDamage")), @@ -87,7 +88,8 @@ Setup_Other::Setup_Other(): mQuickStats(config.getBoolValue("quickStats")), mWarpParticle(config.getBoolValue("warpParticle")), mAutoShop(config.getBoolValue("autoShop")), - mShowMobHP(config.getBoolValue("showMobHP")) + mShowMobHP(config.getBoolValue("showMobHP")), + mShowOwnHP(config.getBoolValue("showOwnHP")) { setName(_("Misc")); @@ -178,6 +180,10 @@ Setup_Other::Setup_Other(): mShowMobHP, this, ACTION_SHOW_MOB_HP); + mShowOwnHPCheckBox = new CheckBox(_("Show own hp bar"), + mShowOwnHP, + this, ACTION_SHOW_OWN_HP); + // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); @@ -192,6 +198,7 @@ Setup_Other::Setup_Other(): place(12, 4, mWarpParticleCheckBox, 10); place(12, 5, mAutoShopCheckBox, 10); place(12, 6, mShowMobHPCheckBox, 10); + place(12, 7, mShowOwnHPCheckBox, 10); place(0, 3, mFloorItemsHighlightCheckBox, 12); place(0, 4, mHighlightAttackRangeCheckBox, 12); place(0, 5, mHighlightMonsterAttackRangeCheckBox, 12); @@ -320,6 +327,10 @@ void Setup_Other::action(const gcn::ActionEvent &event) { mShowMobHP = mShowMobHPCheckBox->isSelected(); } + else if (event.getId() == ACTION_SHOW_OWN_HP) + { + mShowOwnHP = mShowOwnHPCheckBox->isSelected(); + } } void Setup_Other::cancel() @@ -389,6 +400,9 @@ void Setup_Other::cancel() mShowMobHP = config.getBoolValue("showMobHP"); mShowMobHPCheckBox->setSelected(mShowMobHP); + + mShowOwnHP = config.getBoolValue("showOwnHP"); + mShowOwnHPCheckBox->setSelected(mShowOwnHP); } void Setup_Other::apply() @@ -416,6 +430,7 @@ void Setup_Other::apply() config.setValue("warpParticle", mWarpParticle); config.setValue("autoShop", mAutoShop); config.setValue("showMobHP", mShowMobHP); + config.setValue("showOwnHP", mShowOwnHP); logger->setDebugLog(mDebugLog); } diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h index b20401be5..6a092e93f 100644 --- a/src/gui/setup_other.h +++ b/src/gui/setup_other.h @@ -119,6 +119,9 @@ class Setup_Other : public SetupTab, public gcn::ActionListener gcn::CheckBox *mShowMobHPCheckBox; bool mShowMobHP; + gcn::CheckBox *mShowOwnHPCheckBox; + bool mShowOwnHP; + EditDialog *mEditDialog; }; diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 03e5c1eed..46f1b72b3 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -52,6 +52,8 @@ const std::string ColorTypeNames[] = "ColorParticle", "ColorPickupInfo", "ColorExpInfo", + "ColorPlayerHp", + "ColorPlayerHp2", "ColorHitPlayerMonster", "ColorHitMonsterPlayer", "ColorHitPlayerPlayer", @@ -124,6 +126,9 @@ UserPalette::UserPalette(): addColor(PARTICLE, 0xffffff, STATIC, _("Particle Effects")); addColor(PICKUP_INFO, 0x28dc28, STATIC, _("Pickup Notification")); addColor(EXP_INFO, 0xffff00, STATIC, _("Exp Notification")); + addColor(PLAYER_HP, 0x00ff00, STATIC, _("Player HP bar"), 50); + addColor(PLAYER_HP2, 0xff0000, STATIC, + _("Player HP bar (second color)"), 50); addColor(HIT_PLAYER_MONSTER, 0x0064ff, STATIC, _("Player Hits Monster")); addColor(HIT_MONSTER_PLAYER, 0xff3232, STATIC, _("Monster Hits Player")); addColor(HIT_PLAYER_PLAYER, 0xff5050, STATIC, diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 057d47113..db2463e20 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -53,6 +53,8 @@ class UserPalette : public Palette, public gcn::ListModel PARTICLE, PICKUP_INFO, EXP_INFO, + PLAYER_HP, + PLAYER_HP2, HIT_PLAYER_MONSTER, HIT_MONSTER_PLAYER, HIT_PLAYER_PLAYER, -- cgit v1.2.3-70-g09d2 From c674793a8657aa099c9637c92f8696f230c327ca Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 10 Jan 2011 00:07:12 +0200 Subject: Add persistent ip as connection option. Usefull is player using some kind of port mapping. --- src/defaults.cpp | 1 + src/gui/serverdialog.cpp | 18 ++++++++++++------ src/gui/serverdialog.h | 2 ++ src/net/tmwa/charserverhandler.cpp | 10 +++++++++- src/net/tmwa/loginhandler.cpp | 5 ++++- 5 files changed, 28 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/defaults.cpp b/src/defaults.cpp index 190c1816c..da5aa4e84 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -190,6 +190,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "showBattleEvents", false); AddDEF(configData, "showMobHP", true); AddDEF(configData, "showOwnHP", true); + AddDEF(configData, "usePersistentIP", false); return configData; } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index c7e1d0f94..3556efc35 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -211,7 +211,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mDownload(0), mDownloadProgress(-1.0f), mServers(ServerInfos()), - mServerInfo(serverInfo) + mServerInfo(serverInfo), + mPersistentIPCheckBox(false) { if (isSafeMode) setCaption("Choose Your Server *** SAFE MODE ***"); @@ -223,6 +224,9 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): Label *typeLabel = new Label(_("Server type:")); mServerNameField = new TextField(mServerInfo->hostname); mPortField = new TextField(toString(mServerInfo->port)); + mPersistentIPCheckBox = new CheckBox(_("Use same ip for game sub servers"), + config.getBoolValue("usePersistentIP"), + this, "persitent ip"); loadCustomServers(); @@ -264,11 +268,12 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): place(1, 2, mTypeField, 5).setPadding(3); place(0, 3, usedScroll, 6, 5).setPadding(3); place(0, 8, mDescription, 6); - place(0, 9, mManualEntryButton); - place(1, 9, mDeleteButton); - place(2, 9, mLoadButton); - place(4, 9, mQuitButton); - place(5, 9, mConnectButton); + place(0, 9, mPersistentIPCheckBox, 6); + place(0, 10, mManualEntryButton); + place(1, 10, mDeleteButton); + place(2, 10, mLoadButton); + place(4, 10, mQuitButton); + place(5, 10, mConnectButton); // Make sure the list has enough height getLayout().setRowHeight(3, 80); @@ -390,6 +395,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) LoginDialog::savedPassword = ""; } + config.setValue("usePersistentIP", mPersistentIPCheckBox->isSelected()); Client::setState(STATE_CONNECT_SERVER); } } diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index b9a67e246..e16dd09b5 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -23,6 +23,7 @@ #define SERVERDIALOG_H #include "gui/widgets/window.h" +#include "gui/widgets/checkbox.h" #include "net/download.h" #include "net/serverinfo.h" @@ -199,6 +200,7 @@ class ServerDialog : public Window, ServerInfos mServers; ServerInfo *mServerInfo; + CheckBox *mPersistentIPCheckBox; }; #endif diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index e500f667b..4bf9df8b3 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -160,7 +160,15 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setCharId(msg.readInt32()); GameHandler *gh = static_cast(Net::getGameHandler()); gh->setMap(msg.readString(16)); - mapServer.hostname = ipToString(msg.readInt32()); + if (config.getBoolValue("usePersistentIP")) + { + msg.readInt32(); + mapServer.hostname = Client::getServerName(); + } + else + { + mapServer.hostname = ipToString(msg.readInt32()); + } mapServer.port = msg.readInt16(); // Prevent the selected local player from being deleted diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 73fec1322..05a28513c 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -288,7 +288,10 @@ void LoginHandler::chooseServer(unsigned int server) return; charServer.clear(); - charServer.hostname = ipToString(mWorlds[server]->address); + if (config.getBoolValue("usePersistentIP")) + charServer.hostname = Client::getServerName(); + else + charServer.hostname = ipToString(mWorlds[server]->address); charServer.port = mWorlds[server]->port; Client::setState(STATE_UPDATE); -- cgit v1.2.3-70-g09d2