summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-30 02:05:40 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 03:11:26 +0300
commita39f63cdfa5ce15b22f294a8bb1db3a036ce462d (patch)
tree4de71bde947cae0cf5d3196cd97e82f5bc537c5c /src/gui
parent02ec4369acfbf261236631e20dbb76131e7889f8 (diff)
downloadmv-a39f63cdfa5ce15b22f294a8bb1db3a036ce462d.tar.gz
mv-a39f63cdfa5ce15b22f294a8bb1db3a036ce462d.tar.bz2
mv-a39f63cdfa5ce15b22f294a8bb1db3a036ce462d.tar.xz
mv-a39f63cdfa5ce15b22f294a8bb1db3a036ce462d.zip
One part of fixes after auto checking.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/botcheckerwindow.cpp47
-rw-r--r--src/gui/chatwindow.cpp83
-rw-r--r--src/gui/skilldialog.h1
-rw-r--r--src/gui/widgets/avatarlistbox.cpp17
-rw-r--r--src/gui/widgets/chattab.h2
5 files changed, 89 insertions, 61 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index a1ad9cc2a..9265ff203 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -127,44 +127,45 @@ public:
if (!mPlayers.at(r))
continue;
- std::string name = mPlayers.at(r)->getName();
+ Being *player = mPlayers.at(r);
+ std::string name = player->getName();
gcn::Widget *widget = new Label(name);
mWidgets.push_back(widget);
- if (mPlayers.at(r)->getAttackTime() != 0)
+ if (player->getAttackTime() != 0)
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getAttackTime()));
+ - player->getAttackTime()));
}
else
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getTestTime()) + "?");
+ - player->getTestTime()) + "?");
}
mWidgets.push_back(widget);
- if (mPlayers.at(r)->getTalkTime() != 0)
+ if (player->getTalkTime() != 0)
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getTalkTime()));
+ - player->getTalkTime()));
}
else
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getTestTime()) + "?");
+ - player->getTestTime()) + "?");
}
mWidgets.push_back(widget);
- if (mPlayers.at(r)->getMoveTime() != 0)
+ if (player->getMoveTime() != 0)
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getMoveTime()));
+ - player->getMoveTime()));
}
else
{
widget = new Label(toString(curTime
- - mPlayers.at(r)->getTestTime()) + "?");
+ - player->getTestTime()) + "?");
}
mWidgets.push_back(widget);
@@ -174,20 +175,20 @@ public:
bool attackBot = false;
bool otherBot = false;
- if (curTime - mPlayers.at(r)->getTestTime() > 2 * 60)
+ if (curTime - player->getTestTime() > 2 * 60)
{
- int attack = curTime - (mPlayers.at(r)->getAttackTime()
- ? mPlayers.at(r)->getAttackTime()
- : mPlayers.at(r)->getTestTime());
- int talk = curTime - (mPlayers.at(r)->getTalkTime()
- ? mPlayers.at(r)->getTalkTime()
- : mPlayers.at(r)->getTestTime()) - attack;
- int move = curTime - (mPlayers.at(r)->getMoveTime()
- ? mPlayers.at(r)->getMoveTime()
- : mPlayers.at(r)->getTestTime()) - attack;
- int other = curTime - (mPlayers.at(r)->getOtherTime()
- ? mPlayers.at(r)->getMoveTime()
- : mPlayers.at(r)->getOtherTime()) - attack;
+ int attack = curTime - (player->getAttackTime()
+ ? player->getAttackTime()
+ : player->getTestTime());
+ int talk = curTime - (player->getTalkTime()
+ ? player->getTalkTime()
+ : player->getTestTime()) - attack;
+ int move = curTime - (player->getMoveTime()
+ ? player->getMoveTime()
+ : player->getTestTime()) - attack;
+ int other = curTime - (player->getOtherTime()
+ ? player->getMoveTime()
+ : player->getOtherTime()) - attack;
if (attack < 2 * 60)
attackBot = true;
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 0403b5e17..29c3abe51 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -510,8 +510,11 @@ void ChatWindow::action(const gcn::ActionEvent &event)
}
else if (event.getId() == ACTION_COLOR_PICKER)
{
- mChatColor = mColorPicker->getSelected();
- config.setValue("chatColor", mChatColor);
+ if (mColorPicker)
+ {
+ mChatColor = mColorPicker->getSelected();
+ config.setValue("chatColor", mChatColor);
+ }
}
if (mColorPicker && mColorPicker->isVisible()
@@ -737,7 +740,8 @@ void ChatWindow::mouseReleased(gcn::MouseEvent &event A_UNUSED)
void ChatWindow::keyPressed(gcn::KeyEvent &event)
{
- if (event.getKey().getValue() == Key::DOWN)
+ const int key = event.getKey().getValue();
+ if (key == Key::DOWN)
{
if (mCurHist != mHistory.end())
{
@@ -756,12 +760,12 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mCurHist = prevHist;
}
}
- else if (mChatInput->getText() != "")
+ else if (!mChatInput->getText().empty())
{
mChatInput->setText("");
}
}
- else if (event.getKey().getValue() == Key::UP &&
+ else if (key == Key::UP &&
mCurHist != mHistory.begin() && !mHistory.empty())
{
// Move backward through the history
@@ -770,7 +774,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatInput->setCaretPosition(static_cast<unsigned>(
mChatInput->getText().length()));
}
- else if (event.getKey().getValue() == Key::INSERT &&
+ else if (key == Key::INSERT &&
mChatInput->getText() != "")
{
// Add the current message to the history and clear the text
@@ -812,8 +816,8 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
std::list<std::string>::const_iterator it;
unsigned int f = 0;
- for (it = tab->getRows().begin();
- it != tab->getRows().end(); ++it, f++)
+ const std::list<std::string> &rows = tab->getRows();
+ for (it = rows.begin(); it != rows.end(); ++it, f++)
{
if (f == mChatHistoryIndex)
mChatInput->setText(*it);
@@ -857,25 +861,48 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
}
}
- std::string Temp;
- switch (event.getKey().getValue())
+ std::string temp;
+ switch (key)
{
- case Key::F2: Temp = "\u2318"; break;
- case Key::F3: Temp = "\u263A"; break;
- case Key::F4: Temp = "\u2665"; break;
- case Key::F5: Temp = "\u266A"; break;
- case Key::F6: Temp = "\u266B"; break;
- case Key::F7: Temp = "\u26A0"; break;
- case Key::F8: Temp = "\u2622"; break;
- case Key::F9: Temp = "\u262E"; break;
- case Key::F10: Temp = "\u2605"; break;
- case Key::F11: Temp = "\u2618"; break;
- case Key::F12: Temp = "\u2592"; break;
- default: break;
+ case Key::F2:
+ temp = "\u2318";
+ break;
+ case Key::F3:
+ temp = "\u263A";
+ break;
+ case Key::F4:
+ temp = "\u2665";
+ break;
+ case Key::F5:
+ temp = "\u266A";
+ break;
+ case Key::F6:
+ temp = "\u266B";
+ break;
+ case Key::F7:
+ temp = "\u26A0";
+ break;
+ case Key::F8:
+ temp = "\u2622";
+ break;
+ case Key::F9:
+ temp = "\u262E";
+ break;
+ case Key::F10:
+ temp = "\u2605";
+ break;
+ case Key::F11:
+ temp = "\u2618";
+ break;
+ case Key::F12:
+ temp = "\u2592";
+ break;
+ default:
+ break;
}
- if (Temp != "")
- addInputText(Temp, false);
+ if (temp != "")
+ addInputText(temp, false);
}
void ChatWindow::processEvent(Channels channel, const DepricatedEvent &event)
@@ -1343,7 +1370,7 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- unsigned long idx = line.find(": \302\202");
+ std::string::size_type idx = line.find(": \302\202");
if (idx != std::string::npos)
{
line = line.erase(idx + 2, 2);
@@ -1351,13 +1378,13 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- unsigned long idx1 = line.find("@@");
+ std::string::size_type idx1 = line.find("@@");
if (idx1 != std::string::npos)
{
- unsigned long idx2 = line.find("|", idx1);
+ std::string::size_type idx2 = line.find("|", idx1);
if (idx2 != std::string::npos)
{
- unsigned long idx3 = line.find("@@", idx2);
+ std::string::size_type idx3 = line.find("@@", idx2);
if (idx3 != std::string::npos)
{
tradeChatTab->chatLog(line, own, ignoreRecord,
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 7fc09d5a6..08371e523 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -31,6 +31,7 @@
#include <guichan/mouselistener.hpp>
#include <map>
+#include <vector>
#define SKILL_MIN_ID 200000
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 749837f7d..b4fc4fad0 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -343,16 +343,15 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
case AVATAR_PLAYER:
{
- Being* being = actorSpriteManager->findBeingByName(
- model->getAvatarAt(selected)->getName(), Being::PLAYER);
- if (being)
+ Avatar *avatar = model->getAvatarAt(selected);
+ if (avatar)
{
- viewport->showPopup(being);
- }
- else
- {
- viewport->showPlayerPopup(
- model->getAvatarAt(selected)->getName());
+ Being* being = actorSpriteManager->findBeingByName(
+ avatar->getName(), Being::PLAYER);
+ if (being)
+ viewport->showPopup(being);
+ else
+ viewport->showPlayerPopup(avatar->getName());
}
break;
}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index d11a85138..455152693 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -171,7 +171,7 @@ class ChatTab : public Tab
friend class WhisperWindow;
virtual void setCurrent()
- { setFlash(false); }
+ { setFlash(0); }
virtual void handleInput(const std::string &msg);