diff options
author | Ira Rice <irarice@gmail.com> | 2008-12-07 16:53:32 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-12-07 16:53:32 -0700 |
commit | aef082e6fe4fca268f9bfe401409eb342f82e4af (patch) | |
tree | 26e9f2f2be9ad59666a4c039c7717e0e5becd3eb /src/gui | |
parent | 7f24abc455a407e84f13d75099e36db77fa8931d (diff) | |
parent | a7c21e6f8add37af7412449742ec55c8daa8571a (diff) | |
download | mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.gz mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.bz2 mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.xz mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.zip |
Merge commit 'a7c21e6f8add37af7412449742ec55c8daa8571a'
Conflicts:
AUTHORS
CMakeLists.txt
ChangeLog
INSTALL
README
aethyra.cbp
configure.ac
data/help/changes.txt
data/help/commands.txt
data/help/header.txt
data/help/support.txt
src/Makefile.am
src/aethyra.rc
src/being.cpp
src/being.h
src/equipment.cpp
src/equipment.h
src/floor_item.h
src/game.cpp
src/gui/buddywindow.cpp
src/gui/char_select.cpp
src/gui/char_server.cpp
src/gui/chat.cpp
src/gui/chat.h
src/gui/equipmentwindow.cpp
src/gui/equipmentwindow.h
src/gui/gui.cpp
src/gui/inventorywindow.cpp
src/gui/inventorywindow.h
src/gui/itemcontainer.cpp
src/gui/itemcontainer.h
src/gui/minimap.cpp
src/gui/ministatus.cpp
src/gui/newskill.cpp
src/gui/npc_text.cpp
src/gui/npclistdialog.h
src/gui/ok_dialog.cpp
src/gui/setup_video.cpp
src/gui/skill.cpp
src/gui/skill.h
src/gui/status.h
src/gui/table_model.h
src/gui/updatewindow.cpp
src/gui/viewport.cpp
src/inventory.cpp
src/inventory.h
src/keyboardconfig.cpp
src/keyboardconfig.h
src/localplayer.cpp
src/localplayer.h
src/logindata.h
src/main.cpp
src/map.cpp
src/monster.cpp
src/monster.h
src/net/beinghandler.cpp
src/net/beinghandler.h
src/net/buysellhandler.cpp
src/net/equipmenthandler.cpp
src/net/loginhandler.cpp
src/net/loginhandler.h
src/net/network.h
src/net/npchandler.cpp
src/net/playerhandler.cpp
src/net/protocol.h
src/net/tradehandler.cpp
src/npc.cpp
src/npc.h
src/particleemitter.cpp
src/particleemitterprop.h
src/player.cpp
src/player.h
src/player_relations.cpp
src/resources/imageset.cpp
src/resources/imageset.h
src/resources/itemdb.cpp
src/resources/mapreader.cpp
src/resources/monsterinfo.h
src/text.cpp
src/text.h
src/textmanager.cpp
src/textmanager.h
src/tileset.h
src/utils/fastsqrt.h
src/utils/strprintf.cpp
src/winver.h
tools/tmxcopy/Makefile
tools/tmxcopy/base64.cpp
tools/tmxcopy/base64.h
tools/tmxcopy/tostring.h
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buddywindow.cpp | 83 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 2 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 10 | ||||
-rw-r--r-- | src/gui/char_server.h | 3 | ||||
-rw-r--r-- | src/gui/chat.cpp | 58 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 8 | ||||
-rw-r--r-- | src/gui/equipmentwindow.h | 3 | ||||
-rw-r--r-- | src/gui/gui.cpp | 2 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 27 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 15 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 4 | ||||
-rw-r--r-- | src/gui/newskill.cpp | 193 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 1 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 6 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 11 | ||||
-rw-r--r-- | src/gui/skill.cpp | 8 | ||||
-rw-r--r-- | src/gui/skill.h | 1 | ||||
-rw-r--r-- | src/gui/status.h | 4 | ||||
-rw-r--r-- | src/gui/table_model.h | 6 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 22 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 9 | ||||
-rw-r--r-- | src/gui/window.cpp | 1 |
24 files changed, 389 insertions, 96 deletions
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp new file mode 100644 index 00000000..14a941a5 --- /dev/null +++ b/src/gui/buddywindow.cpp @@ -0,0 +1,83 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "buddywindow.h" + +#include <guichan/widgets/listbox.hpp> + +#include "button.h" +#include "chat.h" +#include "scrollarea.h" + +#include "../resources/buddylist.h" + +extern ChatWindow *chatWindow; + +BuddyWindow::BuddyWindow(): + Window("Buddy") +{ + setContentSize(124, 202); + + mBuddyList = new BuddyList(); + + mListbox = new gcn::ListBox(); + mListbox->setListModel(mBuddyList); + + ScrollArea *scrollArea = new ScrollArea(mListbox); + scrollArea->setDimension(gcn::Rectangle( + 7, 5, 110, 170)); + add(scrollArea); + + Button *talk = new Button("Talk", "Talk", this); + Button *remove = new Button("Remove", "Remove", this); + Button *cancel = new Button("Cancel", "Cancel", this); + + talk->setPosition(2,180); + remove->setPosition(talk->getWidth()+2,180); + cancel->setPosition(talk->getWidth()+remove->getWidth()+2,180); + + add(talk); + add(remove); + add(cancel); +} + +void BuddyWindow::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "Talk") { + int selected = mListbox->getSelected(); + if ( selected > -1 ) + { + std::string who = mBuddyList->getElementAt(selected); + chatWindow->setInputText(who +": "); + } + } + else if (event.getId() == "Remove") { + int selected = mListbox->getSelected(); + if ( selected > -1 ) + { + std::string who = mBuddyList->getElementAt(selected); + mBuddyList->removeBuddy(who); + } + } + else if (event.getId() == "Cancel") { + setVisible(false); + } +} diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 93783ded..53cc1e8d 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -256,8 +256,6 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, int numberOfHairColors = ColorDB::size(); - printf("%d\n", numberOfHairColors); - mPlayer->setHairStyle(rand() % mPlayer->getNumOfHairstyles(), rand() % numberOfHairColors); mNameField = new TextField(""); diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 8f68e6e1..054aff84 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -45,8 +45,10 @@ class ServerListModel : public gcn::ListModel { std::string getElementAt(int i); }; -ServerSelectDialog::ServerSelectDialog(LoginData *loginData): - Window("Select Server"), mLoginData(loginData) +ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): + Window("Select Server"), + mLoginData(loginData), + mNextState(nextState) { mServerListModel = new ServerListModel(); mServerList = new ListBox(mServerListModel); @@ -103,10 +105,10 @@ ServerSelectDialog::action(const gcn::ActionEvent &event) mLoginData->hostname = iptostring(si->address); mLoginData->port = si->port; mLoginData->updateHost = si->updateHost; - state = UPDATE_STATE; + state = mNextState; } else if (event.getId() == "cancel") { - state = LOGIN_STATE; + state = LOGIN_STATE; } } diff --git a/src/gui/char_server.h b/src/gui/char_server.h index bb81d3a5..e05792f8 100644 --- a/src/gui/char_server.h +++ b/src/gui/char_server.h @@ -44,7 +44,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { * * @see Window::Window */ - ServerSelectDialog(LoginData *loginData); + ServerSelectDialog(LoginData *loginData, int nextState); /** * Destructor. @@ -61,6 +61,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { ServerListModel *mServerListModel; gcn::ListBox *mServerList; gcn::Button *mOkButton; + int mNextState; }; #endif diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index dd11cebb..3f12c462 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -257,7 +257,7 @@ bool ChatWindow::isInputFocused() return mChatInput->isFocused(); } -void ChatWindow::chatSend(const std::string & nick, std::string msg) +void ChatWindow::chatSend(const std::string &nick, std::string msg) { /* Some messages are managed client side, while others * require server handling by proper packet. Probably @@ -302,37 +302,42 @@ void ChatWindow::chatSend(const std::string & nick, std::string msg) trim(msg); } - if (command == "announce") { + if (command == "announce") + { MessageOut outMsg(mNetwork); outMsg.writeInt16(0x0099); outMsg.writeInt16(msg.length() + 4); outMsg.writeString(msg, msg.length()); return; } - if (command == "help") { + else if (command == "help") + { + msg.erase(0, 6); + trim(msg); std::size_t space = msg.find(" "); std::string msg1; - if (space == std::string::npos) { + if (space == std::string::npos) + { msg1 = ""; - } else { + } + else + { msg1 = msg.substr(space + 1, msg.length()); msg = msg.substr(0, space); } - if (msg != "" && msg.at(0) == '/') { + if (msg != "" && msg.at(0) == '/') + { msg.erase(0, 1); } - while (msg1 != "" && msg1.at(0) == ' ') { - msg1.erase(0, 1); - } + trim(msg1); help(msg, msg1); - return; } - if (command == "where") { + else if (command == "where") + { // Display the current map, X, and Y std::ostringstream where; - where << map_path << " " << player_node->mX << " " << player_node->mY; + where << map_path << " " << player_node->mX << "," << player_node->mY; chatLog(where.str(), BY_SERVER); - return; } if (command == "who") { MessageOut outMsg(mNetwork); @@ -648,20 +653,23 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog("For more information, type /help <command>", BY_SERVER); return; } - if (msg1 == "announce") { + if (msg1 == "announce") + { chatLog("Command: /announce <msg>", BY_SERVER); chatLog("*** only available to a GM ***", BY_SERVER); chatLog("This command sends the message <msg> to " "all players currently online.", BY_SERVER); return; } - if (msg1 == "clear") { + if (msg1 == "clear") + { chatLog("Command: /clear", BY_SERVER); chatLog("This command clears the chat log of previous chat.", BY_SERVER); return; } - if (msg1 == "help") { + if (msg1 == "help") + { chatLog("Command: /help", BY_SERVER); chatLog("This command displays a list of all commands available.", BY_SERVER); @@ -669,22 +677,26 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog("This command displays help on <command>.", BY_SERVER); return; } - if (msg1 == "party") { + if (msg1 == "party") + { mParty->help(msg2); return; } - if (msg1 == "present") { + if (msg1 == "present") + { chatLog("Command: /present", BY_SERVER); chatLog("This command gets a list of players within hearing " "and sends it to either the record log if recording, or the " "chat log otherwise.", BY_SERVER); return; } - if (msg1 == "record") { + if (msg1 == "record") + { mRecorder->help(msg2); return; } - if (msg1 == "toggle") { + if (msg1 == "toggle") + { chatLog("Command: /toggle <state>", BY_SERVER); chatLog("This command sets whether the return key should toggle the " "chat log, or whether the chat log turns off automatically.", @@ -696,7 +708,8 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog("This command displays the return toggle status.", BY_SERVER); return; } - if (msg1 == "where") { + if (msg1 == "where") + { chatLog("Command: /where", BY_SERVER); chatLog("This command displays the name of the current map.", BY_SERVER); @@ -709,7 +722,8 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) "double quotes (\").", BY_SERVER); return; } - if (msg1 == "who") { + if (msg1 == "who") + { chatLog("Command: /who", BY_SERVER); chatLog("This command displays the number of players currently " "online.", BY_SERVER); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index bf85f033..7e1ef315 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -22,6 +22,8 @@ #include "equipmentwindow.h" #include "../equipment.h" +#include "../inventory.h" +#include "../localplayer.h" #include "../graphics.h" #include "../inventory.h" #include "../item.h" @@ -40,7 +42,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): setCloseButton(true); setDefaultSize(5, 230, 200, 120); loadWindowState(); - inventory = player_node->getInventory(); + mInventory = player_node->getInventory(); } EquipmentWindow::~EquipmentWindow() @@ -62,7 +64,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4), 36 * (i / 4) + 25, 32, 32)); - if (!(item = inventory->getItem(mEquipment->getEquipment(i)))) + if (!(item = mInventory->getItem(mEquipment->getEquipment(i)))) continue; image = item->getImage(); @@ -75,7 +77,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32)); - if (!(item = inventory->getItem(mEquipment->getArrows()))) + if (!(item = mInventory->getItem(mEquipment->getArrows()))) return; image = item->getImage(); diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 7aacfc1e..b669f5b1 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -23,6 +23,7 @@ #define _TMW_EQUIPMENT_H #include "window.h" +#include "../inventory.h" #include "../guichanfwd.h" #include "../inventory.h" @@ -54,7 +55,7 @@ class EquipmentWindow : public Window private: Equipment *mEquipment; - Inventory *inventory; + Inventory *mInventory; }; extern EquipmentWindow *equipmentWindow; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a382ef85..70f82d9d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -110,7 +110,7 @@ Gui::Gui(Graphics *graphics): Window::setWindowContainer(guiTop); setTop(guiTop); - // Set global font + // Set global font (based on ISO-8859-15) try { mGuiFont = new gcn::ImageFont("graphics/gui/sansserif8.png", " !\"#$%&'()*+,-./" diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index a8b20d40..424fca59 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -73,7 +73,7 @@ InventoryWindow::InventoryWindow(): mWeightLabel->setPosition(8, 8); mSlots = "Slots: " + toString(player_node->getInventory()->getNumberOfSlotsUsed()) + - "/" + toString(player_node->getInventory()->getSize() - 2); + "/" + toString(player_node->getInventory()->getInventorySize()); mSlotsLabel = new TextBox(); mItemEffectLabel = new TextBox(); @@ -113,7 +113,7 @@ void InventoryWindow::logic() mSlots = "Slots: " + toString(player_node->getInventory()->getNumberOfSlotsUsed()) + - "/" + toString(player_node->getInventory()->getSize() - 2); + "/" + toString(player_node->getInventory()->getInventorySize()); draw(); } diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index fca0c72d..9e17f3da 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -64,8 +64,7 @@ ItemContainer::~ItemContainer() mSelImg->decRef(); } -void -ItemContainer::logic() +void ItemContainer::logic() { gcn::Widget::logic(); @@ -78,8 +77,7 @@ ItemContainer::logic() } } -void -ItemContainer::draw(gcn::Graphics *graphics) +void ItemContainer::draw(gcn::Graphics *graphics) { int columns = getWidth() / gridWidth; @@ -146,8 +144,7 @@ void ItemContainer::recalculateHeight() setHeight(height); } -Item* -ItemContainer::getSelectedItem() +Item *ItemContainer::getSelectedItem() { refindSelectedItem(); // Make sure that we're still current @@ -157,8 +154,7 @@ ItemContainer::getSelectedItem() return mInventory->getItem(mSelectedItemIndex); } -void -ItemContainer::selectNone() +void ItemContainer::selectNone() { setSelectedItemIndex(NO_ITEM); } @@ -166,15 +162,15 @@ ItemContainer::selectNone() void ItemContainer::refindSelectedItem() { if (mSelectedItemIndex != NO_ITEM) { - + if (mInventory->getItem(mSelectedItemIndex) && mInventory->getItem(mSelectedItemIndex)->getId() == mLastSelectedItemId) return; // we're already fine - + // Otherwise ensure the invariant: we must point to an item of the specified last ID, // or nowhere at all. - for (int i = 0; i <= mMaxItems + mOffset; i++) + for (int i = 0; i <= mMaxItems + 1; i++) if (mInventory->getItem(i) && mInventory->getItem(i)->getId() == mLastSelectedItemId) { mSelectedItemIndex = i; @@ -198,7 +194,6 @@ void ItemContainer::setSelectedItemIndex(int index) newSelectedItemIndex = NO_ITEM; else newSelectedItemIndex = index; - if (mSelectedItemIndex != newSelectedItemIndex) { mSelectedItemIndex = newSelectedItemIndex; @@ -212,8 +207,7 @@ void ItemContainer::setSelectedItemIndex(int index) } } -void -ItemContainer::distributeValueChangedEvent() +void ItemContainer::distributeValueChangedEvent() { gcn::SelectionEvent event(this); std::list<gcn::SelectionListener*>::iterator i_end = mListeners.end(); @@ -225,8 +219,7 @@ ItemContainer::distributeValueChangedEvent() } } -void -ItemContainer::mousePressed(gcn::MouseEvent &event) +void ItemContainer::mousePressed(gcn::MouseEvent &event) { int button = event.getButton(); @@ -243,8 +236,6 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) Item *item = mInventory->getItem(index); if (item) - { itemShortcut->setItemSelected(item->getId()); - } } } diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 5d22b658..8927b001 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -108,29 +108,30 @@ class ItemContainer : public gcn::Widget, private: /** - * Find the current item index by the most recently used item ID + + * Sets the currently selected item. Invalid (e.g., negative) indices set `no item'. */ - void refindSelectedItem(void); + void setSelectedItemIndex(int index); /** - * Sets the currently selected item. Invalid (e.g., negative) indices set `no item'. + * Find the current item index by the most recently used item ID */ - void setSelectedItemIndex(int index); + void refindSelectedItem(void); /** * Determine and set the height of the container. */ - void recalculateHeight(); + void recalculateHeight(void); /** * Sends out selection events to the list of selection listeners. */ - void distributeValueChangedEvent(); + void distributeValueChangedEvent(void); Inventory *mInventory; Image *mSelImg; int mSelectedItemIndex; - int mLastSelectedItemId; // last selected item ID. If we lose the item, find again by ID. + int mLastSelectedItemId; // last selected item ID. If we lose the item, find again by ID. int mMaxItems; int mOffset; diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index f8a0959a..de5e1956 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -86,7 +86,7 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0+i)); + (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0 + i)); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); if (itemShortcut->getItem(i) < 0) @@ -100,6 +100,8 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) item->isEquipped() ? "Eq." : toString(item->getQuantity()); Image* image = item->getImage(); if (image) { + const std::string label = + item->isEquipped() ? "Eq." : toString(item->getQuantity()); g->drawImage(image, itemX, itemY); g->drawText( label, diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 3a2e483d..8339e478 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -40,17 +40,13 @@ Minimap::Minimap(): Minimap::~Minimap() { if (mMapImage) - { mMapImage->decRef(); - } } void Minimap::setMapImage(Image *img) { if (mMapImage) - { mMapImage->decRef(); - } mMapImage = img; diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp new file mode 100644 index 00000000..20fc01bd --- /dev/null +++ b/src/gui/newskill.cpp @@ -0,0 +1,193 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + /* This file implements the new skill dialog for use under the latest + * version of the skill system as of 2005/02/20 + */ + +#include "newskill.h" + +#include <guichan/widgets/label.hpp> + +#include "button.h" +#include "progressbar.h" + +#include "../graphics.h" + +const char *skill_name[] = { + // 0-99 + // weapon skills 0-9 + "Short Blades", "Long Blades", "Hammers", "Archery", "Whip", + "Staves", "Throwing", "Piercing", "Hand to Hand", NULL, + // magic skills 10-19 + "Epyri (Fire)", "Merene (Water)", "Geon (Earth)", "Izurial (Air)", + "Lumine (Light)", "Tenebrae (Dark)", "Chronos (Time)", "Teless (Space)", + "Gen (Mana)", NULL, + // craft skills 20-29 + "Metalworking", "Woodworking", "Jeweler", "Cook", "Tailor", + "Alchemist", "Artisan", "Synthesis", NULL, NULL, + // general skills 30-39 + "Running", "Searching", "Sneak", "Trading", "Intimidate", + "Athletics", NULL, NULL, NULL,NULL, + // combat skills 40-49 + "Dodge", "Accuracy", "Critical", "Block", "Parry", "Diehard", "Magic Aura", + "Counter", NULL, NULL, + // resistance skills 50-59 + "Poison", "Silence", "Petrify", "Paralyze", "Blind", "Slow", "Zombie", + "Critical", NULL, NULL, + // element reistance 60-69 + "Heat (Fire)", "Chill (Water)", "Stone (Earth)", "Wind (Air)", + "Shine (Light)", "Shadow (Dark)", "Decay (Time)", "Chaos (Space)", NULL, + NULL, + // hunting skills 70-79 + "Insects", "Birds", "Lizards", "Amorphs", "Undead", "Machines", "Arcana", + "Humanoids", "Plantoids", NULL, + // stats 80-89 + "Strength", "Fortitude", "Vitality", "Menality", "Awareness", "Mana", + "Dexterity", NULL, NULL, NULL, + // unused (reserved) 90-99 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + + +NewSkillDialog::NewSkillDialog(): + Window("Skills") +{ + startPoint = 0; + for (int i = 0; i < N_SKILL_CAT_SIZE; i++) + { + mSkillLabel[i] = new gcn::Label("Empty "); + mSkillLevel[i] = new gcn::Label("00000"); + mSkillbar[i] = new ProgressBar(0.0f,100,15,0,0,255); + mSkillLevel[i]->setAlignment(Graphics::RIGHT); + add(mSkillLabel[i],40,5+i*25); + add(mSkillLevel[i],150,5+i*25); + add(mSkillbar[i],180,5+i*25); + } + // initialize the skills + for (int i = 0; i < N_SKILL; i++) + { + mPlayerSkill[i].level = 0; + mPlayerSkill[i].exp = 0; + } + resetNSD(); + + // create controls + Button *catButton[N_SKILL_CAT]; + catButton[0] = new Button("Weapons", "g1", this); + catButton[1] = new Button("Magic", "g2", this); + catButton[2] = new Button("Craft", "g3", this); + catButton[3] = new Button("General", "g4", this); + catButton[4] = new Button("Combat", "g5", this); + catButton[5] = new Button("E. Resist", "g6", this); + catButton[6] = new Button("S. Resist", "g7", this); + catButton[7] = new Button("Hunting", "g8", this); + catButton[8] = new Button("Stat", "g9", this); + + setContentSize(350, 250); + + for (int i = 0; i < 9; ++i) { + catButton[i]->setDimension(gcn::Rectangle(0, 0, 60, 20)); + catButton[i]->setPosition(290, 20 * i); + add(catButton[i]); + } + + Button *closeButton = new Button("Close", "close", this); + closeButton->setDimension(gcn::Rectangle(0,0,60,20)); + closeButton->setPosition(290, 230); + add(closeButton); + + // finsihing touches + setLocationRelativeTo(getParent()); +} + +void NewSkillDialog::action(const gcn::ActionEvent &event) +{ + int osp = startPoint; + if (event.getId() == "close") + { + setVisible(false); + } + else if (event.getId() == "g1") // weapons group 0-9 + { + startPoint =0; + } + else if (event.getId() == "g2") // magic group 10-19 + { + startPoint =10; + } + else if (event.getId() == "g3") // craft group 20-29 + { + startPoint =20; + } + else if (event.getId() == "g4") // general group 30-39 + { + startPoint =30; + } + else if (event.getId() == "g5") // combat group 40-49 + { + startPoint =40; + } + else if (event.getId() == "g6") // e. resist group 50-59 + { + startPoint =50; + } + else if (event.getId() == "g7") // s resist group 60-69 + { + startPoint =60; + } + else if (event.getId() == "g8") // hunting group 70-79 + { + startPoint =70; + } + else if (event.getId() == "g9") // stats group 80-89 + { + startPoint =80; + } + if (osp != startPoint) + { + resetNSD(); + } +} + +void NewSkillDialog::resetNSD() +{ + for (int a = 0; a < N_SKILL_CAT_SIZE; a++) + { + if (skill_name[a + startPoint]) + { + mSkillLabel[a]->setCaption(skill_name[a + startPoint]); + mSkillLabel[a]->setVisible(true); + char tmp[5]; + sprintf(tmp, "%d", mPlayerSkill[a+startPoint].level); + mSkillLevel[a]->setCaption(tmp); + mSkillLevel[a]->setVisible(true); + mSkillbar[a]->setProgress(0.0f); + mSkillbar[a]->setVisible(true); + } + else + { + mSkillLevel[a]->setVisible(false); + mSkillLabel[a]->setVisible(false); + mSkillbar[a]->setVisible(false); + } + } +} diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index d83e9dea..b53de828 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -59,7 +59,6 @@ void NpcTextDialog::setText(const std::string &text) { const gcn::Rectangle &area = getChildrenArea(); const int width = area.width; - const int height = area.height; mText = text; mTextBox->setMinWidth(width - 30); diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 04c5c4d9..099d03c0 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -86,9 +86,9 @@ class NpcListDialog : public Window, public gcn::ActionListener, private: gcn::ListBox *mItemList; - ScrollArea *scrollArea; - Button *okButton; - Button *cancelButton; + gcn::ScrollArea *scrollArea; + gcn::Button *okButton; + gcn::Button *cancelButton; std::vector<std::string> mItems; }; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index ec5b1d0a..15841615 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -289,11 +289,12 @@ void Setup_Video::apply() bool fullscreen = mFsCheckBox->isSelected(); if (fullscreen != (config.getValue("screen", 0) == 1)) { - - /* Commented out the openGL test because - * the fullscreen mode change works fine, but - * will need to test it on windows so not - * deleting entirely until then --kraant*/ + /* The OpenGL test is only necessary on Windows, since switching + * to/from full screen works fine on Linux. On Windows we'd have to + * reinitialize the OpenGL state and reload all textures. + * + * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode + */ #ifdef WIN32 // checks for opengl usage diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 36c3a305..8e61dea4 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -87,7 +87,8 @@ public: SkillInfo const *info; char tmp[128]; - if (skill->id >= 0 && (unsigned int) skill->id < skill_db.size()) + if (skill->id >= 0 + && (unsigned int) skill->id < skill_db.size()) info = &skill_db[skill->id]; else info = &fakeSkillInfo; @@ -195,13 +196,14 @@ void SkillDialog::update() if (selectedSkill >= 0) { int skillId = mSkillList[selectedSkill]->id; bool modifiable; - + if (skillId >= 0 && (unsigned int) skillId < skill_db.size()) modifiable = skill_db[skillId].modifiable; else modifiable = false; - mIncButton->setEnabled(modifiable && player_node->mSkillPoint > 0); + mIncButton->setEnabled(modifiable + && player_node->mSkillPoint > 0); } else mIncButton->setEnabled(false); diff --git a/src/gui/skill.h b/src/gui/skill.h index ee579dd5..2095e098 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -30,6 +30,7 @@ #include "scrollarea.h" #include "table.h" #include "window.h" +#include "table.h" #include "../guichanfwd.h" diff --git a/src/gui/status.h b/src/gui/status.h index 4fbce445..eb4171c9 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -68,7 +68,9 @@ class StatusWindow : public Window, public gcn::ActionListener /** * Status Part */ - gcn::Label *mLvlLabel, *mJobLvlLabel, *mGpLabel, *mHpLabel, *mHpValueLabel; + gcn::Label *mLvlLabel, *mJobLvlLabel; + gcn::Label *mGpLabel; + gcn::Label *mHpLabel, *mHpValueLabel; gcn::Label *mMpLabel, *mMpValueLabel; gcn::Label *mXpLabel, *mXpValueLabel, *mJobXpLabel, *mJobValueLabel; ProgressBar *mHpBar, *mMpBar; diff --git a/src/gui/table_model.h b/src/gui/table_model.h index 4022e369..a52a7561 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -127,9 +127,9 @@ public: */ virtual void resize(void); - virtual int getRows(); - virtual int getColumns(); - virtual int getRowHeight(); + virtual int getRows(void); + virtual int getColumns(void); + virtual int getRowHeight(void); virtual int getColumnWidth(int index); virtual gcn::Widget *getElementAt(int row, int column); diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 1097f072..36d00bec 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -309,14 +309,15 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15); - struct curl_slist *pHeaders=NULL; - if(uw->mDownloadStatus != UPDATE_RESOURCES){ - /*caching breaks things when resources2.txt is cached - *so caching is turned off on the proxy with this header - *change*/ - pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); - pHeaders = curl_slist_append(pHeaders, "Cache-Control: no-cache"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders); + struct curl_slist *pHeaders = NULL; + if (uw->mDownloadStatus != UPDATE_RESOURCES) + { + // Make sure the resources2.txt and news.txt aren't cached, + // in order to always get the latest version. + pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); + pHeaders = + curl_slist_append(pHeaders, "Cache-Control: no-cache"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders); } if ((res = curl_easy_perform(curl)) != 0) @@ -343,8 +344,9 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_cleanup(curl); - if(uw->mDownloadStatus != UPDATE_RESOURCES){ - curl_slist_free_all(pHeaders); + if (uw->mDownloadStatus != UPDATE_RESOURCES) + { + curl_slist_free_all(pHeaders); } if (!uw->mStoreInMemory) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 3f0f546e..e50903b6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -48,6 +48,8 @@ extern volatile int tick_time; +extern volatile int tick_time; + Viewport::Viewport(): mMap(0), mPixelViewX(0.0f), @@ -196,17 +198,16 @@ Viewport::draw(gcn::Graphics *gcnGraphics) } } - // Draw names + // Draw text if (textManager) { - textManager->draw(graphics, (int) mPixelViewX, (int) mPixelViewY); + textManager->draw(graphics, mPixelViewX, mPixelViewY); } - // Draw player speech, and emotion sprite as needed + // Draw player names, speech, and emotion sprite as needed Beings &beings = beingManager->getAll(); for (BeingIterator i = beings.begin(); i != beings.end(); i++) { - (*i)->drawSpeech(graphics, -(int) mPixelViewX, -(int) mPixelViewY); (*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY); } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 48964121..30456a81 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -22,6 +22,7 @@ #include <algorithm> #include <cassert> #include <climits> +#include <cassert> #include <guichan/exception.hpp> |