diff options
author | Fate <fate-tmw@googlemail.com> | 2008-12-06 19:50:57 -0700 |
---|---|---|
committer | Fate <fate-tmw@googlemail.com> | 2008-12-06 19:50:57 -0700 |
commit | 483941ef2a4faef54865b3ce2e316cb32ed8cf64 (patch) | |
tree | a542f040a80497eca957c36adbfb490ed419b02b /src/gui | |
parent | 617fb41e21710856c1451058481e5df3756fb355 (diff) | |
parent | 416e28057f5a6073a2ef44f296ed1c8bc1280bf6 (diff) | |
download | mana-483941ef2a4faef54865b3ce2e316cb32ed8cf64.tar.gz mana-483941ef2a4faef54865b3ce2e316cb32ed8cf64.tar.bz2 mana-483941ef2a4faef54865b3ce2e316cb32ed8cf64.tar.xz mana-483941ef2a4faef54865b3ce2e316cb32ed8cf64.zip |
Merge branch 'master' of git@gitorious.org:tmw/eathena
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 9 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 42 | ||||
-rw-r--r-- | src/gui/npc_text.h | 22 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 47 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 27 | ||||
-rw-r--r-- | src/gui/status.cpp | 2 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 16 |
7 files changed, 118 insertions, 47 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index a96c2eda..b9e11dad 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -327,7 +327,10 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE) { - chatLog(map_path, BY_SERVER); + // Display the current map, X, and Y + std::ostringstream where; + where << map_path << " " << player_node->mX << "," << player_node->mY; + chatLog(where.str(), BY_SERVER); } else if (msg.substr(0, IS_WHO_LENGTH) == IS_WHO) { @@ -339,9 +342,9 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) mTextOutput->clearRows(); } else if (msg.substr(0, IS_WHISPER_LENGTH) == IS_WHISPER) - whisper(nick, msg, IS_WHISPER_LENGTH + 1); + whisper(nick, msg, IS_WHISPER_LENGTH); else if (msg.substr(0, IS_SHORT_WHISPER_LENGTH) == IS_SHORT_WHISPER) - whisper(nick, msg, IS_SHORT_WHISPER_LENGTH + 1); + whisper(nick, msg, IS_SHORT_WHISPER_LENGTH); else { chatLog("Unknown command", BY_SERVER); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 3c4beaf3..34c9cce1 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -32,10 +32,16 @@ NpcTextDialog::NpcTextDialog(): Window("NPC") { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mTextBox = new TextBox; mTextBox->setEditable(false); - gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - Button *okButton = new Button("OK", "ok", this); + + scrollArea = new ScrollArea(mTextBox); + okButton = new Button("OK", "ok", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -52,20 +58,36 @@ NpcTextDialog::NpcTextDialog(): setLocationRelativeTo(getParent()); } -void -NpcTextDialog::setText(const std::string &text) +void NpcTextDialog::setText(const std::string &text) +{ + mText = text; + mTextBox->setTextWrapped(mText); +} + +void NpcTextDialog::addText(const std::string &text) { - mTextBox->setTextWrapped(text); + setText(mText + text + "\n"); } -void -NpcTextDialog::addText(const std::string &text) +void NpcTextDialog::widgetResized(const gcn::Event &event) { - mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); + Window::widgetResized(event); + + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + okButton->setPosition( + width - 5 - okButton->getWidth(), + height - 5 - okButton->getHeight()); + + // Set the text again so that it gets wrapped according to the new size + mTextBox->setTextWrapped(mText); } -void -NpcTextDialog::action(const gcn::ActionEvent &event) +void NpcTextDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 2c9771d3..76161f88 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -45,18 +45,23 @@ class NpcTextDialog : public Window, public gcn::ActionListener NpcTextDialog(); /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Sets the text shows in the dialog. * * @param string The new text. */ - void - setText(const std::string &string); + void setText(const std::string &string); /** * Adds the text to the text shows in the dialog. Also adds a newline @@ -64,11 +69,14 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @param string The text to add. */ - void - addText(const std::string &string); + void addText(const std::string &string); private: + gcn::Button *okButton; + gcn::ScrollArea *scrollArea; TextBox *mTextBox; + + std::string mText; }; -#endif +#endif // _TMW_NPC_TEXT_H diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 90444f1a..cdd38312 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -32,10 +32,15 @@ NpcListDialog::NpcListDialog(): Window("NPC") { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mItemList = new ListBox(this); - ScrollArea *scrollArea = new ScrollArea(mItemList); - Button *okButton = new Button("OK", "ok", this); - Button *cancelButton = new Button("Cancel", "cancel", this); + scrollArea = new ScrollArea(mItemList); + okButton = new Button("OK", "ok", this); + cancelButton = new Button("Cancel", "cancel", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -59,37 +64,49 @@ NpcListDialog::NpcListDialog(): setLocationRelativeTo(getParent()); } -int -NpcListDialog::getNumberOfElements() +int NpcListDialog::getNumberOfElements() { return mItems.size(); } -std::string -NpcListDialog::getElementAt(int i) +std::string NpcListDialog::getElementAt(int i) { return mItems[i]; } -void -NpcListDialog::parseItems(const std::string &itemString) +void NpcListDialog::parseItems(const std::string &itemString) { std::istringstream iss(itemString); std::string tmp; - while(getline(iss, tmp, ':')) { + while (getline(iss, tmp, ':')) mItems.push_back(tmp); - } } -void -NpcListDialog::reset() +void NpcListDialog::reset() { mItems.clear(); } -void -NpcListDialog::action(const gcn::ActionEvent &event) +void NpcListDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + cancelButton->setPosition( + width - 5 - cancelButton->getWidth(), + height - 5 - cancelButton->getHeight()); + okButton->setPosition( + cancelButton->getX() - 5 - okButton->getWidth(), + cancelButton->getY()); +} + +void NpcListDialog::action(const gcn::ActionEvent &event) { int choice = 0; diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 0e6760f1..f548dbba 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -49,41 +49,46 @@ class NpcListDialog : public Window, public gcn::ActionListener, NpcListDialog(); /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Returns the number of items in the choices list. */ - int - getNumberOfElements(); + int getNumberOfElements(); /** * Returns the name of item number i of the choices list. */ - std::string - getElementAt(int i); + std::string getElementAt(int i); /** * Fills the options list for an NPC dialog. * * @param itemString A string with the options separated with colons. */ - void - parseItems(const std::string &itemString); + void parseItems(const std::string &itemString); /** * Resets the list by removing all items. */ - void - reset(); + void reset(); private: gcn::ListBox *mItemList; + gcn::ScrollArea *scrollArea; + gcn::Button *okButton; + gcn::Button *cancelButton; std::vector<std::string> mItems; }; -#endif +#endif // _TMW_GUI_NPCLISTDIALOG_H diff --git a/src/gui/status.cpp b/src/gui/status.cpp index b9f28562..1a257ae8 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -39,7 +39,7 @@ StatusWindow::StatusWindow(LocalPlayer *player): setResizable(true); setCloseButton(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, - (windowContainer->getHeight() - 255) / 2, 365, 255); + (windowContainer->getHeight() - 255) / 2, 365, 275); loadWindowState(); // ---------------------- diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index c0344b72..7f7d45fc 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -310,6 +310,17 @@ 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) + { + // 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) { uw->mDownloadStatus = UPDATE_ERROR; @@ -334,6 +345,11 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_cleanup(curl); + if (uw->mDownloadStatus != UPDATE_RESOURCES) + { + curl_slist_free_all(pHeaders); + } + if (!uw->mStoreInMemory) { // Don't check resources2.txt checksum |