From bb7c5ce187c0d6c555fbc390859b054e6c8dfcd2 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 6 Dec 2008 15:16:42 +0000 Subject: Fix whispering --- src/gui/chat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5817adbd..66f6600f 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -339,9 +339,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); -- cgit v1.2.3-70-g09d2 From 3b7d0af6f0c61e1087838c14519e099dbbe47ec2 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 6 Dec 2008 23:44:17 +0100 Subject: Made /where response include position information Change ported from Aethyra. --- src/gui/chat.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 66f6600f..1c7629ae 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) { -- cgit v1.2.3-70-g09d2 From 523eed88816298b1660ecb9e67db80776e4007bb Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 1 Nov 2008 03:36:47 +0000 Subject: Made NPC dialogues resizeable. (cherry picked from Aethyra commit 81299ca9acc39dec62e1e504781721ad0db0d471) Conflicts: src/gui/inventorywindow.cpp src/gui/npc_text.cpp --- src/gui/npc_text.cpp | 37 +++++++++++++++++++++++++++++++++---- src/gui/npc_text.h | 16 ++++++++++++++++ src/gui/npclistdialog.cpp | 33 ++++++++++++++++++++++++++++++--- src/gui/npclistdialog.h | 15 +++++++++++++++ 4 files changed, 94 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 3c4beaf3..ad2ccdce 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); @@ -55,13 +61,36 @@ NpcTextDialog::NpcTextDialog(): void NpcTextDialog::setText(const std::string &text) { - mTextBox->setTextWrapped(text); + mText = text; + draw(); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); + mText = mTextBox->getText() + text + "\n"; + draw(); +} + +void NpcTextDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + draw(); +} + +void NpcTextDialog::draw() +{ + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + mTextBox->setTextWrapped(mText); + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + okButton->setPosition( + width - 5 - okButton->getWidth(), + height - 5 - okButton->getHeight()); } void diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 2c9771d3..939fb8fa 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -44,6 +44,18 @@ class NpcTextDialog : public Window, public gcn::ActionListener */ NpcTextDialog(); + /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** + * Redraws the window + */ + void draw(); + /** * Called when receiving actions from the widgets. */ @@ -68,7 +80,11 @@ class NpcTextDialog : public Window, public gcn::ActionListener addText(const std::string &string); private: + gcn::Button *okButton; + gcn::ScrollArea *scrollArea; TextBox *mTextBox; + + std::string mText; }; #endif diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 90444f1a..4f3bc893 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); @@ -88,6 +93,28 @@ NpcListDialog::reset() mItems.clear(); } +void NpcListDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + draw(); +} + +void NpcListDialog::draw() +{ + 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) { diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 0e6760f1..0c9ca495 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -48,6 +48,18 @@ class NpcListDialog : public Window, public gcn::ActionListener, */ NpcListDialog(); + /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** + * Redraws the window + */ + void draw(); + /** * Called when receiving actions from the widgets. */ @@ -82,6 +94,9 @@ class NpcListDialog : public Window, public gcn::ActionListener, private: gcn::ListBox *mItemList; + gcn::ScrollArea *scrollArea; + gcn::Button *okButton; + gcn::Button *cancelButton; std::vector mItems; }; -- cgit v1.2.3-70-g09d2 From 43eb6ba950dd8bf978e539c7c7460ef5096438de Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 7 Dec 2008 00:23:59 +0100 Subject: Fixed wrapping in some cases, removed draw method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'draw' method was confusingly named, and was actually for updating the GUI after a resize. Its functionality has been merged into 'widgetResized'. The wrapping was broken in the case where text was added to the NPC dialog, cause it was added to an already wrapped string, causing the wrapping to become permanent. Sorry for all the reformatting. Signed-off-by: Bjørn Lindeijer --- src/gui/npc_text.cpp | 23 ++++++++--------------- src/gui/npc_text.h | 16 ++++------------ src/gui/npclistdialog.cpp | 22 ++++++---------------- src/gui/npclistdialog.h | 22 ++++++---------------- 4 files changed, 24 insertions(+), 59 deletions(-) (limited to 'src/gui') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index ad2ccdce..34c9cce1 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -58,43 +58,36 @@ NpcTextDialog::NpcTextDialog(): setLocationRelativeTo(getParent()); } -void -NpcTextDialog::setText(const std::string &text) +void NpcTextDialog::setText(const std::string &text) { mText = text; - draw(); + mTextBox->setTextWrapped(mText); } -void -NpcTextDialog::addText(const std::string &text) +void NpcTextDialog::addText(const std::string &text) { - mText = mTextBox->getText() + text + "\n"; - draw(); + setText(mText + text + "\n"); } void NpcTextDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); - draw(); -} -void NpcTextDialog::draw() -{ const gcn::Rectangle &area = getChildrenArea(); const int width = area.width; const int height = area.height; - mTextBox->setTextWrapped(mText); - 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 939fb8fa..76161f88 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -51,24 +51,17 @@ class NpcTextDialog : public Window, public gcn::ActionListener */ void widgetResized(const gcn::Event &event); - /** - * Redraws the window - */ - void draw(); - /** * 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 @@ -76,8 +69,7 @@ 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; @@ -87,4 +79,4 @@ class NpcTextDialog : public Window, public gcn::ActionListener std::string mText; }; -#endif +#endif // _TMW_NPC_TEXT_H diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 4f3bc893..cdd38312 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -64,31 +64,26 @@ 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(); } @@ -96,11 +91,7 @@ NpcListDialog::reset() void NpcListDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); - draw(); -} -void NpcListDialog::draw() -{ const gcn::Rectangle &area = getChildrenArea(); const int width = area.width; const int height = area.height; @@ -115,8 +106,7 @@ void NpcListDialog::draw() cancelButton->getY()); } -void -NpcListDialog::action(const gcn::ActionEvent &event) +void NpcListDialog::action(const gcn::ActionEvent &event) { int choice = 0; diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 0c9ca495..f548dbba 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -55,42 +55,32 @@ class NpcListDialog : public Window, public gcn::ActionListener, */ void widgetResized(const gcn::Event &event); - /** - * Redraws the window - */ - void draw(); - /** * 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; @@ -101,4 +91,4 @@ class NpcListDialog : public Window, public gcn::ActionListener, std::vector mItems; }; -#endif +#endif // _TMW_GUI_NPCLISTDIALOG_H -- cgit v1.2.3-70-g09d2 From ad8b5f6389562a1f68f2821753317ea7c22bf2ea Mon Sep 17 00:00:00 2001 From: Douglas Boffey Date: Fri, 8 Aug 2008 09:05:28 +0000 Subject: Changed the status window so that all the information appears by default (cherry picked from Aethyra commit 0f033c073c7ae630c9359da358128f5f425f01a6) --- src/gui/status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') 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(); // ---------------------- -- cgit v1.2.3-70-g09d2 From 047f598be826dd57dd1124db914e8367256112be Mon Sep 17 00:00:00 2001 From: Kraant Date: Sun, 10 Aug 2008 10:56:58 +0000 Subject: Set headers for CURL so that proxies won't cache files to fix bug that causes resources2.txt to be old and out of sync with the files in the directory. (cherry picked from Aethyra commit ccacde4192268fbf5250e9bd6894d158f957922c) --- src/gui/updatewindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gui') diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index c0344b72..d453e22a 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -310,6 +310,13 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15); + /*caching breaks things when resources2.txt is cached + *so caching is turned off on the proxy with this header + *change*/ + struct curl_slist *pHeaders=NULL; + pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders); + if ((res = curl_easy_perform(curl)) != 0) { uw->mDownloadStatus = UPDATE_ERROR; @@ -334,6 +341,8 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_cleanup(curl); + curl_slist_free_all(pHeaders); + if (!uw->mStoreInMemory) { // Don't check resources2.txt checksum -- cgit v1.2.3-70-g09d2 From cabf8905526b6601813573d049f6afaf364e1cac Mon Sep 17 00:00:00 2001 From: Kraant Date: Sun, 10 Aug 2008 13:00:33 +0000 Subject: Changed proxy fix to only tell the proxy to no-cache for news.txt and resources2.txt. (cherry picked from Aethyra commit 3206b3254a1a9b90bbdbd1a7178e4df043a5ee26) --- src/gui/updatewindow.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index d453e22a..2edb1a9a 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -310,12 +310,15 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15); - /*caching breaks things when resources2.txt is cached - *so caching is turned off on the proxy with this header - *change*/ struct curl_slist *pHeaders=NULL; - pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders); + 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); + } if ((res = curl_easy_perform(curl)) != 0) { @@ -341,7 +344,9 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_cleanup(curl); - curl_slist_free_all(pHeaders); + if(uw->mDownloadStatus != UPDATE_RESOURCES){ + curl_slist_free_all(pHeaders); + } if (!uw->mStoreInMemory) { -- cgit v1.2.3-70-g09d2 From 416e28057f5a6073a2ef44f296ed1c8bc1280bf6 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 7 Dec 2008 00:59:09 +0100 Subject: Some code reformatting and updated NEWS --- NEWS | 2 ++ src/gui/updatewindow.cpp | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/NEWS b/NEWS index 56beff06..52dbf700 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ - Extended particle emitters with properties that can change over time - Extended the GUI font to support more characters - Only require a restart to switch to full screen with OpenGL on Windows +- Make sure news and update file list aren't cached (from Aethyra) +- Made NPC dialogs resizable (from Aethyra) - Fixed visibility of trade window on startup - Fixed a client input freeze when closing NPC script from server - Fixed dead players to lie on the ground instead of standing around diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 2edb1a9a..7f7d45fc 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -310,14 +310,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) @@ -344,8 +345,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) -- cgit v1.2.3-70-g09d2