From 1f5f9385fe7383dd5b71baac10b209349f3823ce Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 13 May 2009 15:06:26 -0600 Subject: Fix how the PartyWindow lays out Avatars Also fix the height of Avatars --- src/gui/partywindow.cpp | 21 ++++++++++++++++++++- src/gui/partywindow.h | 2 ++ src/gui/widgets/avatar.cpp | 12 ++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 996073bd..1260a2c3 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -92,9 +92,10 @@ PartyMember *PartyWindow::findOrCreateMember(int id) { member = new PartyMember; mMembers[id] = member; - add(member->avatar, 0, (mMembers.size() - 1) * 14); } + buildLayout(); + return member; } @@ -148,6 +149,8 @@ void PartyWindow::removeMember(int id) void PartyWindow::removeMember(const std::string &name) { removeMember(findMember(name)); + + buildLayout(); } void PartyWindow::updateOnlne(int id, bool online) @@ -225,3 +228,19 @@ void PartyWindow::clearMembers() delete_all(mMembers); mMembers.clear(); } + +void PartyWindow::buildLayout() +{ + clearLayout(); + int lastPos = 0; + + PartyList::iterator it; + PartyMember *member; + + for (it = mMembers.begin(); it != mMembers.end(); it++) + { + member = (*it).second; + add(member->avatar, 0, lastPos); + lastPos += member->avatar->getHeight() + 2; + } +} diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index 8cea500f..19e611ed 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -125,6 +125,8 @@ class PartyWindow : public Window, gcn::ActionListener */ PartyMember *findOrCreateMember(int id); + void buildLayout(); + typedef std::map PartyList; PartyList mMembers; std::string mPartyInviter; diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index 0bbdc468..16c77233 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -42,7 +42,6 @@ Avatar::Avatar(): mMaxHp(0) { setOpaque(false); - setSize(250, 12); if (avatarCount == 0) { @@ -54,12 +53,17 @@ Avatar::Avatar(): avatarStatusOffline->incRef(); avatarStatusOnline->incRef(); - mStatus = new Icon(avatarStatusOffline); - mStatus->setSize(12, 12); - add(mStatus, 1, 0); mLabel = new Label; mLabel->adjustSize(); + + mStatus = new Icon(avatarStatusOffline); + mStatus->setSize(12, 12); + + add(mStatus, 1, (mLabel->getHeight() - 12) / 2); add(mLabel, 16, 0); + + setSize(250, mLabel->getHeight()); + } Avatar::~Avatar() -- cgit v1.2.3-70-g09d2 From 453b42fb59fccf593f88959a9402b4fa96bf219f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 00:07:25 +0200 Subject: Don't apply GUI opacity to the selected value of a DropDown --- src/gui/truetypefont.cpp | 8 ++++---- src/gui/widgets/dropdown.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index 62a27651..e07adc9f 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -19,12 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "gui/truetypefont.h" -#include "truetypefont.h" +#include "graphics.h" +#include "resources/image.h" -#include "../graphics.h" -#include "../resources/image.h" +#include #define CACHE_SIZE 256 diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 491e6396..e838aab6 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -140,15 +140,15 @@ void DropDown::draw(gcn::Graphics* graphics) const int alpha = (int) (mAlpha * 255.0f); gcn::Color faceColor = getBaseColor(); faceColor.a = alpha; - const gcn::Color* highlightColor = &guiPalette->getColor(Palette::HIGHLIGHT, - alpha); + const gcn::Color *highlightColor = + &guiPalette->getColor(Palette::HIGHLIGHT, alpha); gcn::Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; if (mListBox->getListModel() && mListBox->getSelected() >= 0) { graphics->setFont(getFont()); - graphics->setColor(guiPalette->getColor(Palette::TEXT, alpha)); + graphics->setColor(guiPalette->getColor(Palette::TEXT)); graphics->drawText(mListBox->getListModel()->getElementAt(mListBox->getSelected()), 1, 0); } -- cgit v1.2.3-70-g09d2 From ec8f340ce6b16b92a450bb6fcdb4ebd40b54f669 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 00:23:13 +0200 Subject: Fixed handling of messages after a failed login When entering the error state, the handlers were unregistered, but they were never registered again. I'm just removing the unregistration for now. --- src/main.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 2d5899f0..40b30899 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -734,7 +734,6 @@ static void accountLogin(Network *network, LoginData *loginData) logger->log("Username is %s", loginData->username.c_str()); #ifdef EATHENA_SUPPORT network->connect(loginData->hostname, loginData->port); - // network->registerHandler(&loginHandler); #endif #ifdef TMWSERV_SUPPORT @@ -774,7 +773,6 @@ static void charLogin(Network *network, LoginData *loginData) { logger->log("Trying to connect to char server..."); network->connect(loginData->hostname, loginData->port); - // network->registerHandler(&charServerHandler); Net::getCharHandler()->setCharInfo(&charInfo); // Send login infos @@ -1505,7 +1503,6 @@ int main(int argc, char *argv[]) currentDialog->addActionListener(&errorListener); currentDialog = NULL; // OkDialog deletes itself network->disconnect(); - network->clearHandlers(); break; case STATE_CONNECTING: -- cgit v1.2.3-70-g09d2 From b17d406451228fa83f34a858e1d849c09f1a94e5 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 00:44:16 +0200 Subject: Fixed the worst layout issues that came up with translations Video and player setup pages now look a bit better when translated or when the font size is increased. --- src/gui/setup.cpp | 4 ++-- src/gui/setup_audio.cpp | 2 +- src/gui/setup_colors.cpp | 2 +- src/gui/setup_joystick.cpp | 2 +- src/gui/setup_keyboard.cpp | 2 +- src/gui/setup_players.cpp | 4 ++-- src/gui/setup_video.cpp | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index a1765f24..e73f9b74 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -64,7 +64,7 @@ Setup::Setup(): Window(_("Setup")) { setCloseButton(true); - int width = 340; + int width = 380; int height = 360; setContentSize(width, height); @@ -104,7 +104,7 @@ Setup::Setup(): add(panel); Label *version = new Label(FULL_VERSION); - version->setPosition(5, height - version->getHeight() - 5); + version->setPosition(9, height - version->getHeight() - 9); add(version); center(); diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 9417ad68..9da74c2e 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -72,7 +72,7 @@ Setup_Audio::Setup_Audio(): place(0, 2, mMusicSlider); place(1, 2, musicLabel); - setDimension(gcn::Rectangle(0, 0, 325, 280)); + setDimension(gcn::Rectangle(0, 0, 365, 280)); } void Setup_Audio::apply() diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index a0be62cd..efa03ba4 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -176,7 +176,7 @@ Setup_Colors::Setup_Colors() : mGradTypeText->setCaption(""); - setDimension(gcn::Rectangle(0, 0, 325, 280)); + setDimension(gcn::Rectangle(0, 0, 365, 280)); } Setup_Colors::~Setup_Colors() diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 08a80bf7..f050e334 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -55,7 +55,7 @@ Setup_Joystick::Setup_Joystick(): place = h.getPlacer(0, 1); place(0, 0, mCalibrateButton); - setDimension(gcn::Rectangle(0, 0, 325, 75)); + setDimension(gcn::Rectangle(0, 0, 365, 75)); } void Setup_Joystick::action(const gcn::ActionEvent &event) diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 0c15a1ee..938c1c4e 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -98,7 +98,7 @@ Setup_Keyboard::Setup_Keyboard(): place(0, 6, mMakeDefaultButton); place(3, 6, mAssignKeyButton); - setDimension(gcn::Rectangle(0, 0, 325, 280)); + setDimension(gcn::Rectangle(0, 0, 365, 280)); } Setup_Keyboard::~Setup_Keyboard() diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index f0d88a30..6372d318 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -283,15 +283,15 @@ Setup_Players::Setup_Players(): place(0, 0, mPlayerTitleTable, 4); place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2); place(0, 5, mDeleteButton); - place(0, 6, mWhisperTabCheckBox); place(2, 5, ignore_action_label); place(2, 6, mIgnoreActionChoicesBox, 2).setPadding(2); place(2, 7, mDefaultTrading); place(2, 8, mDefaultWhisper); + place(0, 9, mWhisperTabCheckBox, 4).setPadding(4); player_relations.addListener(this); - setDimension(gcn::Rectangle(0, 0, 325, 280)); + setDimension(gcn::Rectangle(0, 0, 365, 280)); } Setup_Players::~Setup_Players() diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 1c4043f7..a9c892b2 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -299,13 +299,13 @@ Setup_Video::Setup_Video(): place(1, 3, mParticleEffectsCheckBox, 3); - place(1, 4, mPickupNotifyLabel, 3); + place(1, 4, mPickupNotifyLabel, 4); place(1, 5, mPickupChatCheckBox, 1); place(2, 5, mPickupParticleCheckBox, 2); place(0, 6, fontSizeLabel, 3); - place(1, 6, mFontSizeDropDown, 3); + place(1, 6, mFontSizeDropDown, 2); place(0, 7, mAlphaSlider); place(1, 7, alphaLabel, 3); @@ -326,7 +326,7 @@ Setup_Video::Setup_Video(): place(1, 11, particleDetailLabel); place(2, 11, mParticleDetailField, 3).setPadding(2); - setDimension(gcn::Rectangle(0, 0, 325, 300)); + setDimension(gcn::Rectangle(0, 0, 365, 300)); } void Setup_Video::apply() -- cgit v1.2.3-70-g09d2 From 2032ca0fb1fd6b59c025180b673e6760d9c12bdc Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 14 May 2009 10:32:17 -0600 Subject: Add QOAL's outfit window --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/game.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/gui/itemcontainer.cpp | 4 +++ src/gui/windowmenu.cpp | 7 ++++- src/keyboardconfig.cpp | 1 + src/keyboardconfig.h | 1 + tmw.cbp | 2 ++ 8 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08110c43..a295f249 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -167,6 +167,8 @@ SET(SRCS gui/npcpostdialog.h gui/okdialog.cpp gui/okdialog.h + gui/outfitwindow.cpp + gui/outfitwindow.h gui/palette.cpp gui/palette.h gui/partywindow.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 47d27ede..a474c963 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -116,6 +116,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/npcpostdialog.h \ gui/okdialog.cpp \ gui/okdialog.h \ + gui/outfitwindow.cpp \ + gui/outfitwindow.h \ gui/palette.cpp \ gui/palette.h \ gui/partywindow.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 59c57607..98985e74 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -57,6 +57,7 @@ #include "gui/ministatus.h" #include "gui/npcdialog.h" #include "gui/okdialog.h" +#include "gui/outfitwindow.h" #include "gui/sdlinput.h" #include "gui/sell.h" #include "gui/setup.h" @@ -138,6 +139,7 @@ HelpWindow *helpWindow; DebugWindow *debugWindow; ShortcutWindow *itemShortcutWindow; ShortcutWindow *emoteShortcutWindow; +OutfitWindow *outfitWindow; BeingManager *beingManager = NULL; FloorItemManager *floorItemManager = NULL; @@ -232,6 +234,7 @@ static void createGuiWindows() new ItemShortcutContainer); emoteShortcutWindow = new ShortcutWindow("EmoteShortcut", new EmoteShortcutContainer); + outfitWindow = new OutfitWindow(); localChatTab = new ChatTab(_("General")); @@ -277,6 +280,7 @@ static void destroyGuiWindows() delete itemShortcutWindow; delete emoteShortcutWindow; delete storageWindow; + delete outfitWindow; } Game::Game(): @@ -606,6 +610,65 @@ void Game::handleInput() } } + if (event.key.keysym.mod & KMOD_RCTRL && !chatWindow->isInputFocused()) + { + switch (event.key.keysym.sym) + { + case SDLK_1: + outfitWindow->wearOutfit(0); + used = true; + break; + + case SDLK_2: + outfitWindow->wearOutfit(1); + used = true; + break; + + case SDLK_3: + outfitWindow->wearOutfit(2); + used = true; + break; + + case SDLK_4: + outfitWindow->wearOutfit(3); + used = true; + break; + + case SDLK_5: + outfitWindow->wearOutfit(4); + used = true; + break; + + case SDLK_6: + outfitWindow->wearOutfit(5); + used = true; + break; + + case SDLK_7: + outfitWindow->wearOutfit(6); + used = true; + break; + + case SDLK_8: + outfitWindow->wearOutfit(7); + used = true; + break; + + case SDLK_9: + outfitWindow->wearOutfit(8); + used = true; + break; + + case SDLK_0: + outfitWindow->wearOutfit(9); + used = true; + break; + + default: + break; + } + } + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); switch (tKey) { @@ -782,6 +845,9 @@ void Game::handleInput() case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: requestedWindow = emoteShortcutWindow; break; + case KeyboardConfig::KEY_WINDOW_OUTFIT: + requestedWindow = outfitWindow; + break; case KeyboardConfig::KEY_SCREENSHOT: // Screenshot (picture, hence the p) saveScreenshot(); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 54aa818b..d8ae6e20 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -23,6 +23,7 @@ #include "gui/chat.h" #include "gui/itempopup.h" +#include "gui/outfitwindow.h" #include "gui/palette.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -162,6 +163,7 @@ void ItemContainer::selectNone() { setSelectedIndex(-1); mSelectionStatus = SEL_NONE; + outfitWindow->setItemSelected(-1); } void ItemContainer::setSelectedIndex(int newIndex) @@ -260,6 +262,8 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) mSelectionStatus = SEL_SELECTING; itemShortcut->setItemSelected(item->getId()); + if (item->isEquipment()) + outfitWindow->setItemSelected(item->getId()); } else { diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 5e33a4ed..d66aa602 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -47,7 +47,7 @@ extern Window *buddyWindow; extern Window *guildWindow; extern Window *magicDialog; #endif - +extern Window *outfitWindow; WindowMenu::WindowMenu(): mEmotePopup(0) @@ -56,6 +56,7 @@ WindowMenu::WindowMenu(): static const char *buttonNames[] = { ":-)", + N_("Outfits"), N_("Status"), N_("Equipment"), N_("Inventory"), @@ -114,6 +115,10 @@ void WindowMenu::action(const gcn::ActionEvent &event) mEmotePopup = 0; } } + else if (event.getId() == "Outfits") + { + window = outfitWindow; + } else if (event.getId() == "Status") { window = statusWindow; diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index b5db3de5..6136f043 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -80,6 +80,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyWindowDebug", SDLK_F10, _("Debug Window")}, {"keyWindowParty", SDLK_F11, _("Party Window")}, {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")}, + {"keyWindowOutfit", SDLK_o, _("Emote Shortcut Window")}, {"keyEmoteShortcut1", SDLK_1, strprintf(_("Emote Shortcut %d"), 1)}, {"keyEmoteShortcut2", SDLK_2, strprintf(_("Emote Shortcut %d"), 2)}, {"keyEmoteShortcut3", SDLK_3, strprintf(_("Emote Shortcut %d"), 3)}, diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index 68a5efa6..b6a07f16 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -191,6 +191,7 @@ class KeyboardConfig KEY_WINDOW_DEBUG, KEY_WINDOW_PARTY, KEY_WINDOW_EMOTE_SHORTCUT, + KEY_WINDOW_OUTFIT, KEY_EMOTE_1, KEY_EMOTE_2, KEY_EMOTE_3, diff --git a/tmw.cbp b/tmw.cbp index 4ab0cebf..c9ac6fb3 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -297,6 +297,8 @@ + + -- cgit v1.2.3-70-g09d2 From b0475c40bb256107aa13919b8d020b172af9d788 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 14 May 2009 10:43:18 -0600 Subject: Make sure to use our hair color file first --- src/resources/colordb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index af498297..12806f8e 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -27,8 +27,8 @@ #include -#define HAIR_COLOR_FILE "colors.xml" -#define TMW_COLOR_FILE "hair.xml" +#define HAIR_COLOR_FILE "hair.xml" +#define AE_COLOR_FILE "colors.xml" namespace { @@ -48,17 +48,17 @@ void ColorDB::load() if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("Trying TMW's color file, %s.", TMW_COLOR_FILE); + logger->log("Trying Aethyra's color file, %s.", AE_COLOR_FILE); TMWHair = true; delete doc; - doc = new XML::Document(TMW_COLOR_FILE); + doc = new XML::Document(AE_COLOR_FILE); root = doc->rootNode(); if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("ColorDB: Failed"); + logger->log("ColorDB: Failed to find any color files."); mColors[0] = mFail; mLoaded = true; -- cgit v1.2.3-70-g09d2 From c316bd0a9ffdbeb85ea80dc3ca2e731062b45c85 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 14 May 2009 11:21:37 -0600 Subject: Add missing windows --- src/gui/outfitwindow.cpp | 301 +++++++++++++++++++++++++++++++++++++++++++++++ src/gui/outfitwindow.h | 92 +++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 src/gui/outfitwindow.cpp create mode 100644 src/gui/outfitwindow.h (limited to 'src') diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp new file mode 100644 index 00000000..1812c58b --- /dev/null +++ b/src/gui/outfitwindow.cpp @@ -0,0 +1,301 @@ +/* + * The Mana World + * Copyright (C) 2007 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "outfitwindow.h" + +#include "configuration.h" +#include "localplayer.h" +#include "graphics.h" +#include "inventory.h" +#include "equipment.h" +#include "item.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/checkbox.h" +#include "gui/widgets/label.h" +#include "gui/widgets/layout.h" + +#include "net/inventoryhandler.h" +#include "net/net.h" + +#include "resources/image.h" + +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include + +OutfitWindow::OutfitWindow(): + Window(_("Outfits")), + mBoxWidth(33), + mBoxHeight(33), + mGridWidth(3), + mGridHeight(3), + mItemClicked(false), + mItemMoved(NULL), + mItemSelected(-1), + mCurrentOutfit(0) +{ + setWindowName("Outfits"); + setCloseButton(true); + setDefaultSize(250, 250, 118, 180); //160 + + mPreviousButton = new Button("<", "previous", this); + mNextButton = new Button(">", "next", this); + mCurrentLabel = new Label("Outfit: 1"); + mCurrentLabel->setAlignment(gcn::Graphics::CENTER); + mUnequipCheck = new CheckBox(_("Unequip first"), + config.getValue("OutfitUnequip", true)); + + place(0, 3, mPreviousButton, 1); + place(1, 3, mCurrentLabel, 2); + place(3, 3, mNextButton, 1); + place(0, 4, mUnequipCheck, 4); + + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); + layout.setColWidth(4, Layout::CENTER); + + loadWindowState(); + + load(); +} + +OutfitWindow::~OutfitWindow() +{ + save(); +} + +void OutfitWindow::load() +{ + memset(mItems, -1, sizeof(mItems)); + for (int o = 0; o < 10; o++) + { + std::string outfit = config.getValue("Outfit" + toString(o), "-1"); + std::string buf; + std::stringstream ss(outfit); + + std::vector tokens; + + while (ss >> buf) { + tokens.push_back(atoi(buf.c_str())); + } + + for (int i = 0; i < (int)tokens.size(); i++) + { + mItems[o][i] = tokens[i]; + } + } +} + +void OutfitWindow::save() +{ + std::string outfitStr; + for (int o = 0; o < 10; o++) + { + for (int i = 0; i < 9; i++) + { + outfitStr += mItems[o][i] ? toString(mItems[o][i]) : toString(-1); + if (i <8) outfitStr += " "; + } + config.setValue("Outfit" + toString(o), outfitStr); + outfitStr = ""; + } + config.setValue("OutfitUnequip", mUnequipCheck ? true : false); +} + +void OutfitWindow::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "next") + { + if (mCurrentOutfit < 9) { + mCurrentOutfit++; + } else { + mCurrentOutfit = 0; + } + } + else if (event.getId() == "previous") + { + if (mCurrentOutfit > 0) { + mCurrentOutfit--; + } else { + mCurrentOutfit = 9; + } + } + mCurrentLabel->setCaption("Outfit: " + toString(mCurrentOutfit + 1)); +} + +void OutfitWindow::wearOutfit(int outfit) +{ + Item *item; + if (mUnequipCheck->isSelected()) + { + for (int i = 0; i < 11; i++) + { + //non vis is 3,4,7 + if (i != 3 && i != 4 && i != 7) + { + if (!(item = player_node->getInventory()->getItem(player_node + ->mEquipment.get()->getEquipment(i)))) + continue; + Net::getInventoryHandler()->unequipItem(item); + } + } + } + + for (int i = 0; i < 9; i++) + { + item = player_node->getInventory()->findItem(mItems[outfit][i]); + if (item && item->getQuantity()) + { + if (item->isEquipment()) { + Net::getInventoryHandler()->equipItem(item); + } + } + } +} + +void OutfitWindow::draw(gcn::Graphics *graphics) +{ + Window::draw(graphics); + Graphics *g = static_cast(graphics); + + for (int i = 0; i < 9; i++) + { + const int itemX = 10 + (i % mGridWidth) * mBoxWidth; + const int itemY = 25 + (i / mGridWidth) * mBoxHeight; + + graphics->setColor(gcn::Color(0, 0, 0, 64)); + graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); + graphics->setColor(gcn::Color(255, 255, 255, 32)); + graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); + + if (mItems[mCurrentOutfit][i] < 0) + continue; + + Item *item = + player_node->getInventory()->findItem(mItems[mCurrentOutfit][i]); + if (item) { + // Draw item icon. + Image* image = item->getImage(); + if (image) { + g->drawImage(image, itemX, itemY); + } + } + } + if (mItemMoved) + { + // Draw the item image being dragged by the cursor. + Image* image = mItemMoved->getImage(); + if (image) + { + const int tPosX = mCursorPosX - (image->getWidth() / 2); + const int tPosY = mCursorPosY - (image->getHeight() / 2); + + g->drawImage(image, tPosX, tPosY); + } + } +} + + +void OutfitWindow::mouseDragged(gcn::MouseEvent &event) +{ + Window::mouseDragged(event); + if (event.getButton() == gcn::MouseEvent::LEFT) { + if (!mItemMoved && mItemClicked) { + const int index = getIndexFromGrid(event.getX(), event.getY()); + if (index == -1) { + return; + } + const int itemId = mItems[mCurrentOutfit][index]; + if (itemId < 0) + return; + Item *item = player_node->getInventory()->findItem(itemId); + if (item) + { + mItemMoved = item; + mItems[mCurrentOutfit][index] = -1; + } + } + if (mItemMoved) { + mCursorPosX = event.getX(); + mCursorPosY = event.getY(); + } + } +} + +void OutfitWindow::mousePressed(gcn::MouseEvent &event) +{ + Window::mousePressed(event); + const int index = getIndexFromGrid(event.getX(), event.getY()); + if (index == -1) { + return; + } + + // Stores the selected item if there is one. + if (isItemSelected()) { + mItems[mCurrentOutfit][index] = mItemSelected; + mItemSelected = -1; + } + else if (mItems[mCurrentOutfit][index]) { + mItemClicked = true; + } +} + +void OutfitWindow::mouseReleased(gcn::MouseEvent &event) +{ + Window::mouseReleased(event); + if (event.getButton() == gcn::MouseEvent::LEFT) + { + if (isItemSelected()) + { + mItemSelected = -1; + } + const int index = getIndexFromGrid(event.getX(), event.getY()); + if (index == -1) { + mItemMoved = NULL; + return; + } + if (mItemMoved) { + mItems[mCurrentOutfit][index] = mItemMoved->getId(); + mItemMoved = NULL; + } + if (mItemClicked) { + mItemClicked = false; + } + } +} + +int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const +{ + const gcn::Rectangle tRect = gcn::Rectangle( + 10, 25, 10 + mGridWidth * mBoxWidth, 25 + mGridHeight * mBoxHeight); + if (!tRect.isPointInRect(pointX, pointY)) { + return -1; + } + const int index = (((pointY - 25) / mBoxHeight) * mGridWidth) + + (pointX - 10) / mBoxWidth; + if (index >= 9) + { + return -1; + } + return index; +} diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h new file mode 100644 index 00000000..3e70815c --- /dev/null +++ b/src/gui/outfitwindow.h @@ -0,0 +1,92 @@ +/* + * The Mana World + * Copyright (C) 2007 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef OUTFITWINDOW_H +#define OUTFITWINDOW_H + +#include "gui/widgets/window.h" + +#include + +class Button; +class CheckBox; +class Item; +class Label; + +class OutfitWindow : public Window, gcn::ActionListener +{ + public: + /** + * Constructor. + */ + OutfitWindow(); + + /** + * Destructor. + */ + ~OutfitWindow(); + + void action(const gcn::ActionEvent &event); + + void draw(gcn::Graphics *graphics); + + void mousePressed(gcn::MouseEvent &event); + + void mouseDragged(gcn::MouseEvent &event); + + void mouseReleased(gcn::MouseEvent &event); + + void load(); + + void setItemSelected(int itemId) + { mItemSelected = itemId; } + + bool isItemSelected() + { return mItemSelected > -1; } + + void wearOutfit(int outfit); + + private: + Button *mPreviousButton; + Button *mNextButton; + Label *mCurrentLabel; + CheckBox *mUnequipCheck; + + int getIndexFromGrid(int pointX, int pointY) const; + + int mBoxWidth; + int mBoxHeight; + int mCursorPosX, mCursorPosY; + int mGridWidth, mGridHeight; + bool mItemClicked; + Item *mItemMoved; + + void save(); + + int mItems[10][9]; + int mItemSelected; + + int mCurrentOutfit; +}; + +extern OutfitWindow *outfitWindow; + +#endif -- cgit v1.2.3-70-g09d2 From 3591c264f14edf300e7d3ea20577c517a092cf50 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 19:08:25 +0200 Subject: Fixed alpha to also apply to the main text of a text particle It was only being applied to the outline and shadow. This improves the fadeout a little, but because the text is being rendered multiple times, it still looks strange. --- src/gui/textrenderer.h | 2 +- src/localplayer.cpp | 3 ++- src/localplayer.h | 3 ++- src/textparticle.cpp | 17 +++++++---------- src/textparticle.h | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h index 712c1312..c8ff5833 100644 --- a/src/gui/textrenderer.h +++ b/src/gui/textrenderer.h @@ -50,7 +50,7 @@ class TextRenderer if (shadow) { graphics->setColor(guiPalette->getColor(Palette::SHADOW, - alpha / 2)); + alpha / 2)); if (outline) { graphics->drawText(text, x + 2, y + 2, align); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c1423190..7119bfc9 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -946,7 +946,8 @@ void LocalPlayer::initTargetCursor() true, TC_LARGE); } -void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, +void LocalPlayer::loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, TargetCursorSize size) { assert(size > -1); diff --git a/src/localplayer.h b/src/localplayer.h index add5c049..4a85dd75 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -490,7 +490,8 @@ class LocalPlayer : public Player /** * Helper function for loading target cursors */ - void loadTargetCursor(std::string filename, int width, int height, + void loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, Being::TargetCursorSize size); /** Images of the target cursor. */ diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 04b7abe1..da176087 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -26,7 +26,7 @@ #include "gui/textrenderer.h" TextParticle::TextParticle(Map *map, const std::string &text, - const gcn::Color* color, + const gcn::Color *color, gcn::Font *font, bool outline): Particle(map), mText(text), @@ -47,18 +47,15 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const float alpha = mAlpha * 255.0f; if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut) - { - alpha *= mLifetimeLeft; - alpha /= mFadeOut; - } + alpha = alpha * mLifetimeLeft / mFadeOut; if (mLifetimePast < mFadeIn) - { - alpha *= mLifetimePast; - alpha /= mFadeIn; - } + alpha = alpha * mLifetimePast / mFadeIn; + + gcn::Color color = *mColor; + color.a = (int) alpha; TextRenderer::renderText(graphics, mText, screenX, screenY, gcn::Graphics::CENTER, - *mColor, mTextFont, mOutline, false, (int) alpha); + color, mTextFont, mOutline, false, (int) alpha); } diff --git a/src/textparticle.h b/src/textparticle.h index 8b7d3e01..a87137ea 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -47,7 +47,7 @@ class TextParticle : public Particle private: std::string mText; /**< Text of the particle. */ gcn::Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color* mColor; /**< Color used for drawing the text. */ + const gcn::Color *mColor; /**< Color used for drawing the text. */ bool mOutline; /**< Make the text better readable */ }; -- cgit v1.2.3-70-g09d2 From e0eeaef318d63ae79522c1d0407e4f5b8212c5f7 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 19:31:41 +0200 Subject: Fixed the fallback on colors.xml to be more neutral There is no need to separate these projects more than necessary. Also fixed a bug that made the hair always white. --- src/resources/colordb.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 12806f8e..e5377aa6 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -27,9 +27,6 @@ #include -#define HAIR_COLOR_FILE "hair.xml" -#define AE_COLOR_FILE "colors.xml" - namespace { ColorDB::Colors mColors; @@ -42,20 +39,20 @@ void ColorDB::load() if (mLoaded) return; - XML::Document *doc = new XML::Document(HAIR_COLOR_FILE); + XML::Document *doc = new XML::Document("hair.xml"); xmlNodePtr root = doc->rootNode(); - bool TMWHair = false; + bool hairXml = true; if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("Trying Aethyra's color file, %s.", AE_COLOR_FILE); + logger->log("Trying to fall back on colors.xml"); - TMWHair = true; + hairXml = false; delete doc; - - doc = new XML::Document(AE_COLOR_FILE); + doc = new XML::Document("colors.xml"); root = doc->rootNode(); + if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { logger->log("ColorDB: Failed to find any color files."); @@ -78,8 +75,8 @@ void ColorDB::load() logger->log("ColorDB: Redefinition of dye ID %d", id); } - TMWHair ? mColors[id] = XML::getProperty(node, "value", "#FFFFFF") : - mColors[id] = XML::getProperty(node, "dye", "#FFFFFF"); + mColors[id] = hairXml ? XML::getProperty(node, "value", "#FFFFFF") : + XML::getProperty(node, "dye", "#FFFFFF"); } } -- cgit v1.2.3-70-g09d2 From d4247f3edb63733e9b2a6903ad2ae08c770e8a0f Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Thu, 14 May 2009 21:49:19 +0200 Subject: Fixes to outfit window - Moved the outfit button onto the Inventory window - Fixed 'unequip first' saving bug Patch by QOAL --- src/gui/inventorywindow.cpp | 18 +++++++++++++++--- src/gui/inventorywindow.h | 1 + src/gui/outfitwindow.cpp | 2 +- src/gui/windowmenu.cpp | 6 ------ 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d6cd3a84..c44ae9e7 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -79,6 +79,7 @@ InventoryWindow::InventoryWindow(int invSize): mUseButton = new Button(longestUseString, "use", this); mDropButton = new Button(_("Drop"), "drop", this); mSplitButton = new Button(_("Split"), "split", this); + mOutfitButton = new Button(_("Outfits"), "outfit", this); mItems = new ItemContainer(player_node->getInventory()); mItems->addSelectionListener(this); @@ -103,6 +104,7 @@ InventoryWindow::InventoryWindow(int invSize): place(0, 2, mUseButton); place(1, 2, mDropButton); place(2, 2, mSplitButton); + place(6, 2, mOutfitButton); Layout &layout = getLayout(); layout.setRowHeight(1, Layout::AUTO_SET); @@ -156,6 +158,16 @@ void InventoryWindow::logic() void InventoryWindow::action(const gcn::ActionEvent &event) { + if (event.getId() == "outfit") + { + extern Window *outfitWindow; + outfitWindow->setVisible(!outfitWindow->isVisible()); + if (outfitWindow->isVisible()) + { + outfitWindow->requestMoveToTop(); + } + } + Item *item = mItems->getSelectedItem(); if (!item) @@ -163,7 +175,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) if (event.getId() == "use") { - if (item->isEquipment()) + if (item->isEquipment()) { if (item->isEquipped()) Net::getInventoryHandler()->unequipItem(item); @@ -258,10 +270,10 @@ void InventoryWindow::updateButtons() mDropButton->setEnabled(false); return; } - + mUseButton->setEnabled(true); mDropButton->setEnabled(true); - + if (selectedItem->isEquipment()) { if (selectedItem->isEquipped()) diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 6e34666d..fbda5ac7 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -109,6 +109,7 @@ class InventoryWindow : public Window, gcn::Button *mUseButton; gcn::Button *mDropButton; gcn::Button *mSplitButton; + gcn::Button *mOutfitButton; gcn::Label *mWeightLabel; gcn::Label *mSlotsLabel; diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 1812c58b..53950299 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -119,7 +119,7 @@ void OutfitWindow::save() config.setValue("Outfit" + toString(o), outfitStr); outfitStr = ""; } - config.setValue("OutfitUnequip", mUnequipCheck ? true : false); + config.setValue("OutfitUnequip", mUnequipCheck->isSelected()); } void OutfitWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index d66aa602..8964f072 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -47,7 +47,6 @@ extern Window *buddyWindow; extern Window *guildWindow; extern Window *magicDialog; #endif -extern Window *outfitWindow; WindowMenu::WindowMenu(): mEmotePopup(0) @@ -56,7 +55,6 @@ WindowMenu::WindowMenu(): static const char *buttonNames[] = { ":-)", - N_("Outfits"), N_("Status"), N_("Equipment"), N_("Inventory"), @@ -115,10 +113,6 @@ void WindowMenu::action(const gcn::ActionEvent &event) mEmotePopup = 0; } } - else if (event.getId() == "Outfits") - { - window = outfitWindow; - } else if (event.getId() == "Status") { window = statusWindow; -- cgit v1.2.3-70-g09d2 From 2477cc428795d678142bf6f66147790c71ad03fd Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 14 May 2009 10:43:18 -0600 Subject: Make sure to use our hair color file first (cherry picked from commit b0475c40bb256107aa13919b8d020b172af9d788) --- src/resources/colordb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index af498297..12806f8e 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -27,8 +27,8 @@ #include -#define HAIR_COLOR_FILE "colors.xml" -#define TMW_COLOR_FILE "hair.xml" +#define HAIR_COLOR_FILE "hair.xml" +#define AE_COLOR_FILE "colors.xml" namespace { @@ -48,17 +48,17 @@ void ColorDB::load() if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("Trying TMW's color file, %s.", TMW_COLOR_FILE); + logger->log("Trying Aethyra's color file, %s.", AE_COLOR_FILE); TMWHair = true; delete doc; - doc = new XML::Document(TMW_COLOR_FILE); + doc = new XML::Document(AE_COLOR_FILE); root = doc->rootNode(); if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("ColorDB: Failed"); + logger->log("ColorDB: Failed to find any color files."); mColors[0] = mFail; mLoaded = true; -- cgit v1.2.3-70-g09d2 From 53c32dd1beb5575c38bbc830f7d37cb954be90d2 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 19:08:25 +0200 Subject: Fixed alpha to also apply to the main text of a text particle It was only being applied to the outline and shadow. This improves the fadeout a little, but because the text is being rendered multiple times, it still looks strange. (cherry picked from commit 3591c264f14edf300e7d3ea20577c517a092cf50) --- src/gui/textrenderer.h | 2 +- src/localplayer.cpp | 3 ++- src/localplayer.h | 3 ++- src/textparticle.cpp | 17 +++++++---------- src/textparticle.h | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h index 712c1312..c8ff5833 100644 --- a/src/gui/textrenderer.h +++ b/src/gui/textrenderer.h @@ -50,7 +50,7 @@ class TextRenderer if (shadow) { graphics->setColor(guiPalette->getColor(Palette::SHADOW, - alpha / 2)); + alpha / 2)); if (outline) { graphics->drawText(text, x + 2, y + 2, align); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c1423190..7119bfc9 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -946,7 +946,8 @@ void LocalPlayer::initTargetCursor() true, TC_LARGE); } -void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, +void LocalPlayer::loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, TargetCursorSize size) { assert(size > -1); diff --git a/src/localplayer.h b/src/localplayer.h index add5c049..4a85dd75 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -490,7 +490,8 @@ class LocalPlayer : public Player /** * Helper function for loading target cursors */ - void loadTargetCursor(std::string filename, int width, int height, + void loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, Being::TargetCursorSize size); /** Images of the target cursor. */ diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 04b7abe1..da176087 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -26,7 +26,7 @@ #include "gui/textrenderer.h" TextParticle::TextParticle(Map *map, const std::string &text, - const gcn::Color* color, + const gcn::Color *color, gcn::Font *font, bool outline): Particle(map), mText(text), @@ -47,18 +47,15 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const float alpha = mAlpha * 255.0f; if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut) - { - alpha *= mLifetimeLeft; - alpha /= mFadeOut; - } + alpha = alpha * mLifetimeLeft / mFadeOut; if (mLifetimePast < mFadeIn) - { - alpha *= mLifetimePast; - alpha /= mFadeIn; - } + alpha = alpha * mLifetimePast / mFadeIn; + + gcn::Color color = *mColor; + color.a = (int) alpha; TextRenderer::renderText(graphics, mText, screenX, screenY, gcn::Graphics::CENTER, - *mColor, mTextFont, mOutline, false, (int) alpha); + color, mTextFont, mOutline, false, (int) alpha); } diff --git a/src/textparticle.h b/src/textparticle.h index 8b7d3e01..a87137ea 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -47,7 +47,7 @@ class TextParticle : public Particle private: std::string mText; /**< Text of the particle. */ gcn::Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color* mColor; /**< Color used for drawing the text. */ + const gcn::Color *mColor; /**< Color used for drawing the text. */ bool mOutline; /**< Make the text better readable */ }; -- cgit v1.2.3-70-g09d2 From 8a93b4d230d3f50c06940f88195e9e514ff1c4ea Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 19:31:41 +0200 Subject: Fixed the fallback on colors.xml to be more neutral There is no need to separate these projects more than necessary. Also fixed a bug that made the hair always white. (cherry picked from commit e0eeaef318d63ae79522c1d0407e4f5b8212c5f7) --- src/resources/colordb.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 12806f8e..e5377aa6 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -27,9 +27,6 @@ #include -#define HAIR_COLOR_FILE "hair.xml" -#define AE_COLOR_FILE "colors.xml" - namespace { ColorDB::Colors mColors; @@ -42,20 +39,20 @@ void ColorDB::load() if (mLoaded) return; - XML::Document *doc = new XML::Document(HAIR_COLOR_FILE); + XML::Document *doc = new XML::Document("hair.xml"); xmlNodePtr root = doc->rootNode(); - bool TMWHair = false; + bool hairXml = true; if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { - logger->log("Trying Aethyra's color file, %s.", AE_COLOR_FILE); + logger->log("Trying to fall back on colors.xml"); - TMWHair = true; + hairXml = false; delete doc; - - doc = new XML::Document(AE_COLOR_FILE); + doc = new XML::Document("colors.xml"); root = doc->rootNode(); + if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) { logger->log("ColorDB: Failed to find any color files."); @@ -78,8 +75,8 @@ void ColorDB::load() logger->log("ColorDB: Redefinition of dye ID %d", id); } - TMWHair ? mColors[id] = XML::getProperty(node, "value", "#FFFFFF") : - mColors[id] = XML::getProperty(node, "dye", "#FFFFFF"); + mColors[id] = hairXml ? XML::getProperty(node, "value", "#FFFFFF") : + XML::getProperty(node, "dye", "#FFFFFF"); } } -- cgit v1.2.3-70-g09d2 From 5cdca270a98b9358382e31e3a7b70b1e225bde66 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 14 May 2009 23:15:54 +0200 Subject: Fixed Reset Windows to also reset the party window Mantis-issue: 697 --- src/gui/setup.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index e73f9b74..aebcf61b 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -46,6 +46,7 @@ extern Window *inventoryWindow; extern Window *npcTextDialog; extern Window *npcStringDialog; extern Window *skillDialog; +extern Window *partyWindow; extern Window *minimap; extern Window *equipmentWindow; extern Window *tradeWindow; @@ -145,6 +146,7 @@ void Setup::action(const gcn::ActionEvent &event) #endif inventoryWindow->resetToDefaultSize(); skillDialog->resetToDefaultSize(); + partyWindow->resetToDefaultSize(); minimap->resetToDefaultSize(); equipmentWindow->resetToDefaultSize(); tradeWindow->resetToDefaultSize(); -- cgit v1.2.3-70-g09d2 From fdb9dc63cab0ff0feb7f0e52252a07df9d7b87f0 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Fri, 15 May 2009 13:32:23 +0200 Subject: Fix label on keyboard config for outfits. --- src/keyboardconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 6136f043..ca6804f4 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -80,7 +80,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyWindowDebug", SDLK_F10, _("Debug Window")}, {"keyWindowParty", SDLK_F11, _("Party Window")}, {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")}, - {"keyWindowOutfit", SDLK_o, _("Emote Shortcut Window")}, + {"keyWindowOutfit", SDLK_o, _("Outfits Window")}, {"keyEmoteShortcut1", SDLK_1, strprintf(_("Emote Shortcut %d"), 1)}, {"keyEmoteShortcut2", SDLK_2, strprintf(_("Emote Shortcut %d"), 2)}, {"keyEmoteShortcut3", SDLK_3, strprintf(_("Emote Shortcut %d"), 3)}, -- cgit v1.2.3-70-g09d2 From ff4b7434b7bd25412a24a13bc0ef00e253c17f0e Mon Sep 17 00:00:00 2001 From: Maximilian Philipps Date: Fri, 15 May 2009 17:43:58 +0200 Subject: scale the partywindow down --- src/gui/partywindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 1260a2c3..68e5a371 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -54,8 +54,8 @@ PartyWindow::PartyWindow() : setSaveVisible(true); setCloseButton(true); setMinWidth(120); - setMinHeight(200); - setDefaultSize(590, 200, 150, 200); + setMinHeight(55); + setDefaultSize(590, 200, 150, 60); loadWindowState(); } -- cgit v1.2.3-70-g09d2 From fc6b38d113e7f78af1075a37e1853e00294742e9 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:37:10 +0200 Subject: Enable and fix path drawing for athena. Notice that in Being::Logic() we call Being::setPosition() with the added offset of x+16, y+32, this makes both the Vector Being::mPos and Being::mPx / Being::mPy not mean the same as pre-merge client. Thus some effects and code dividing these members with 32 to get the tile coords get wrong results. Perhaps this all these methods of getting x,y on beings should be cleaned up so we have 1 method we settle on and store the sprites' fixed x,y offset on the sprite itself. so we have x + fixed_offset + animation_offset and not all these magic numbers floating around. --- src/gui/viewport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f92a81b8..2c3f4007 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -195,7 +195,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) mMap->drawCollision(graphics, (int) mPixelViewX, (int) mPixelViewY); -#if 0 +#if EATHENA_SUPPORT drawDebugPath(graphics); #endif } @@ -265,8 +265,8 @@ void Viewport::drawDebugPath(Graphics *graphics) const Vector &playerPos = player_node->getPosition(); Path debugPath = mMap->findPath( - (int) playerPos.x / 32, - (int) playerPos.y / 32, + (int) (playerPos.x - 16) / 32, + (int) (playerPos.y - 32) / 32, mouseTileX, mouseTileY, 0xFF); drawPath(graphics, debugPath); -- cgit v1.2.3-70-g09d2 From afe09f20caa9ee3a690ea2b84bdaee19464b45bc Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:41:46 +0200 Subject: Fix offset error on where command. Both mPx/mPy and mPos vector have the extra 16,32 pixels. --- src/commandhandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 462cb3b9..f2fafed4 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -279,9 +279,9 @@ void CommandHandler::handleWhere(const std::string &args, ChatTab *tab) { std::ostringstream where; where << map_path << ", coordinates: " - << (player_node->getPixelX() / 32) << ", " - << ((player_node->getPixelY() / 32) - 1); // Not real sure why we remove 1, - // but it makes it in sync with @where + << ((player_node->getPixelX() - 16) / 32) << ", " + << ((player_node->getPixelY() - 32) / 32); + tab->chatLog(where.str(), BY_SERVER); } -- cgit v1.2.3-70-g09d2 From 98eadea1f98f76237701d2ac44868847a18d13c2 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:57:50 +0200 Subject: Fix offsets (16,32) on TextEffects for damage, pickup and exp. --- src/being.cpp | 2 +- src/localplayer.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 2b31e9ec..37cb6987 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -448,7 +448,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type) // Show damage number particleEngine->addTextSplashEffect(damage, - mPx + 16, mPy + 16, + mPx, mPy - 16, color, font, true); if (amount > 0) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 7119bfc9..650de182 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -812,8 +812,8 @@ void LocalPlayer::setXp(int xp) // Show XP number particleEngine->addTextRiseFadeOutEffect( text, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::EXP_INFO), gui->getInfoParticleFont(), true); } @@ -829,8 +829,8 @@ void LocalPlayer::pickedUp(const std::string &item) // Show pickup notification particleEngine->addTextRiseFadeOutEffect( item, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::PICKUP_INFO), gui->getInfoParticleFont(), true); } -- cgit v1.2.3-70-g09d2 From c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 15 May 2009 12:09:45 +0200 Subject: Fixed a possible crash on logging in to the map server The Game instance was created too late, in some cases after messages were received by the BeingHandler. This caused crashes since the BeingHandler tried to use the BeingManager, which hadn't been created yet. --- src/main.cpp | 5 +++-- src/net/ea/maphandler.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 40b30899..07bcd3f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,6 +159,7 @@ extern Net::Connection *accountServerConnection; #endif Graphics *graphics; +Game *game = 0; unsigned char state; std::string errorMessage; @@ -910,7 +911,6 @@ int main(int argc, char *argv[]) // Needs to be created in main, as the updater uses it guiPalette = new Palette; - Game *game = NULL; Window *currentDialog = NULL; #ifdef TMWSERV_SUPPORT QuitDialog* quitDialog = NULL; @@ -1290,6 +1290,7 @@ int main(int argc, char *argv[]) game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; @@ -1467,9 +1468,9 @@ int main(int argc, char *argv[]) desktop = NULL; logger->log("State: GAME"); - game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; break; diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp index 76b3c480..c7ff0ec7 100644 --- a/src/net/ea/maphandler.cpp +++ b/src/net/ea/maphandler.cpp @@ -27,6 +27,7 @@ #include "net/messagein.h" #include "net/messageout.h" +#include "game.h" #include "localplayer.h" #include "log.h" #include "main.h" @@ -37,6 +38,7 @@ #include "utils/stringutils.h" Net::MapHandler *mapHandler; +extern Game *game; namespace EAthena { @@ -65,6 +67,7 @@ void MapHandler::handleMessage(MessageIn &msg) logger->log("Protocol: Player start position: (%d, %d), Direction: %d", player_node->mX, player_node->mY, direction); state = STATE_GAME; + game = new Game; break; case SMSG_SERVER_PING: -- cgit v1.2.3-70-g09d2 From a6ad03efc6223a46cc8336eaf43119fb346d7195 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 16 May 2009 22:33:20 -0400 Subject: Fixes the lightspeed bug --- src/localplayer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 650de182..e9bc30f2 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -727,10 +727,10 @@ void LocalPlayer::stopAttack() { if (mTarget) { - setAction(STAND); - mLastTarget = -1; + if (mAction == ATTACK) + setAction(STAND); + setTarget(NULL); } - setTarget(NULL); mLastTarget = -1; } -- cgit v1.2.3-70-g09d2 From e1b4184da2ece6c9e1518064ffe35b9404b3db18 Mon Sep 17 00:00:00 2001 From: Michon van Dooren Date: Fri, 15 May 2009 17:38:01 +0200 Subject: Fixed the -S/--home-dir command line option. --- src/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 07bcd3f8..3c98ed27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,6 +215,7 @@ struct Options std::string configPath; std::string updateHost; std::string dataPath; + std::string homeDir; std::string serverName; short serverPort; @@ -303,11 +304,16 @@ static void setUpdatesDir() * Initializes the home directory. On UNIX and FreeBSD, ~/.tmw is used. On * Windows and other systems we use the current working directory. */ -static void initHomeDir() +static void initHomeDir(const Options &options) { - homeDir = std::string(PHYSFS_getUserDir()) + - "/." + - branding.getValue("appShort", "tmw"); + homeDir = options.homeDir; + + if (homeDir.empty()) + { + homeDir = std::string(PHYSFS_getUserDir()) + + "/." + + branding.getValue("appShort", "tmw"); + } #if defined WIN32 if (!CreateDirectory(homeDir.c_str(), 0) && GetLastError() != ERROR_ALREADY_EXISTS) @@ -660,7 +666,7 @@ static void parseOptions(int argc, char *argv[], Options &options) options.printVersion = true; break; case 'S': - homeDir = optarg; + options.homeDir = optarg; break; case 'O': options.noOpenGL = true; @@ -894,7 +900,7 @@ int main(int argc, char *argv[]) // Load branding information branding.init("data/branding.xml"); - initHomeDir(); + initHomeDir(options); // Configure logger logger = new Logger; -- cgit v1.2.3-70-g09d2 From 9b4d924d74587f489ac8141134b1c504e54a0684 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 05:13:29 +0200 Subject: Init state variable to make valgrind happy. --- src/main.cpp | 2 +- src/main.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 3c98ed27..bc010d30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,7 +161,7 @@ extern Net::Connection *accountServerConnection; Graphics *graphics; Game *game = 0; -unsigned char state; +unsigned char state = STATE_NULL; std::string errorMessage; Sound sound; diff --git a/src/main.h b/src/main.h index 49a034f5..a3894d13 100644 --- a/src/main.h +++ b/src/main.h @@ -107,15 +107,16 @@ enum { STATE_LOGOUT_ATTEMPT, STATE_CONNECT_GAME, STATE_WAIT, - STATE_FORCE_QUIT + STATE_FORCE_QUIT, #else STATE_ACCOUNT, STATE_CHAR_CONNECT, STATE_CHAR_SERVER, STATE_CHAR_NEW, STATE_CHAR_DEL, - STATE_CONNECTING + STATE_CONNECTING, #endif + STATE_NULL }; /* length definitions for several char[]s in order -- cgit v1.2.3-70-g09d2 From 6e8b4df7f826ce7a6c43b22f67c654a5c4893a1c Mon Sep 17 00:00:00 2001 From: Maximilian Philipps Date: Fri, 15 May 2009 17:43:58 +0200 Subject: scale the partywindow down (cherry picked from commit ff4b7434b7bd25412a24a13bc0ef00e253c17f0e) --- src/gui/partywindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 1260a2c3..68e5a371 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -54,8 +54,8 @@ PartyWindow::PartyWindow() : setSaveVisible(true); setCloseButton(true); setMinWidth(120); - setMinHeight(200); - setDefaultSize(590, 200, 150, 200); + setMinHeight(55); + setDefaultSize(590, 200, 150, 60); loadWindowState(); } -- cgit v1.2.3-70-g09d2 From 91bd2b5862242c88cfe999ee578febf97dc21939 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:37:10 +0200 Subject: Enable and fix path drawing for athena. Notice that in Being::Logic() we call Being::setPosition() with the added offset of x+16, y+32, this makes both the Vector Being::mPos and Being::mPx / Being::mPy not mean the same as pre-merge client. Thus some effects and code dividing these members with 32 to get the tile coords get wrong results. Perhaps this all these methods of getting x,y on beings should be cleaned up so we have 1 method we settle on and store the sprites' fixed x,y offset on the sprite itself. so we have x + fixed_offset + animation_offset and not all these magic numbers floating around. (cherry picked from commit fc6b38d113e7f78af1075a37e1853e00294742e9) --- src/gui/viewport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f92a81b8..2c3f4007 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -195,7 +195,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) mMap->drawCollision(graphics, (int) mPixelViewX, (int) mPixelViewY); -#if 0 +#if EATHENA_SUPPORT drawDebugPath(graphics); #endif } @@ -265,8 +265,8 @@ void Viewport::drawDebugPath(Graphics *graphics) const Vector &playerPos = player_node->getPosition(); Path debugPath = mMap->findPath( - (int) playerPos.x / 32, - (int) playerPos.y / 32, + (int) (playerPos.x - 16) / 32, + (int) (playerPos.y - 32) / 32, mouseTileX, mouseTileY, 0xFF); drawPath(graphics, debugPath); -- cgit v1.2.3-70-g09d2 From 7657ec87dcae8dd12186c65448cb6fe743849e4d Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:41:46 +0200 Subject: Fix offset error on where command. Both mPx/mPy and mPos vector have the extra 16,32 pixels. (cherry picked from commit afe09f20caa9ee3a690ea2b84bdaee19464b45bc) --- src/commandhandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 462cb3b9..f2fafed4 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -279,9 +279,9 @@ void CommandHandler::handleWhere(const std::string &args, ChatTab *tab) { std::ostringstream where; where << map_path << ", coordinates: " - << (player_node->getPixelX() / 32) << ", " - << ((player_node->getPixelY() / 32) - 1); // Not real sure why we remove 1, - // but it makes it in sync with @where + << ((player_node->getPixelX() - 16) / 32) << ", " + << ((player_node->getPixelY() - 32) / 32); + tab->chatLog(where.str(), BY_SERVER); } -- cgit v1.2.3-70-g09d2 From b86b23225eedc5ca7fe313cc6485138e1f69cadb Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 01:57:50 +0200 Subject: Fix offsets (16,32) on TextEffects for damage, pickup and exp. (cherry picked from commit 98eadea1f98f76237701d2ac44868847a18d13c2) --- src/being.cpp | 2 +- src/localplayer.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 2b31e9ec..37cb6987 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -448,7 +448,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type) // Show damage number particleEngine->addTextSplashEffect(damage, - mPx + 16, mPy + 16, + mPx, mPy - 16, color, font, true); if (amount > 0) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 7119bfc9..650de182 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -812,8 +812,8 @@ void LocalPlayer::setXp(int xp) // Show XP number particleEngine->addTextRiseFadeOutEffect( text, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::EXP_INFO), gui->getInfoParticleFont(), true); } @@ -829,8 +829,8 @@ void LocalPlayer::pickedUp(const std::string &item) // Show pickup notification particleEngine->addTextRiseFadeOutEffect( item, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::PICKUP_INFO), gui->getInfoParticleFont(), true); } -- cgit v1.2.3-70-g09d2 From da03d6fcdd76774fd97e94227f32b9574f52bc18 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 15 May 2009 12:09:45 +0200 Subject: Fixed a possible crash on logging in to the map server The Game instance was created too late, in some cases after messages were received by the BeingHandler. This caused crashes since the BeingHandler tried to use the BeingManager, which hadn't been created yet. (cherry picked from commit c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5) --- src/main.cpp | 5 +++-- src/net/ea/maphandler.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 40b30899..07bcd3f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,6 +159,7 @@ extern Net::Connection *accountServerConnection; #endif Graphics *graphics; +Game *game = 0; unsigned char state; std::string errorMessage; @@ -910,7 +911,6 @@ int main(int argc, char *argv[]) // Needs to be created in main, as the updater uses it guiPalette = new Palette; - Game *game = NULL; Window *currentDialog = NULL; #ifdef TMWSERV_SUPPORT QuitDialog* quitDialog = NULL; @@ -1290,6 +1290,7 @@ int main(int argc, char *argv[]) game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; @@ -1467,9 +1468,9 @@ int main(int argc, char *argv[]) desktop = NULL; logger->log("State: GAME"); - game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; break; diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp index 76b3c480..c7ff0ec7 100644 --- a/src/net/ea/maphandler.cpp +++ b/src/net/ea/maphandler.cpp @@ -27,6 +27,7 @@ #include "net/messagein.h" #include "net/messageout.h" +#include "game.h" #include "localplayer.h" #include "log.h" #include "main.h" @@ -37,6 +38,7 @@ #include "utils/stringutils.h" Net::MapHandler *mapHandler; +extern Game *game; namespace EAthena { @@ -65,6 +67,7 @@ void MapHandler::handleMessage(MessageIn &msg) logger->log("Protocol: Player start position: (%d, %d), Direction: %d", player_node->mX, player_node->mY, direction); state = STATE_GAME; + game = new Game; break; case SMSG_SERVER_PING: -- cgit v1.2.3-70-g09d2 From 11f68b7cfe0833b8d5b2dc9aee2256b499812e7e Mon Sep 17 00:00:00 2001 From: Michon van Dooren Date: Fri, 15 May 2009 17:38:01 +0200 Subject: Fixed the -S/--home-dir command line option. (cherry picked from commit e1b4184da2ece6c9e1518064ffe35b9404b3db18) --- src/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 07bcd3f8..3c98ed27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,6 +215,7 @@ struct Options std::string configPath; std::string updateHost; std::string dataPath; + std::string homeDir; std::string serverName; short serverPort; @@ -303,11 +304,16 @@ static void setUpdatesDir() * Initializes the home directory. On UNIX and FreeBSD, ~/.tmw is used. On * Windows and other systems we use the current working directory. */ -static void initHomeDir() +static void initHomeDir(const Options &options) { - homeDir = std::string(PHYSFS_getUserDir()) + - "/." + - branding.getValue("appShort", "tmw"); + homeDir = options.homeDir; + + if (homeDir.empty()) + { + homeDir = std::string(PHYSFS_getUserDir()) + + "/." + + branding.getValue("appShort", "tmw"); + } #if defined WIN32 if (!CreateDirectory(homeDir.c_str(), 0) && GetLastError() != ERROR_ALREADY_EXISTS) @@ -660,7 +666,7 @@ static void parseOptions(int argc, char *argv[], Options &options) options.printVersion = true; break; case 'S': - homeDir = optarg; + options.homeDir = optarg; break; case 'O': options.noOpenGL = true; @@ -894,7 +900,7 @@ int main(int argc, char *argv[]) // Load branding information branding.init("data/branding.xml"); - initHomeDir(); + initHomeDir(options); // Configure logger logger = new Logger; -- cgit v1.2.3-70-g09d2 From 9a8d9a1e92859fdd75468852b3c7cc0de4ae44c0 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 16 May 2009 22:33:20 -0400 Subject: Fixes the lightspeed bug (cherry picked from commit a6ad03efc6223a46cc8336eaf43119fb346d7195) --- src/localplayer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 650de182..e9bc30f2 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -727,10 +727,10 @@ void LocalPlayer::stopAttack() { if (mTarget) { - setAction(STAND); - mLastTarget = -1; + if (mAction == ATTACK) + setAction(STAND); + setTarget(NULL); } - setTarget(NULL); mLastTarget = -1; } -- cgit v1.2.3-70-g09d2 From 0b18320693dd428e01ab9810d3bb4e18858c43d2 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 17 May 2009 05:13:29 +0200 Subject: Init state variable to make valgrind happy. (cherry picked from commit 9b4d924d74587f489ac8141134b1c504e54a0684) --- src/main.cpp | 2 +- src/main.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 3c98ed27..bc010d30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,7 +161,7 @@ extern Net::Connection *accountServerConnection; Graphics *graphics; Game *game = 0; -unsigned char state; +unsigned char state = STATE_NULL; std::string errorMessage; Sound sound; diff --git a/src/main.h b/src/main.h index 49a034f5..a3894d13 100644 --- a/src/main.h +++ b/src/main.h @@ -107,15 +107,16 @@ enum { STATE_LOGOUT_ATTEMPT, STATE_CONNECT_GAME, STATE_WAIT, - STATE_FORCE_QUIT + STATE_FORCE_QUIT, #else STATE_ACCOUNT, STATE_CHAR_CONNECT, STATE_CHAR_SERVER, STATE_CHAR_NEW, STATE_CHAR_DEL, - STATE_CONNECTING + STATE_CONNECTING, #endif + STATE_NULL }; /* length definitions for several char[]s in order -- cgit v1.2.3-70-g09d2 From 7b2b5dabb44ce1448f3af99fcba96eefe6d9147d Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 17 May 2009 22:43:33 +0200 Subject: Make the state variable a bit more type-safe Should be no change in behaviour. --- src/gui/serverselectdialog.cpp | 2 +- src/gui/serverselectdialog.h | 6 ++++-- src/main.cpp | 8 ++++---- src/main.h | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/serverselectdialog.cpp b/src/gui/serverselectdialog.cpp index ccdf2bb6..f492ebc7 100644 --- a/src/gui/serverselectdialog.cpp +++ b/src/gui/serverselectdialog.cpp @@ -55,7 +55,7 @@ class ServerListModel : public gcn::ListModel } }; -ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): +ServerSelectDialog::ServerSelectDialog(LoginData *loginData, State nextState): Window(_("Select Server")), mLoginData(loginData), mNextState(nextState) diff --git a/src/gui/serverselectdialog.h b/src/gui/serverselectdialog.h index b80ad286..fd1484af 100644 --- a/src/gui/serverselectdialog.h +++ b/src/gui/serverselectdialog.h @@ -24,6 +24,8 @@ #include "gui/widgets/window.h" +#include "main.h" + #include #include @@ -42,7 +44,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { * * @see Window::Window */ - ServerSelectDialog(LoginData *loginData, int nextState); + ServerSelectDialog(LoginData *loginData, State nextState); /** * Destructor. @@ -59,7 +61,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { ServerListModel *mServerListModel; gcn::ListBox *mServerList; gcn::Button *mOkButton; - int mNextState; + State mNextState; }; #endif diff --git a/src/main.cpp b/src/main.cpp index bc010d30..fb061818 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,7 +161,7 @@ extern Net::Connection *accountServerConnection; Graphics *graphics; Game *game = 0; -unsigned char state = STATE_NULL; +State state = STATE_NULL; std::string errorMessage; Sound sound; @@ -975,7 +975,7 @@ int main(int argc, char *argv[]) desktop->setSize(screenWidth, screenHeight); - unsigned int oldstate = !state; // We start with a status change. + State oldstate = STATE_EXIT; // We start with a status change SDL_Event event; @@ -1429,9 +1429,9 @@ int main(int argc, char *argv[]) } else { - int nextState = STATE_UPDATE; + State nextState = STATE_UPDATE; currentDialog = new ServerSelectDialog(&loginData, - nextState); + nextState); positionDialog(currentDialog, screenWidth, screenHeight); if (options.chooseDefault) diff --git a/src/main.h b/src/main.h index a3894d13..75343944 100644 --- a/src/main.h +++ b/src/main.h @@ -78,7 +78,7 @@ /* * Client different States */ -enum { +enum State { STATE_EXIT, STATE_LOADDATA, STATE_LOGIN, @@ -136,7 +136,7 @@ const short maxSlot = 2; extern std::string token; extern char n_server, n_character; -extern unsigned char state; +extern State state; extern std::string errorMessage; #endif -- cgit v1.2.3-70-g09d2