summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-16 15:50:00 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-16 15:50:00 +0000
commit32badd4b6f843cb74fdc3238fe92119518c8c0ab (patch)
treeade2ace7f5ef62ae9fd14c6409d9c2df43a2348b /src/gui
parent65ccfccfc1e35a2e65638aea61c46e4e51bd874e (diff)
downloadmana-client-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.gz
mana-client-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.bz2
mana-client-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.xz
mana-client-32badd4b6f843cb74fdc3238fe92119518c8c0ab.zip
A bunch of cosmetic changes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp12
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/checkbox.cpp3
-rw-r--r--src/gui/equipmentwindow.cpp8
-rw-r--r--src/gui/help.cpp3
-rw-r--r--src/gui/itemcontainer.cpp6
-rw-r--r--src/gui/listbox.cpp5
-rw-r--r--src/gui/listbox.h12
-rw-r--r--src/gui/login.cpp8
-rw-r--r--src/gui/ministatus.cpp32
-rw-r--r--src/gui/window.cpp25
11 files changed, 38 insertions, 78 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 558c5558..7e0e4849 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -197,9 +197,9 @@ ChatWindow::action(const std::string& eventId)
{
std::string message = mChatInput->getText();
- if (message.length() > 0) {
+ if (!message.empty()) {
// If message different from previous, put it in the history
- if (mHistory.size() == 0 || message != mHistory.back()) {
+ if (mHistory.empty() || message != mHistory.back()) {
mHistory.push_back(message);
}
@@ -207,7 +207,7 @@ ChatWindow::action(const std::string& eventId)
mCurHist = mHistory.end();
// Send the message to the server
- chatSend(player_node->getName().c_str(), message.c_str());
+ chatSend(player_node->getName(), message);
// Clear the text from the chat input
mChatInput->setText("");
@@ -252,7 +252,7 @@ ChatWindow::isFocused()
}
void
-ChatWindow::chatSend(std::string nick, std::string msg)
+ChatWindow::chatSend(const std::string &nick, std::string msg)
{
// Prepare command
if (msg.substr(0, 1) == "/")
@@ -292,9 +292,7 @@ ChatWindow::chatSend(std::string nick, std::string msg)
}
// Prepare ordinary message
else {
- nick += " : ";
- nick += msg;
- msg = nick;
+ msg = nick + " : " + msg;
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_CHAT_MESSAGE);
diff --git a/src/gui/chat.h b/src/gui/chat.h
index f1c48569..80e57a84 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -182,7 +182,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
* chatlog.chat_send("Zaeiru", "Hello to all users on the screen!");
*/
void
- chatSend(std::string nick, std::string msg);
+ chatSend(const std::string &nick, std::string msg);
/** Called when key is pressed */
void keyPress(const gcn::Key& key);
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index 7506d3c0..ec7eb578 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -37,10 +37,9 @@ Image *CheckBox::checkBoxDisabledChecked;
CheckBox::CheckBox(const std::string& caption, bool marked):
gcn::CheckBox(caption, marked)
{
- ResourceManager *resman = ResourceManager::getInstance();
-
if (instances == 0)
{
+ ResourceManager *resman = ResourceManager::getInstance();
Image *checkBox = resman->getImage("graphics/gui/checkbox.png");
checkBoxNormal = checkBox->getSubImage(0, 0, 9, 10);
checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 61a9ad55..64c368bc 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -60,8 +60,10 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
Item *item;
Image *image;
+ // Rectangles around items are black
+ graphics->setColor(gcn::Color(0, 0, 0));
+
for (int i = 0; i < 8; i++) {
- graphics->setColor(gcn::Color(0, 0, 0));
graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4),
36 * (i / 4) + 25, 32, 32));
@@ -74,7 +76,6 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
}
- graphics->setColor(gcn::Color(0, 0, 0));
graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32));
if (!(item = mEquipment->getArrows())) {
@@ -86,6 +87,5 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
std::stringstream n;
n << item->getQuantity();
- graphics->drawText(n.str(), 170, 62,
- gcn::Graphics::CENTER);
+ graphics->drawText(n.str(), 170, 62, gcn::Graphics::CENTER);
}
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 6b2eca6b..dfb814db 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -26,9 +26,6 @@
#include "button.h"
#include "browserbox.h"
#include "scrollarea.h"
-#include "textbox.h"
-
-#include "../log.h"
#include "../resources/resourcemanager.h"
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 874c0b63..e0730ced 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -76,8 +76,7 @@ void ItemContainer::draw(gcn::Graphics* graphics)
{
int gridWidth = mItemset->get(0)->getWidth() + 4;
int gridHeight = mItemset->get(0)->getHeight() + 10;
- int w = getWidth();
- int columns = w / gridWidth;
+ int columns = getWidth() / gridWidth;
// Have at least 1 column
if (columns < 1)
@@ -170,8 +169,7 @@ void ItemContainer::mousePress(int mx, int my, int button)
{
int gridWidth = mItemset->get(0)->getWidth() + 4;
int gridHeight = mItemset->get(0)->getHeight() + 10;
- int w = getWidth();
- int columns = w / gridWidth;
+ int columns = getWidth() / gridWidth;
if (button == gcn::MouseInput::LEFT || gcn::MouseInput::RIGHT)
{
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index 5b20bb55..df03b81b 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -27,11 +27,6 @@
#include <guichan/graphics.hpp>
#include <guichan/listmodel.hpp>
-ListBox::ListBox():
- gcn::ListBox()
-{
-}
-
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel)
{
diff --git a/src/gui/listbox.h b/src/gui/listbox.h
index 23b81a57..5999f7a7 100644
--- a/src/gui/listbox.h
+++ b/src/gui/listbox.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef __TMW_LISTBOX_H__
-#define __TMW_LISTBOX_H__
+#ifndef _TMW_LISTBOX_H
+#define _TMW_LISTBOX_H
#include <guichan/widgets/listbox.hpp>
@@ -33,16 +33,12 @@
*
* \ingroup GUI
*/
-class ListBox : public gcn::ListBox {
+class ListBox : public gcn::ListBox
+{
public:
/**
* Constructor.
*/
- ListBox();
-
- /**
- * Constructor.
- */
ListBox(gcn::ListModel *listModel);
/**
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index d6c8bfea..ee648669 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -39,7 +39,7 @@
void
WrongDataNoticeListener::setTarget(gcn::TextField *textField)
{
- this->mTarget = textField;
+ mTarget = textField;
}
void
@@ -114,7 +114,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
setLocationRelativeTo(getParent());
- if (!mUserField->getText().length()) {
+ if (mUserField->getText().empty()) {
mUserField->requestFocus();
} else {
mPassField->requestFocus();
@@ -134,9 +134,9 @@ LoginDialog::action(const std::string& eventId)
if (eventId == "ok")
{
// Check login
- if (mUserField->getText().length() == 0)
+ if (mUserField->getText().empty())
{
- mWrongDataNoticeListener->setTarget(this->mPassField);
+ mWrongDataNoticeListener->setTarget(mPassField);
OkDialog *dlg = new OkDialog("Error", "Enter your username first");
dlg->addActionListener(mWrongDataNoticeListener);
}
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index e4cfc6a6..fc2f451b 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -23,7 +23,6 @@
#include "ministatus.h"
-#include <guichan/imagefont.hpp>
#include <guichan/widgets/label.hpp>
#include <sstream>
@@ -48,12 +47,18 @@ MiniStatusWindow::MiniStatusWindow():
mHpBar->setPosition(0, 3);
mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
+ mHpLabel->setDimension(mHpBar->getDimension());
+ mMpLabel->setDimension(mMpBar->getDimension());
+
mHpLabel->setForegroundColor(gcn::Color(255, 255, 255));
mMpLabel->setForegroundColor(gcn::Color(255, 255, 255));
mHpLabel->setFont(speechFont);
mMpLabel->setFont(speechFont);
+ mHpLabel->setAlignment(gcn::Graphics::CENTER);
+ mMpLabel->setAlignment(gcn::Graphics::CENTER);
+
add(mHpBar);
add(mMpBar);
add(mHpLabel);
@@ -70,16 +75,13 @@ void MiniStatusWindow::update()
{
mHpBar->setColor(223, 32, 32); // Red
}
+ else if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
+ {
+ mHpBar->setColor(230, 171, 34); // Orange
+ }
else
{
- if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
- {
- mHpBar->setColor(230, 171, 34); // Orange
- }
- else
- {
- mHpBar->setColor(0, 171, 34); // Green
- }
+ mHpBar->setColor(0, 171, 34); // Green
}
mHpBar->setProgress((float)player_node->mHp / (float)player_node->mMaxHp);
@@ -89,21 +91,9 @@ void MiniStatusWindow::update()
std::stringstream updatedText;
updatedText << player_node->mHp;
mHpLabel->setCaption(updatedText.str());
- mHpLabel->adjustSize();
updatedText.str("");
updatedText << player_node->mMp;
mMpLabel->setCaption(updatedText.str());
- mMpLabel->adjustSize();
- mHpLabel->setPosition(
- mHpBar->getX() +
- int((mHpBar->getWidth() / 2) - (mHpLabel->getWidth() / 2)),
- mHpBar->getY() +
- int((mHpBar->getHeight() / 2) - (mHpLabel->getHeight() / 2)));
- mMpLabel->setPosition(
- mMpBar->getX() +
- int((mMpBar->getWidth() / 2) - (mMpLabel->getWidth() / 2)),
- mMpBar->getY() +
- int((mMpBar->getHeight() / 2) - (mMpLabel->getHeight() / 2)));
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 3b577116..492fe292 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -46,25 +46,12 @@ Image *Window::resizeGrip;
class WindowConfigListener : public ConfigListener
{
- public:
- /**
- * Called when an config option changes.
- */
- void optionChanged(const std::string &name)
- {
- if (name == "guialpha")
- {
- float guiAlpha = config.getValue("guialpha", 0.8);
-
- for (int i = 0; i < 9; i++)
- {
- if (Window::border.grid[i]->getAlpha() != guiAlpha)
- {
- Window::border.grid[i]->setAlpha(guiAlpha);
- }
- }
- }
- }
+ void optionChanged(const std::string &)
+ {
+ for_each(Window::border.grid, Window::border.grid + 9,
+ std::bind2nd(std::mem_fun(&Image::setAlpha),
+ config.getValue("guialpha", 0.8)));
+ }
};
Window::Window(const std::string& caption, bool modal, Window *parent):