summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
commit8bde9095c5840b8d62ebafe11beaed98877d6ac2 (patch)
tree537f717a339d1247cae222eb7a354ea5dbe8babf /src/gui
parenta246c08cef5e4d598fc07a681eb971bfbcf01519 (diff)
downloadmana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.gz
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.bz2
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.xz
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.zip
* Made Sprite into an interface implemented by both FloorItem and Being, which
hook themselves into the map on construction. The improved fringe layer is working as expected now. * Made sure TMW compiles without warnings even when using "-Wconversion -Wshadow -Wcast-qual -Wwrite-strings -ansi -pedantic", lots of cleanups. * Added two new small tilesets that contain the desert tiles that are twice and three times the height of a normal tile. One well in new_3-1 has been converted to use the new double tiles for testing purposes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chargedialog.cpp5
-rw-r--r--src/gui/chargedialog.h8
-rw-r--r--src/gui/chat.cpp20
-rw-r--r--src/gui/chat.h3
-rw-r--r--src/gui/equipmentwindow.cpp5
-rw-r--r--src/gui/equipmentwindow.h8
-rw-r--r--src/gui/gui.cpp7
-rw-r--r--src/gui/help.cpp9
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/gui/item_amount.cpp2
-rw-r--r--src/gui/itemcontainer.cpp10
-rw-r--r--src/gui/itemcontainer.h2
-rw-r--r--src/gui/linkhandler.h8
-rw-r--r--src/gui/login.cpp64
-rw-r--r--src/gui/menuwindow.cpp9
-rw-r--r--src/gui/newskill.cpp3
-rw-r--r--src/gui/npc_text.cpp15
-rw-r--r--src/gui/popupmenu.cpp78
-rw-r--r--src/gui/popupmenu.h7
-rw-r--r--src/gui/progressbar.cpp73
-rw-r--r--src/gui/progressbar.h38
-rw-r--r--src/gui/scrollarea.cpp21
-rw-r--r--src/gui/scrollarea.h10
-rw-r--r--src/gui/skill.cpp2
-rw-r--r--src/gui/status.cpp7
-rw-r--r--src/gui/trade.h3
-rw-r--r--src/gui/window.cpp40
-rw-r--r--src/gui/window.h11
28 files changed, 234 insertions, 236 deletions
diff --git a/src/gui/chargedialog.cpp b/src/gui/chargedialog.cpp
index c6cee598..e456810f 100644
--- a/src/gui/chargedialog.cpp
+++ b/src/gui/chargedialog.cpp
@@ -43,11 +43,6 @@ ChargeDialog::~ChargeDialog()
delete progBar;
}
-void ChargeDialog::action(const std::string& eventId)
-{
-
-}
-
// update the dialog
void ChargeDialog::logic()
{
diff --git a/src/gui/chargedialog.h b/src/gui/chargedialog.h
index 4e6d83dc..8a4f9b04 100644
--- a/src/gui/chargedialog.h
+++ b/src/gui/chargedialog.h
@@ -34,7 +34,7 @@ class ProgressBar;
/**
* \ingroup Interface
*/
-class ChargeDialog : public Window, public gcn::ActionListener
+class ChargeDialog : public Window
{
public:
/**
@@ -45,10 +45,8 @@ class ChargeDialog : public Window, public gcn::ActionListener
/**
* Destructor.
*/
- ~ChargeDialog();
-
- // action listener
- void action(const std::string&);
+ ~ChargeDialog();
+
void logic();
private:
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index a091abc9..7e1458c9 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -183,9 +183,9 @@ void ChatWindow::chat_log(std::string line, int own)
}
}
-void ChatWindow::chat_log(CHATSKILL action)
+void ChatWindow::chat_log(CHATSKILL act)
{
- chat_log(const_msg(action), BY_SERVER);
+ chat_log(const_msg(act), BY_SERVER);
}
void ChatWindow::action(const std::string& eventId)
@@ -227,7 +227,8 @@ bool ChatWindow::isFocused()
return chatInput->hasFocus();
}
-char *ChatWindow::chat_send(std::string nick, std::string msg)
+void
+ChatWindow::chat_send(std::string nick, std::string msg)
{
short packetId = CMSG_CHAT_MESSAGE;
@@ -240,7 +241,6 @@ char *ChatWindow::chat_send(std::string nick, std::string msg)
}*/
// prepare ordinary message
chat_log("Sorry but /commands are not available yet", BY_PLAYER);
- return "";
}
else {
nick += " : ";
@@ -254,15 +254,13 @@ char *ChatWindow::chat_send(std::string nick, std::string msg)
outMsg.writeShort(packetId);
outMsg.writeShort(msg.length() + 4);
outMsg.writeString(msg, msg.length());
-
- return "";
}
-std::string ChatWindow::const_msg(CHATSKILL action)
+std::string ChatWindow::const_msg(CHATSKILL act)
{
std::string msg;
- if (action.success == SKILL_FAILED && action.skill == SKILL_BASIC) {
- switch (action.bskill) {
+ if (act.success == SKILL_FAILED && act.skill == SKILL_BASIC) {
+ switch (act.bskill) {
case BSKILL_TRADE :
msg = "Trade failed!";
break;
@@ -283,7 +281,7 @@ std::string ChatWindow::const_msg(CHATSKILL action)
break;
}
- switch (action.reason) {
+ switch (act.reason) {
case RFAIL_SKILLDEP :
msg += " You have not yet reached a high enough lvl!";
break;
@@ -319,7 +317,7 @@ std::string ChatWindow::const_msg(CHATSKILL action)
break;
}
} else {
- switch(action.skill) {
+ switch(act.skill) {
case SKILL_WARP :
msg = "Warp failed...";
break;
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 1766bd08..e648eda5 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -176,7 +176,8 @@ class ChatWindow : public Window, public gcn::ActionListener,
* // for simple message by a user /- message
* chatlog.chat_send("Zaeiru", "Hello to all users on the screen!");
*/
- char *chat_send(std::string nick, std::string msg);
+ void
+ chat_send(std::string nick, std::string msg);
/** Called when key is pressed */
void keyPress(const gcn::Key& key);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index ba29a1e5..d1d23ee1 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -43,7 +43,6 @@ EquipmentWindow::EquipmentWindow():
setDefaultSize(5, 230, 200, 90);
loadWindowState();
-
ResourceManager *resman = ResourceManager::getInstance();
Image *itemImg = resman->getImage("graphics/sprites/items.png");
if (!itemImg) logger->error("Unable to load items.png");
@@ -94,7 +93,3 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
graphics->drawText(n.str(), 170, 62,
gcn::Graphics::CENTER);
}
-
-void EquipmentWindow::action(const std::string &eventId)
-{
-}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0470ba6f..a3241057 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -35,7 +35,8 @@ class Spriteset;
*
* \ingroup Interface
*/
-class EquipmentWindow : public Window, gcn::ActionListener {
+class EquipmentWindow : public Window
+{
public:
/**
* Constructor.
@@ -52,11 +53,6 @@ class EquipmentWindow : public Window, gcn::ActionListener {
*/
void draw(gcn::Graphics *graphics);
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const std::string& eventId);
-
private:
Spriteset *itemset;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 365d8eba..c829cef7 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -69,12 +69,15 @@ gcn::ImageFont *speechFont;
class GuiConfigListener : public ConfigListener
{
public:
- GuiConfigListener(Gui *gui):mGui(gui) {}
+ GuiConfigListener(Gui *g):
+ mGui(g)
+ {}
void optionChanged(const std::string &name)
{
if (name == "customcursor") {
- mGui->setUseCustomCursor(config.getValue("customcursor", 1) == 1);
+ bool bCustomCursor = config.getValue("customcursor", 1) == 1;
+ mGui->setUseCustomCursor(bCustomCursor);
}
}
private:
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 80ddbc9a..71e94340 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -51,7 +51,7 @@ HelpWindow::HelpWindow():
okButton->setEventId("close");
okButton->addActionListener(this);
-
+
browserBox->setLinkHandler(this);
add(scrollArea);
@@ -69,7 +69,10 @@ HelpWindow::~HelpWindow()
void HelpWindow::action(const std::string& eventId)
{
- setVisible(false);
+ if (eventId == "close")
+ {
+ setVisible(false);
+ }
}
void HelpWindow::handleLink(const std::string& link)
@@ -81,7 +84,7 @@ void HelpWindow::handleLink(const std::string& link)
void HelpWindow::loadHelp(const std::string &helpFile)
{
browserBox->clearRows();
-
+
loadFile("header");
loadFile(helpFile);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 2fca3e3c..9012b8ee 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -42,6 +42,8 @@
#include "../resources/iteminfo.h"
+extern Inventory *inventory;
+
InventoryWindow::InventoryWindow():
Window("Inventory")
{
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index 52570514..b313b98c 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -31,6 +31,8 @@
#include "../inventory.h"
#include "../item.h"
+extern Inventory *inventory;
+
ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
Window("Select amount of items to drop.", true, parent),
mItem(item)
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 81a85b8d..3f00f9eb 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -39,7 +39,7 @@
#include "../resources/resourcemanager.h"
ItemContainer::ItemContainer(Inventory *inventory):
- inventory(inventory)
+ mInventory(inventory)
{
ResourceManager *resman = ResourceManager::getInstance();
Image *itemImg = resman->getImage("graphics/sprites/items.png");
@@ -51,7 +51,7 @@ ItemContainer::ItemContainer(Inventory *inventory):
if (!selImg) logger->error("Unable to load selection.png");
selectedItem = 0; // No item selected
- maxItems = inventory->getLastUsedSlot();
+ maxItems = mInventory->getLastUsedSlot();
addMouseListener(this);
}
@@ -66,7 +66,7 @@ void ItemContainer::logic()
{
gcn::Widget::logic();
- int i = inventory->getLastUsedSlot();
+ int i = mInventory->getLastUsedSlot();
if (i != maxItems) {
maxItems = i;
@@ -100,7 +100,7 @@ void ItemContainer::draw(gcn::Graphics* graphics)
*/
for (int i = 2; i < INVENTORY_SIZE; i++)
{
- Item *item = inventory->getItem(i);
+ Item *item = mInventory->getItem(i);
if (item->getQuantity() <= 0) {
continue;
@@ -182,6 +182,6 @@ void ItemContainer::mousePress(int mx, int my, int button)
if (index > INVENTORY_SIZE) {
index = INVENTORY_SIZE - 1;
}
- selectedItem = inventory->getItem(index);
+ selectedItem = mInventory->getItem(index);
}
}
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 9cd92812..69134d83 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -82,7 +82,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
void selectNone();
private:
- Inventory *inventory;
+ Inventory *mInventory;
Spriteset *itemset;
Image *selImg;
Item *selectedItem;
diff --git a/src/gui/linkhandler.h b/src/gui/linkhandler.h
index 05a0a99b..65c0d433 100644
--- a/src/gui/linkhandler.h
+++ b/src/gui/linkhandler.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef _TMW_LINK_HANDLER_H
-#define _TMW_LINK_HANDLER_H
+#ifndef _TMW_LINK_HANDLER_H_
+#define _TMW_LINK_HANDLER_H_
/**
* A simple interface to windows that need to handle links from BrowserBox
@@ -33,8 +33,8 @@ class LinkHandler
public:
virtual ~LinkHandler() { }
- virtual void handleLink(const std::string& link) { }
-
+ virtual void handleLink(const std::string& link) = 0;
+
protected:
LinkHandler() { }
};
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index aea77768..6d1c896d 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -60,11 +60,14 @@ WrongPasswordNoticeListener::setLoginDialog(LoginDialog *loginDialog)
void
WrongPasswordNoticeListener::action(const std::string &eventId)
{
- // Reset the password and put the caret ready to retype it.
- mLoginDialog->passField->setText("");
- mLoginDialog->passField->setCaretPosition(0);
- mLoginDialog->passField->requestFocus();
- wrongLoginNotice = NULL;
+ if (eventId == "ok")
+ {
+ // Reset the password and put the caret ready to retype it.
+ mLoginDialog->passField->setText("");
+ mLoginDialog->passField->setCaretPosition(0);
+ mLoginDialog->passField->requestFocus();
+ wrongLoginNotice = NULL;
+ }
}
void
@@ -76,10 +79,13 @@ WrongUsernameNoticeListener::setLoginDialog(LoginDialog *loginDialog)
void
WrongUsernameNoticeListener::action(const std::string &eventId)
{
- // Set the focus on the username Field
- mLoginDialog->userField->setCaretPosition(LEN_MAX_USERNAME - 1);
- mLoginDialog->userField->requestFocus();
- wrongLoginNotice = NULL;
+ if (eventId == "ok")
+ {
+ // Set the focus on the username Field
+ mLoginDialog->userField->setCaretPosition(LEN_MAX_USERNAME - 1);
+ mLoginDialog->userField->requestFocus();
+ wrongLoginNotice = NULL;
+ }
}
LoginDialog::LoginDialog():
@@ -269,41 +275,41 @@ LoginDialog::action(const std::string& eventId)
else if (user.length() < LEN_MIN_USERNAME)
{
// Name too short
- std::stringstream errorMessage;
- errorMessage << "The username needs to be at least "
- << LEN_MIN_USERNAME
- << " characters long.";
- wrongLoginNotice = new OkDialog("Error", errorMessage.str(),
+ std::stringstream errorMsg;
+ errorMsg << "The username needs to be at least "
+ << LEN_MIN_USERNAME
+ << " characters long.";
+ wrongLoginNotice = new OkDialog("Error", errorMsg.str(),
&wrongUsernameNoticeListener);
}
else if (user.length() > LEN_MAX_USERNAME - 1 )
{
// Name too long
- std::stringstream errorMessage;
- errorMessage << "The username needs to be less than "
- << LEN_MAX_USERNAME
- << " characters long.";
- wrongLoginNotice = new OkDialog("Error", errorMessage.str(),
+ std::stringstream errorMsg;
+ errorMsg << "The username needs to be less than "
+ << LEN_MAX_USERNAME
+ << " characters long.";
+ wrongLoginNotice = new OkDialog("Error", errorMsg.str(),
&wrongUsernameNoticeListener);
}
else if (passField->getText().length() < LEN_MIN_PASSWORD)
{
// Pass too short
- std::stringstream errorMessage;
- errorMessage << "The password needs to be at least "
- << LEN_MIN_PASSWORD
- << " characters long.";
- wrongLoginNotice = new OkDialog("Error", errorMessage.str(),
+ std::stringstream errorMsg;
+ errorMsg << "The password needs to be at least "
+ << LEN_MIN_PASSWORD
+ << " characters long.";
+ wrongLoginNotice = new OkDialog("Error", errorMsg.str(),
&wrongPasswordNoticeListener);
}
else if (passField->getText().length() > LEN_MAX_PASSWORD - 1 )
{
// Pass too long
- std::stringstream errorMessage;
- errorMessage << "The password needs to be less than "
- << LEN_MAX_PASSWORD
- << " characters long.";
- wrongLoginNotice = new OkDialog("Error", errorMessage.str(),
+ std::stringstream errorMsg;
+ errorMsg << "The password needs to be less than "
+ << LEN_MAX_PASSWORD
+ << " characters long.";
+ wrongLoginNotice = new OkDialog("Error", errorMsg.str(),
&wrongPasswordNoticeListener);
}
else
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 1e190102..280339a1 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -33,6 +33,7 @@
#include "skill.h"
#include "../graphics.h"
+
extern Graphics *graphics;
extern Window *setupWindow;
@@ -78,8 +79,8 @@ MenuWindow::MenuWindow():
int menuWidth = setupButton->getX() + setupButton->getWidth();
setDefaultSize((graphics->getWidth() - menuWidth - 5), 0,
- menuWidth,
- (setupButton->getY() + setupButton->getHeight()));
+ menuWidth,
+ (setupButton->getY() + setupButton->getHeight()));
}
MenuWindow::~MenuWindow()
@@ -91,9 +92,9 @@ MenuWindow::~MenuWindow()
delete setupButton;
}
-void MenuWindow::draw(gcn::Graphics *graphics)
+void MenuWindow::draw(gcn::Graphics *g)
{
- Window::drawContent(graphics);
+ Window::drawContent(g);
}
void MenuWindow::action(const std::string& eventId)
diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp
index 12c87b36..ec080d81 100644
--- a/src/gui/newskill.cpp
+++ b/src/gui/newskill.cpp
@@ -34,7 +34,7 @@
#include "../graphics.h"
-char *skill_name[] = {
+const char *skill_name[] = {
// 0-99
// weapon skills 0-9
"Short Blades", "Long Blades", "Hammers", "Archery", "Whip",
@@ -69,7 +69,6 @@ char *skill_name[] = {
};
-
NewSkillDialog::NewSkillDialog():
Window("Skills")
{
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 9896f08e..2e0b0837 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -80,10 +80,13 @@ NpcTextDialog::addText(const std::string &text)
void
NpcTextDialog::action(const std::string& eventId)
{
- MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeLong(current_npc);
- setText("");
- setVisible(false);
- current_npc = 0;
+ if (eventId == "ok")
+ {
+ MessageOut outMsg;
+ outMsg.writeShort(CMSG_NPC_NEXT_REQUEST);
+ outMsg.writeLong(current_npc);
+ setText("");
+ setVisible(false);
+ current_npc = 0;
+ }
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index feb287eb..6bb57f60 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -47,13 +47,17 @@
#include "../resources/itemmanager.h"
extern Being* autoTarget;
+extern Inventory* inventory;
PopupMenu::PopupMenu():
- Window()
+ Window(),
+ mBeing(NULL),
+ mFloorItem(NULL),
+ mItem(NULL)
{
setResizable(false);
setTitleBarHeight(0);
- title = false;
+ mShowTitle = false;
browserBox = new BrowserBox();
browserBox->setPosition(4, 4);
@@ -61,29 +65,25 @@ PopupMenu::PopupMenu():
browserBox->setOpaque(false);
add(browserBox);
browserBox->setLinkHandler(this);
-
- being = NULL;
- floorItem = NULL;
}
PopupMenu::~PopupMenu()
{
delete browserBox;
- delete floorItem;
}
void PopupMenu::showPopup(int x, int y, Being *being)
{
- this->being = being;
+ mBeing = being;
browserBox->clearRows();
- switch (being->getType())
+ switch (mBeing->getType())
{
case Being::PLAYER:
{
// Players can be traded with. Later also attack, follow and
// add as buddy will be options in this menu.
- const std::string &name = being->getName();
+ const std::string &name = mBeing->getName();
browserBox->addRow("@@trade|Trade With " + name + "@@");
browserBox->addRow("@@attack|Attack " + name + "@@");
@@ -112,11 +112,11 @@ void PopupMenu::showPopup(int x, int y, Being *being)
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
{
- this->floorItem = floorItem;
+ mFloorItem = floorItem;
browserBox->clearRows();
// Floor item can be picked up (single option, candidate for removal)
- std::string name = itemDb->getItemInfo(floorItem->getItemId())->getName();
+ std::string name = itemDb->getItemInfo(mFloorItem->getItemId())->getName();
browserBox->addRow("@@pickup|Pick Up " + name + "@@");
//browserBox->addRow("@@look|Look To@@");
@@ -129,32 +129,38 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
void PopupMenu::handleLink(const std::string& link)
{
// Talk To action
- if ((link == "talk") && being && being->getType() == Being::NPC &&
- (current_npc == 0))
+ if (link == "talk" &&
+ mBeing != NULL &&
+ mBeing->getType() == Being::NPC &&
+ current_npc == 0)
{
MessageOut outMsg;
outMsg.writeShort(CMSG_NPC_TALK);
- outMsg.writeLong(being->getId());
+ outMsg.writeLong(mBeing->getId());
outMsg.writeByte(0);
- current_npc = being->getId();
+ current_npc = mBeing->getId();
}
// Trade action
- else if ((link == "trade") && being && being->getType() == Being::PLAYER)
+ else if (link == "trade" &&
+ mBeing != NULL &&
+ mBeing->getType() == Being::PLAYER)
{
MessageOut outMsg;
outMsg.writeShort(CMSG_TRADE_REQUEST);
- outMsg.writeLong(being->getId());
+ outMsg.writeLong(mBeing->getId());
//tradePartner.flush();
//tradePartner << "Trade: You and " << being->name<< "";
- tradePartnerName = being->getName();
+ tradePartnerName = mBeing->getName();
}
// Attack action
- else if ((link == "attack") && being && being->getType() == Being::PLAYER)
+ else if (link == "attack" &&
+ mBeing != NULL &&
+ mBeing->getType() == Being::PLAYER)
{
- autoTarget = being;
- attack(being);
+ autoTarget = mBeing;
+ attack(mBeing);
}
/*
@@ -165,20 +171,20 @@ void PopupMenu::handleLink(const std::string& link)
/*
// Add Buddy action
- else if ((link == "buddy") && being && being->isPlayer())
+ else if ((link == "buddy") && mBeing != NULL && mBeing->isPlayer())
{
if (!buddyWindow->isVisible())
buddyWindow->setVisible(true);
- buddyWindow->addBuddy(being->getName());
+ buddyWindow->addBuddy(mBeing->getName());
}*/
// Pick Up Floor Item action
- else if ((link == "pickup") && floorItem)
+ else if ((link == "pickup") && mFloorItem != NULL)
{
MessageOut outMsg;
outMsg.writeShort(CMSG_ITEM_PICKUP);
- outMsg.writeLong(floorItem->getId());
+ outMsg.writeLong(mFloorItem->getId());
}
// Look To action
@@ -188,27 +194,27 @@ void PopupMenu::handleLink(const std::string& link)
else if (link == "use")
{
- assert(m_item);
- if (m_item->isEquipment())
+ assert(mItem);
+ if (mItem->isEquipment())
{
- if (m_item->isEquipped())
+ if (mItem->isEquipped())
{
- inventory->unequipItem(m_item);
+ inventory->unequipItem(mItem);
}
else
{
- inventory->equipItem(m_item);
+ inventory->equipItem(mItem);
}
}
else
{
- inventory->useItem(m_item);
+ inventory->useItem(mItem);
}
}
else if (link == "drop")
{
- new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, m_item);
+ new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem);
}
else if (link == "description")
@@ -231,15 +237,15 @@ void PopupMenu::handleLink(const std::string& link)
*/
_getFocusHandler()->focusNone();
- being = NULL;
- floorItem = NULL;
- m_item = NULL;
+ mBeing = NULL;
+ mFloorItem = NULL;
+ mItem = NULL;
}
void PopupMenu::showPopup(int x, int y, Item *item)
{
assert(item);
- m_item = item;
+ mItem = item;
browserBox->clearRows();
if (item->isEquipment())
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 0ba9f485..0cd6225c 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -74,10 +74,9 @@ class PopupMenu : public Window, public LinkHandler
private:
BrowserBox* browserBox;
- Being* being;
- FloorItem* floorItem;
-
- Item *m_item;
+ Being* mBeing;
+ FloorItem* mFloorItem;
+ Item *mItem;
/**
* Shared code for the various showPopup functions.
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 834ca73a..0863db98 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -35,12 +35,10 @@ int ProgressBar::mInstances = 0;
ProgressBar::ProgressBar(float progress, int x, int y,
unsigned int width, unsigned int height,
- unsigned char red,
- unsigned char green,
- unsigned char blue):
+ Uint8 red, Uint8 green, Uint8 blue):
gcn::Widget(),
- red(red), green(green), blue(blue),
- redToGo(red), greenToGo(green), blueToGo(blue)
+ mRed(red), mGreen(green), mBlue(blue),
+ mRedToGo(red), mGreenToGo(green), mBlueToGo(blue)
{
setProgress(progress);
setX(x);
@@ -88,58 +86,43 @@ ProgressBar::~ProgressBar()
void ProgressBar::logic()
{
// Smoothly changing the color for a nicer effect.
- if (redToGo > red) red++;
- if (redToGo < red) red--;
- if (greenToGo > green) green++;
- if (greenToGo < green) green--;
- if (blueToGo > blue) blue++;
- if (blueToGo < blue) blue--;
+ if (mRedToGo > mRed) mRed++;
+ if (mRedToGo < mRed) mRed--;
+ if (mGreenToGo > mGreen) mGreen++;
+ if (mGreenToGo < mGreen) mGreen--;
+ if (mBlueToGo > mBlue) mBlue++;
+ if (mBlueToGo < mBlue) mBlue--;
}
-void ProgressBar::draw(gcn::Graphics *graphics)
+void
+ProgressBar::draw(gcn::Graphics *graphics)
{
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth(), getHeight(),
- mBorder);
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0,
+ getWidth(), getHeight(),
+ mBorder);
// The bar
- if (progress > 0)
+ if (mProgress > 0)
{
- graphics->setColor(gcn::Color(red, green, blue, 200));
+ graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200));
graphics->fillRectangle(gcn::Rectangle(4, 4,
- (int)(progress * (getWidth() - 8)), getHeight() - 8));
+ (int)(mProgress * (getWidth() - 8)),
+ getHeight() - 8));
}
}
-void ProgressBar::setProgress(float progress)
+void
+ProgressBar::setProgress(float progress)
{
- if (progress < 0.0f) this->progress = 0.0;
- else if (progress > 1.0f) this->progress = 1.0;
- else this->progress = progress;
+ if (progress < 0.0f) mProgress = 0.0;
+ else if (progress > 1.0f) mProgress = 1.0;
+ else mProgress = progress;
}
-float ProgressBar::getProgress()
+void
+ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue)
{
- return progress;
-}
-
-void ProgressBar::setColor(unsigned char red, unsigned char green, unsigned char blue)
-{
- redToGo = red;
- greenToGo = green;
- blueToGo = blue;
-}
-
-unsigned char ProgressBar::getRed()
-{
- return red;
-}
-
-unsigned char ProgressBar::getGreen()
-{
- return green;
-}
-
-unsigned char ProgressBar::getBlue()
-{
- return blue;
+ mRedToGo = red;
+ mGreenToGo = green;
+ mBlueToGo = blue;
}
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index fe9e7085..cd62c498 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -26,6 +26,8 @@
#include <guichan/widget.hpp>
+#include <SDL_types.h>
+
class ImageRect;
@@ -40,8 +42,8 @@ class ProgressBar : public gcn::Widget {
* Constructor, initializes the progress with the given value.
*/
ProgressBar(float progress = 0.0f, int x = 0, int y = 0,
- unsigned int width = 40, unsigned int height = 7,
- unsigned char red = 150, unsigned char green = 150, unsigned char blue = 150);
+ unsigned int width = 40, unsigned int height = 7,
+ Uint8 red = 150, Uint8 green = 150, Uint8 blue = 150);
/**
* Destructor.
@@ -51,47 +53,55 @@ class ProgressBar : public gcn::Widget {
/**
* Performs progress bar logic (fading colors)
*/
- void logic();
+ void
+ logic();
/**
* Draws the progress bar.
*/
- void draw(gcn::Graphics *graphics);
+ void
+ draw(gcn::Graphics *graphics);
/**
* Sets the current progress.
*/
- void setProgress(float progress);
+ void
+ setProgress(float progress);
/**
* Returns the current progress.
*/
- float getProgress();
+ float
+ getProgress() { return mProgress; }
/**
* Change the filling of the progress bar.
*/
- void setColor(unsigned char red, unsigned char green, unsigned char blue);
+ void
+ setColor(Uint8, Uint8 green, Uint8 blue);
/**
* Get The red value of color
*/
- unsigned char getRed();
+ Uint8
+ getRed() { return mRed; }
/**
* Get The red value of color
*/
- unsigned char getGreen();
+ Uint8
+ getGreen() { return mGreen; }
- /**
+ /**
* Get The red value of color
*/
- unsigned char getBlue();
+ Uint8
+ getBlue() { return mBlue; }
private:
- float progress;
- unsigned char red, green, blue;
- unsigned char redToGo, greenToGo, blueToGo;
+ float mProgress;
+ Uint8 mRed, mGreen, mBlue;
+ Uint8 mRedToGo, mGreenToGo, mBlueToGo;
static ImageRect mBorder;
static int mInstances;
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index ec8a7946..246e2ffa 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -216,21 +216,21 @@ void ScrollArea::draw(gcn::Graphics *graphics)
void ScrollArea::drawBorder(gcn::Graphics *graphics)
{
- int w, h, bs;
- bs = getBorderSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ int bs = getBorderSize();
+ int w = getWidth() + bs * 2;
+ int h = getHeight() + bs * 2;
- if (isOpaque()) {
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background);
+ if (mOpaque) {
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h,
+ background);
}
}
void ScrollArea::setOpaque(bool opaque)
{
- this->opaque = opaque;
+ mOpaque = opaque;
- if (opaque) {
+ if (mOpaque) {
setBorderSize(2);
}
else {
@@ -238,11 +238,6 @@ void ScrollArea::setOpaque(bool opaque)
}
}
-bool ScrollArea::isOpaque()
-{
- return opaque;
-}
-
void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir)
{
int state = 0;
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
index f2e00466..d75e194a 100644
--- a/src/gui/scrollarea.h
+++ b/src/gui/scrollarea.h
@@ -70,19 +70,21 @@ class ScrollArea : public gcn::ScrollArea {
/**
* Sets whether the widget should draw its background or not.
*/
- void setOpaque(bool opaque);
+ void
+ setOpaque(bool opaque);
/**
* Returns whether the widget draws its background or not.
*/
- bool isOpaque();
+ bool
+ isOpaque() { return mOpaque; }
protected:
enum BUTTON_DIR {
UP,
DOWN,
LEFT,
- RIGHT,
+ RIGHT
};
/**
@@ -105,7 +107,7 @@ class ScrollArea : public gcn::ScrollArea {
static ImageRect vMarker;
static Image *buttons[4][2];
- bool opaque;
+ bool mOpaque;
};
#endif
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 75f77e39..b65fcfd9 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -37,7 +37,7 @@
#include "../graphics.h"
extern Graphics *graphics;
-char *skill_db[] = {
+const char *skill_db[] = {
// 0-99
"", "Basic", "Sword", "Two hand", "HP regeneration", "Bash", "Provoke", "Magnum", "Endure", "MP regeneration",
"", "", "", "", "", "", "", "", "", "",
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 1a858297..1ba09b98 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -35,6 +35,7 @@
#include "../net/protocol.h"
#include "../graphics.h"
+
extern Graphics *graphics;
StatusWindow::StatusWindow():
@@ -43,7 +44,7 @@ StatusWindow::StatusWindow():
setWindowName("Status");
setResizable(true);
setDefaultSize((graphics->getWidth() - 365) / 2,
- (graphics->getHeight() - 255) / 2, 365, 255);
+ (graphics->getHeight() - 255) / 2, 365, 255);
loadWindowState();
// ----------------------
@@ -428,11 +429,11 @@ void StatusWindow::update()
jobValueLabel->setPosition(290, jobXpLabel->getY());
}
-void StatusWindow::draw(gcn::Graphics *graphics)
+void StatusWindow::draw(gcn::Graphics *g)
{
update();
- Window::draw(graphics);
+ Window::draw(g);
}
void StatusWindow::action(const std::string& eventId)
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 7cb350da..1a2d0d99 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -96,7 +96,8 @@ class TradeWindow : public Window, gcn::ActionListener
/**
* Send trade packet.
*/
- void TradeWindow::tradeItem(Item *item, int quantity);
+ void
+ tradeItem(Item *item, int quantity);
/**
* Called on mouse click.
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 2f288fff..54fc0103 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -67,11 +67,11 @@ class WindowConfigListener : public ConfigListener
Window::Window(const std::string& caption, bool modal, Window *parent):
gcn::Window(caption),
- parent(parent),
+ mParent(parent),
mWindowName("window"),
snapSize(8),
- title(true),
- modal(modal),
+ mShowTitle(true),
+ mModal(modal),
resizable(false),
mMouseResize(false),
minWinWidth(6),
@@ -114,14 +114,14 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
setTitleBarHeight(20);
// Add chrome
- chrome = new gcn::Container();
- chrome->setOpaque(false);
- setContent(chrome);
+ mChrome = new gcn::Container();
+ mChrome->setOpaque(false);
+ setContent(mChrome);
// Add this window to the window container
windowContainer->add(this);
- if (modal)
+ if (mModal)
{
requestModalFocus();
}
@@ -163,7 +163,7 @@ Window::~Window()
resizeGrip->decRef();
}
- delete chrome;
+ delete mChrome;
}
void Window::setWindowContainer(WindowContainer *wc)
@@ -186,7 +186,7 @@ void Window::draw(gcn::Graphics* graphics)
}
// Draw title
- if (title) {
+ if (mShowTitle) {
graphics->setFont(getFont());
graphics->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
}
@@ -196,13 +196,13 @@ void Window::draw(gcn::Graphics* graphics)
void Window::setContentWidth(int width)
{
- chrome->setWidth(width);
+ mChrome->setWidth(width);
resizeToContent();
}
void Window::setContentHeight(int height)
{
- chrome->setHeight(height);
+ mChrome->setHeight(height);
resizeToContent();
}
@@ -254,11 +254,6 @@ bool Window::isResizable()
return resizable;
}
-Window *Window::getParentWindow()
-{
- return parent;
-}
-
void Window::scheduleDelete()
{
windowContainer->scheduleDelete(this);
@@ -266,12 +261,12 @@ void Window::scheduleDelete()
void Window::add(gcn::Widget *w)
{
- chrome->add(w);
+ mChrome->add(w);
}
void Window::add(gcn::Widget *w, int x, int y)
{
- chrome->add(w, x, y);
+ mChrome->add(w, x, y);
}
void Window::mousePress(int x, int y, int button)
@@ -401,7 +396,8 @@ void Window::mouseMotion(int x, int y)
}
}
-void Window::mouseRelease(int x, int y, int button)
+void
+Window::mouseRelease(int x, int y, int button)
{
if (button == 1)
{
@@ -410,7 +406,8 @@ void Window::mouseRelease(int x, int y, int button)
}
}
-gcn::Rectangle Window::getGripDimension()
+gcn::Rectangle
+Window::getGripDimension()
{
return gcn::Rectangle(getWidth() - resizeGrip->getWidth(),
getHeight() - resizeGrip->getHeight(),
@@ -418,7 +415,8 @@ gcn::Rectangle Window::getGripDimension()
getHeight());
}
-void Window::loadWindowState()
+void
+Window::loadWindowState()
{
const std::string &name = mWindowName;
diff --git a/src/gui/window.h b/src/gui/window.h
index 66330350..ee85c97f 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -138,7 +138,8 @@ class Window : public gcn::Window
*
* @return The parent window or <code>NULL</code> if there is none.
*/
- Window *getParentWindow();
+ Window*
+ getParentWindow() { return mParent; }
/**
* Schedule this window for deletion. It will be deleted at the start
@@ -195,12 +196,12 @@ class Window : public gcn::Window
virtual void resetToDefaultSize();
protected:
- gcn::Container *chrome; /**< Contained container */
- Window *parent; /**< The parent window */
+ gcn::Container *mChrome; /**< Contained container */
+ Window *mParent; /**< The parent window */
std::string mWindowName; /**< Name of the window */
int snapSize; /**< Snap distance to window edge */
- bool title; /**< Window has a title bar */
- bool modal; /**< Window is modal */
+ bool mShowTitle; /**< Window has a title bar */
+ bool mModal; /**< Window is modal */
bool resizable; /**< Window can be resized */
bool mMouseResize; /**< Window is being resized */
int minWinWidth; /**< Minimum window width */