summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/browserbox.cpp30
-rw-r--r--src/gui/browserbox.h7
-rw-r--r--src/gui/button.cpp43
-rw-r--r--src/gui/button.h5
-rw-r--r--src/gui/buttonbox.cpp43
-rw-r--r--src/gui/buttonbox.h67
-rw-r--r--src/gui/buy.h6
-rw-r--r--src/gui/buysell.h2
-rw-r--r--src/gui/char_select.cpp3
-rw-r--r--src/gui/char_select.h9
-rw-r--r--src/gui/char_server.cpp17
-rw-r--r--src/gui/char_server.h2
-rw-r--r--src/gui/chat.cpp92
-rw-r--r--src/gui/chat.h5
-rw-r--r--src/gui/chatinput.h2
-rw-r--r--src/gui/checkbox.cpp31
-rw-r--r--src/gui/checkbox.h8
-rw-r--r--src/gui/colour.cpp17
-rw-r--r--src/gui/colour.h9
-rw-r--r--src/gui/confirm_dialog.cpp9
-rw-r--r--src/gui/confirm_dialog.h9
-rw-r--r--src/gui/connection.cpp7
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/debugwindow.h4
-rw-r--r--src/gui/emotecontainer.h2
-rw-r--r--src/gui/emoteshortcutcontainer.cpp13
-rw-r--r--src/gui/emoteshortcutcontainer.h4
-rw-r--r--src/gui/emotewindow.cpp5
-rw-r--r--src/gui/emotewindow.h2
-rw-r--r--src/gui/equipmentwindow.cpp94
-rw-r--r--src/gui/equipmentwindow.h11
-rw-r--r--src/gui/focushandler.h2
-rw-r--r--src/gui/gccontainer.h2
-rw-r--r--src/gui/gui.cpp25
-rw-r--r--src/gui/gui.h1
-rw-r--r--src/gui/help.cpp2
-rw-r--r--src/gui/help.h2
-rw-r--r--src/gui/inttextfield.h2
-rw-r--r--src/gui/inventorywindow.cpp26
-rw-r--r--src/gui/inventorywindow.h6
-rw-r--r--src/gui/item_amount.cpp3
-rw-r--r--src/gui/item_amount.h4
-rw-r--r--src/gui/itemcontainer.cpp3
-rw-r--r--src/gui/itemcontainer.h2
-rw-r--r--src/gui/itemlinkhandler.cpp6
-rw-r--r--src/gui/itempopup.cpp102
-rw-r--r--src/gui/itempopup.h9
-rw-r--r--src/gui/itemshortcutcontainer.cpp10
-rw-r--r--src/gui/itemshortcutcontainer.h2
-rw-r--r--src/gui/listbox.cpp27
-rw-r--r--src/gui/listbox.h5
-rw-r--r--src/gui/login.cpp9
-rw-r--r--src/gui/login.h11
-rw-r--r--src/gui/menuwindow.h2
-rw-r--r--src/gui/minimap.cpp28
-rw-r--r--src/gui/minimap.h2
-rw-r--r--src/gui/ministatus.cpp1
-rw-r--r--src/gui/ministatus.h7
-rw-r--r--src/gui/npc_text.cpp34
-rw-r--r--src/gui/npc_text.h16
-rw-r--r--src/gui/npcintegerdialog.cpp27
-rw-r--r--src/gui/npcintegerdialog.h19
-rw-r--r--src/gui/npclistdialog.cpp3
-rw-r--r--src/gui/npclistdialog.h5
-rw-r--r--src/gui/npcstringdialog.cpp13
-rw-r--r--src/gui/npcstringdialog.h11
-rw-r--r--src/gui/ok_dialog.cpp10
-rw-r--r--src/gui/ok_dialog.h6
-rw-r--r--src/gui/passwordfield.cpp2
-rw-r--r--src/gui/passwordfield.h4
-rw-r--r--src/gui/playerbox.cpp11
-rw-r--r--src/gui/playerbox.h3
-rw-r--r--src/gui/popupmenu.cpp25
-rw-r--r--src/gui/progressbar.cpp35
-rw-r--r--src/gui/progressbar.h6
-rw-r--r--src/gui/radiobutton.cpp39
-rw-r--r--src/gui/radiobutton.h6
-rw-r--r--src/gui/recorder.cpp115
-rw-r--r--src/gui/recorder.h76
-rw-r--r--src/gui/register.cpp8
-rw-r--r--src/gui/register.h4
-rw-r--r--src/gui/scrollarea.cpp28
-rw-r--r--src/gui/scrollarea.h7
-rw-r--r--src/gui/sell.cpp8
-rw-r--r--src/gui/sell.h4
-rw-r--r--src/gui/setup.cpp3
-rw-r--r--src/gui/setup_audio.cpp4
-rw-r--r--src/gui/setup_audio.h2
-rw-r--r--src/gui/setup_colours.cpp66
-rw-r--r--src/gui/setup_colours.h18
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_joystick.h2
-rw-r--r--src/gui/setup_keyboard.cpp12
-rw-r--r--src/gui/setup_keyboard.h1
-rw-r--r--src/gui/setup_players.cpp26
-rw-r--r--src/gui/setup_players.h13
-rw-r--r--src/gui/setup_video.cpp69
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/gui/shop.h3
-rw-r--r--src/gui/shoplistbox.cpp24
-rw-r--r--src/gui/shoplistbox.h5
-rw-r--r--src/gui/shortcutcontainer.cpp11
-rw-r--r--src/gui/shortcutcontainer.h10
-rw-r--r--src/gui/shortcutwindow.cpp15
-rw-r--r--src/gui/shortcutwindow.h6
-rw-r--r--src/gui/skill.cpp35
-rw-r--r--src/gui/skill.h9
-rw-r--r--src/gui/slider.cpp16
-rw-r--r--src/gui/slider.h3
-rw-r--r--src/gui/speechbubble.cpp47
-rw-r--r--src/gui/speechbubble.h6
-rw-r--r--src/gui/status.cpp227
-rw-r--r--src/gui/status.h10
-rw-r--r--src/gui/table.cpp263
-rw-r--r--src/gui/table.h58
-rw-r--r--src/gui/table_model.cpp31
-rw-r--r--src/gui/table_model.h38
-rw-r--r--src/gui/textbox.cpp29
-rw-r--r--src/gui/textbox.h12
-rw-r--r--src/gui/textfield.cpp15
-rw-r--r--src/gui/textfield.h3
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/truetypefont.h1
-rw-r--r--src/gui/updatewindow.cpp6
-rw-r--r--src/gui/updatewindow.h2
-rw-r--r--src/gui/viewport.cpp8
-rw-r--r--src/gui/viewport.h9
-rw-r--r--src/gui/widgets/dropdown.cpp60
-rw-r--r--src/gui/widgets/dropdown.h29
-rw-r--r--src/gui/widgets/resizegrip.cpp9
-rw-r--r--src/gui/widgets/resizegrip.h3
-rw-r--r--src/gui/widgets/tab.cpp39
-rw-r--r--src/gui/widgets/tab.h8
-rw-r--r--src/gui/window.cpp16
-rw-r--r--src/gui/windowcontainer.h5
135 files changed, 1553 insertions, 1126 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index dbecf72b..65659df6 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -21,15 +21,17 @@
#include <algorithm>
+#include <guichan/graphics.hpp>
+
#include "browserbox.h"
#include "colour.h"
#include "linkhandler.h"
#include "truetypefont.h"
-BrowserBox::BrowserBox(unsigned int mode):
+BrowserBox::BrowserBox(unsigned int mode, bool opaque):
gcn::Widget(),
mMode(mode), mHighMode(UNDERLINE | BACKGROUND),
- mOpaque(true),
+ mOpaque(opaque),
mUseLinksAndUserColors(true),
mSelectedLink(-1),
mMaxRows(0)
@@ -122,7 +124,18 @@ void BrowserBox::addRow(const std::string &row)
//discard older rows when a row limit has been set
if (mMaxRows > 0)
{
- while (mTextRows.size() > mMaxRows) mTextRows.pop_front();
+ while (mTextRows.size() > mMaxRows)
+ {
+ mTextRows.pop_front();
+ for (unsigned int i = 0; i < mLinks.size(); i++)
+ {
+ mLinks[i].y1 -= font->getHeight();
+ mLinks[i].y2 -= font->getHeight();
+
+ if (mLinks[i].y1 < 0)
+ mLinks.erase(mLinks.begin() + i);
+ }
+ }
}
// Auto size mode
@@ -238,9 +251,10 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mSelectedLink >= 0)
{
+ bool valid;
if ((mHighMode & BACKGROUND))
{
- graphics->setColor(gcn::Color(HIGHLIGHT));
+ graphics->setColor(gcn::Color(textColour->getColour('H', valid)));
graphics->fillRectangle(gcn::Rectangle(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y1,
@@ -251,7 +265,6 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & UNDERLINE))
{
- bool valid;
graphics->setColor(gcn::Color(textColour->getColour('<', valid)));
graphics->drawLine(
mLinks[mSelectedLink].x1,
@@ -263,6 +276,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
int x = 0, y = 0;
int wrappedLines = 0;
+ int link = 0;
TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont());
graphics->setColor(BLACK);
@@ -320,6 +334,12 @@ void BrowserBox::draw(gcn::Graphics *graphics)
int rgb = textColour->getColour(c, valid);
if (c == '<')
{
+ const int size = mLinks[link].x2 - mLinks[link].x1;
+ mLinks[link].x1 = x;
+ mLinks[link].y1 = y;
+ mLinks[link].x2 = mLinks[link].x1 + size;
+ mLinks[link].y2 = y + font->getHeight();
+ link++;
prevColor = selColor;
}
if (valid)
diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h
index 4bdf224b..5dde402e 100644
--- a/src/gui/browserbox.h
+++ b/src/gui/browserbox.h
@@ -22,15 +22,12 @@
#ifndef BROWSERBOX_H
#define BROWSERBOX_H
-#include <iosfwd>
+#include <list>
#include <vector>
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
-#include "../guichanfwd.h"
-#include "../main.h"
-
class LinkHandler;
struct BROWSER_LINK {
@@ -49,7 +46,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
/**
* Constructor.
*/
- BrowserBox(unsigned int mode = AUTO_SIZE);
+ BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true);
/**
* Destructor.
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 9b624015..1d3a04e4 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -19,8 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/exception.hpp>
+#include <guichan/font.hpp>
+
#include "button.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -28,13 +32,8 @@
#include "../utils/dtor.h"
-#include <guichan/exception.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/font.hpp>
-
-#include <algorithm>
-
int Button::mInstances = 0;
+float Button::mAlpha = config.getValue("guialpha", 0.8);
enum{
BUTTON_STANDARD, // 0
@@ -100,6 +99,7 @@ void Button::init()
data[x].gridX, data[y].gridY,
data[x + 1].gridX - data[x].gridX + 1,
data[y + 1].gridY - data[y].gridY + 1);
+ button[mode].grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -126,17 +126,25 @@ void Button::draw(gcn::Graphics *graphics)
{
int mode;
- if (!isEnabled()) {
+ if (!isEnabled())
mode = BUTTON_DISABLED;
- }
- else if (isPressed() || mIsLogged) {
+ else if (isPressed() || mIsLogged)
mode = BUTTON_PRESSED;
- }
- else if (mHasMouse || isFocused()) {
+ else if (mHasMouse || isFocused())
mode = BUTTON_HIGHLIGHTED;
- }
- else {
+ else
mode = BUTTON_STANDARD;
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ button[BUTTON_DISABLED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_PRESSED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_HIGHLIGHTED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_STANDARD].grid[a]->setAlpha(mAlpha);
+ }
}
static_cast<Graphics*>(graphics)->
@@ -147,7 +155,8 @@ void Button::draw(gcn::Graphics *graphics)
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
- switch (getAlignment()) {
+ switch (getAlignment())
+ {
case gcn::Graphics::LEFT:
textX = 4;
break;
@@ -163,10 +172,8 @@ void Button::draw(gcn::Graphics *graphics)
graphics->setFont(getFont());
- if (isPressed()) {
+ if (isPressed())
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
- }
- else {
+ else
graphics->drawText(getCaption(), textX, textY, getAlignment());
- }
}
diff --git a/src/gui/button.h b/src/gui/button.h
index d8ed9fa7..abaf5c43 100644
--- a/src/gui/button.h
+++ b/src/gui/button.h
@@ -22,12 +22,8 @@
#ifndef BUTTON_H
#define BUTTON_H
-#include <iosfwd>
-
#include <guichan/widgets/button.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
/**
@@ -71,6 +67,7 @@ class Button : public gcn::Button
static ImageRect button[4]; /**< Button state graphics */
static int mInstances; /**< Number of button instances */
+ static float mAlpha;
bool mIsLogged; /**< Makes the button appear pressed all the time */
};
diff --git a/src/gui/buttonbox.cpp b/src/gui/buttonbox.cpp
deleted file mode 100644
index 44d65f58..00000000
--- a/src/gui/buttonbox.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "button.h"
-#include "buttonbox.h"
-
-ButtonBox::ButtonBox(const std::string &title, const std::string &buttonTxt,
- ButtonBoxListener *listener) :
- Window(title),
- mListener(listener)
-{
- Button *button = new Button(buttonTxt, "activate", this);
- setContentSize(button->getWidth() + 10,
- button->getHeight() + 10);
- button->setPosition(5, 5);
- add(button);
-}
-
-void ButtonBox::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "activate")
- {
- mListener->buttonBoxRespond();
- }
-}
diff --git a/src/gui/buttonbox.h b/src/gui/buttonbox.h
deleted file mode 100644
index 91dfad34..00000000
--- a/src/gui/buttonbox.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef BUTTONBOX_H
-#define BUTTONBOX_H
-
-#include <string>
-
-#include <guichan/actionlistener.hpp>
-
-#include "window.h"
-
-#include "../guichanfwd.h"
-
-class ButtonBoxListener
-{
- public:
- /*
- * function that ButtonBox calls when the button has been pressed
- */
- virtual void buttonBoxRespond() = 0;
-};
-
-class ButtonBox : public Window, public gcn::ActionListener
-{
- public:
- /*
- * Constructor.
- *
- * @param title is the text that appears at the top of the box
- * @param buttonTxt is the text that appears on the button
- * @param listener points to the class that should respond to the
- * button press
- */
- ButtonBox(const std::string &title, const std::string &buttonTxt,
- ButtonBoxListener *listener);
-
- /*
- * called when the button is pressed
- *
- * @param event is the event that is generated
- */
- void action(const gcn::ActionEvent &event);
-
- private:
- ButtonBoxListener *mListener;
-};
-
-#endif
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 423918ce..0f1cfede 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -25,9 +25,9 @@
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
-#include "window.h"
+#include <SDL_types.h>
-#include "../guichanfwd.h"
+#include "window.h"
class Network;
class ShopItems;
@@ -40,7 +40,7 @@ class ListBox;
* \ingroup Interface
*/
class BuyDialog : public Window, public gcn::ActionListener,
- gcn::SelectionListener
+ public gcn::SelectionListener
{
public:
/**
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index 60a6398d..e3cdc52a 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -26,8 +26,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* A dialog to choose between buying or selling at a shop.
*
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index dcb05aa1..8de4f5a7 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -22,6 +22,7 @@
#include <string>
#include <guichan/font.hpp>
+
#include <guichan/widgets/label.hpp>
#include "button.h"
@@ -40,6 +41,8 @@
#include "../net/charserverhandler.h"
#include "../net/messageout.h"
+#include "../resources/colordb.h"
+
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
#include "../utils/trim.h"
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 5d4ecfa8..23de061d 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -26,9 +26,8 @@
#include "window.h"
-#include "../guichanfwd.h"
-#include "../lockedarray.h"
#include "../being.h"
+#include "../lockedarray.h"
class LocalPlayer;
class Network;
@@ -109,14 +108,12 @@ class CharCreateDialog : public Window, public gcn::ActionListener
*/
~CharCreateDialog();
- void
- action(const gcn::ActionEvent &event);
+ void action(const gcn::ActionEvent &event);
/**
* Unlocks the dialog, enabling the create character button again.
*/
- void
- unlock();
+ void unlock();
private:
/**
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 2e823b60..bc096379 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -28,10 +28,7 @@
#include "../main.h"
#include "../serverinfo.h"
-#include "../net/network.h" // TODO this is just for iptostring, move that?
-
#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
#include "../utils/tostring.h"
extern SERVER_INFO **server_info;
@@ -39,7 +36,8 @@ extern SERVER_INFO **server_info;
/**
* The list model for the server list.
*/
-class ServerListModel : public gcn::ListModel {
+class ServerListModel : public gcn::ListModel
+{
public:
virtual ~ServerListModel() {};
@@ -80,13 +78,12 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState):
add(mOkButton);
add(mCancelButton);
- if (n_server == 0) {
+ if (n_server == 0)
// Disable Ok button
mOkButton->setEnabled(false);
- } else {
+ else
// Select first server
mServerList->setSelected(1);
- }
setLocationRelativeTo(getParent());
setVisible(true);
@@ -100,7 +97,8 @@ ServerSelectDialog::~ServerSelectDialog()
void ServerSelectDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "ok") {
+ if (event.getId() == "ok")
+ {
mOkButton->setEnabled(false);
const SERVER_INFO *si = server_info[mServerList->getSelected()];
mLoginData->hostname = iptostring(si->address);
@@ -108,9 +106,8 @@ void ServerSelectDialog::action(const gcn::ActionEvent &event)
mLoginData->updateHost = si->updateHost;
state = mNextState;
}
- else if (event.getId() == "cancel") {
+ else if (event.getId() == "cancel")
state = LOGIN_STATE;
- }
}
int ServerListModel::getNumberOfElements()
diff --git a/src/gui/char_server.h b/src/gui/char_server.h
index 9419c92d..49a5b47b 100644
--- a/src/gui/char_server.h
+++ b/src/gui/char_server.h
@@ -27,8 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class LoginData;
class ServerListModel;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 4fb92ac5..1c0cea13 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -19,15 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-#include <fstream>
-
#include <guichan/focushandler.hpp>
#include "browserbox.h"
#include "chat.h"
#include "chatinput.h"
#include "itemlinkhandler.h"
+#include "recorder.h"
#include "scrollarea.h"
#include "sdlinput.h"
#include "windowcontainer.h"
@@ -36,11 +34,9 @@
#include "../beingmanager.h"
#include "../configuration.h"
-#include "../extensions.h"
#include "../game.h"
#include "../localplayer.h"
#include "../party.h"
-#include "../recorder.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -75,8 +71,6 @@ Window(""), mNetwork(network), mTmpVisible(false)
mTextOutput->setLinkHandler(mItemLinkHandler);
mScrollArea = new ScrollArea(mTextOutput);
- mScrollArea->setPosition(mScrollArea->getFrameSize(),
- mScrollArea->getFrameSize());
mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
@@ -344,6 +338,11 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
* require server handling by proper packet. Probably
* those if elses should be replaced by protocol calls */
+ trim(msg);
+
+ if (msg.compare("") == 0)
+ return;
+
// Send party message
if (msg.at(0) == mPartyPrefix)
{
@@ -379,14 +378,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
std::string temp = msg.substr(start+1, end - start - 1);
- while (temp[0] == ' ')
- {
- temp = temp.substr(1, temp.size());
- }
- while (temp[temp.size()] == ' ')
- {
- temp = temp.substr(0, temp.size() - 1);
- }
+ trim(temp);
for (unsigned int i = 0; i < temp.size(); i++)
{
@@ -394,10 +386,13 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
}
const ItemInfo itemInfo = ItemDB::get(temp);
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
+ if (itemInfo.getName() != _("Unknown item"))
+ {
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+ }
}
start = msg.find('[', start + 1);
}
@@ -440,7 +435,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
}
else if (command == "help")
{
- msg.erase(0, 6);
trim(msg);
std::size_t space = msg.find(" ");
std::string msg1;
@@ -480,7 +474,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
else if (command == "whisper" || command == "msg" || command == "w")
whisper(nick, msg);
else if (command == "record")
- mRecorder->respond(msg);
+ mRecorder->changeRecordingStatus(msg);
else if (command == "toggle")
{
if (msg == "")
@@ -540,32 +534,27 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
* This will eventually be replaced by a GUI, so
* we don't need to get too sophisticated
*/
- if (extensions.aethyra_spells)
+ MessageOut outMsg(mNetwork);
+ if (msg == "heal")
{
- MessageOut outMsg(mNetwork);
- if (msg == "heal")
- {
- outMsg.writeInt16(0x03f3);
- outMsg.writeInt16(0x01);
- outMsg.writeInt32(0);
- outMsg.writeInt8(0);
- outMsg.writeInt8(0);
- outMsg.writeString("", 24);
- }
- else if (msg == "gather")
- {
- outMsg.writeInt16(0x03f3);
- outMsg.writeInt16(0x02);
- outMsg.writeInt32(0);
- outMsg.writeInt8(0);
- outMsg.writeInt8(0);
- outMsg.writeString("", 24);
- }
- else
- chatLog(_("No such spell!"), BY_SERVER);
+ outMsg.writeInt16(0x03f3);
+ outMsg.writeInt16(0x01);
+ outMsg.writeInt32(0);
+ outMsg.writeInt8(0);
+ outMsg.writeInt8(0);
+ outMsg.writeString("", 24);
+ }
+ else if (msg == "gather")
+ {
+ outMsg.writeInt16(0x03f3);
+ outMsg.writeInt16(0x02);
+ outMsg.writeInt32(0);
+ outMsg.writeInt8(0);
+ outMsg.writeInt8(0);
+ outMsg.writeString("", 24);
}
else
- chatLog(_("The current server doesn't support spells"), BY_SERVER);
+ chatLog(_("No such spell!"), BY_SERVER);
}
else if (command == "present")
{
@@ -745,10 +734,10 @@ void ChatWindow::setInputText(std::string input_str)
requestChatFocus();
}
-void ChatWindow::addItemText(int itemId, const std::string &item)
+void ChatWindow::addItemText(const std::string &item)
{
std::ostringstream text;
- text << "[@@" << itemId << "|" << item << "@@] ";
+ text << "[" << item << "] ";
mChatInput->setText(mChatInput->getText() + text.str());
requestChatFocus();
}
@@ -805,10 +794,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2)
chatLog(_("/announce: Global announcement (GM only)"), BY_SERVER);
chatLog(_("/clear: Clears this window"), BY_SERVER);
chatLog(_("/help: Display this help"), BY_SERVER);
- mParty->help();
+ chatLog(_("/party <command> <params>: Party commands."), BY_SERVER);
chatLog(_("/msg <nick> <message>: Alternate form for /whisper"), BY_SERVER);
chatLog(_("/present: Get list of players present"), BY_SERVER);
- mRecorder->help();
+ chatLog(_("/record <filename>: Start recording the chat to an"
+ " external file."), BY_SERVER);
chatLog(_("/toggle: Determine whether <return> toggles the chat log."),
BY_SERVER);
chatLog(_("/where: Display map name"), BY_SERVER);
@@ -852,7 +842,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2)
}
else if (msg1 == "record")
{
- mRecorder->help(msg2);
+ chatLog(_("Command: /record <filename>"), BY_SERVER);
+ chatLog(_("This command starts recording the chat log to the file "
+ "<filename>."), BY_SERVER);
+ chatLog(_("Command: /record"), BY_SERVER);
+ chatLog(_("This command finishes a recording session."), BY_SERVER);
}
else if (msg1 == "toggle")
{
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 176fccb7..2fadb014 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -22,7 +22,6 @@
#ifndef CHAT_H
#define CHAT_H
-#include <fstream>
#include <list>
#include <string>
@@ -31,8 +30,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class BrowserBox;
class Network;
class Recorder;
@@ -182,7 +179,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
void setInputText(std::string input_str);
/** Called to add item to chat */
- void addItemText(int itemid, const std::string &item);
+ void addItemText(const std::string &item);
/** Override to reset mTmpVisible */
void setVisible(bool visible);
diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h
index d98e120b..a4a50502 100644
--- a/src/gui/chatinput.h
+++ b/src/gui/chatinput.h
@@ -26,8 +26,6 @@
#include "textfield.h"
-#include "../guichanfwd.h"
-
/**
* The chat input hides when it loses focus. It is also invisible by default.
*/
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index b8fca2b8..511ed34c 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -21,12 +21,14 @@
#include "checkbox.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
int CheckBox::instances = 0;
+float CheckBox::mAlpha = config.getValue("guialpha", 0.8);
Image *CheckBox::checkBoxNormal;
Image *CheckBox::checkBoxChecked;
Image *CheckBox::checkBoxDisabled;
@@ -43,6 +45,13 @@ CheckBox::CheckBox(const std::string& caption, bool selected):
checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10);
checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10);
+ if (config.getValue("opengl", 0))
+ {
+ checkBoxNormal->setAlpha(mAlpha);
+ checkBoxChecked->setAlpha(mAlpha);
+ checkBoxDisabled->setAlpha(mAlpha);
+ checkBoxDisabledChecked->setAlpha(mAlpha);
+ }
checkBox->decRef();
}
@@ -66,16 +75,26 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
{
Image *box;
- if (isSelected()) {
- if (isEnabled()) {
+ if (isSelected())
+ {
+ if (isEnabled())
box = checkBoxChecked;
- } else {
+ else
box = checkBoxDisabledChecked;
- }
- } else if (isEnabled()) {
+ }
+ else if (isEnabled())
box = checkBoxNormal;
- } else {
+ else
box = checkBoxDisabled;
+
+ if (config.getValue("guialpha", 0.8) != mAlpha &&
+ config.getValue("opengl", 0))
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ checkBoxNormal->setAlpha(mAlpha);
+ checkBoxChecked->setAlpha(mAlpha);
+ checkBoxDisabled->setAlpha(mAlpha);
+ checkBoxDisabledChecked->setAlpha(mAlpha);
}
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h
index d92fc822..20adb43c 100644
--- a/src/gui/checkbox.h
+++ b/src/gui/checkbox.h
@@ -22,12 +22,8 @@
#ifndef CHECKBOX_H
#define CHECKBOX_H
-#include <iosfwd>
-
#include <guichan/widgets/checkbox.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
@@ -35,7 +31,8 @@ class Image;
*
* \ingroup GUI
*/
-class CheckBox : public gcn::CheckBox {
+class CheckBox : public gcn::CheckBox
+{
public:
/**
* Constructor.
@@ -54,6 +51,7 @@ class CheckBox : public gcn::CheckBox {
private:
static int instances;
+ static float mAlpha;
static Image *checkBoxNormal;
static Image *checkBoxChecked;
static Image *checkBoxDisabled;
diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp
index 78e35e97..cdb5a3fd 100644
--- a/src/gui/colour.cpp
+++ b/src/gui/colour.cpp
@@ -19,18 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstdio>
-
#include "colour.h"
#include "../configuration.h"
#include "../utils/gettext.h"
+#include "../utils/tostring.h"
Colour::Colour()
{
addColour('C', 0x000000, _("Chat"));
addColour('G', 0xff0000, _("GM"));
+ addColour('H', 0xebc873, _("Highlight"));
addColour('Y', 0x1fa052, _("Player"));
addColour('W', 0x0000ff, _("Whisper"));
addColour('I', 0xf1dc27, _("Is"));
@@ -48,9 +48,7 @@ Colour::~Colour()
col != colEnd;
++col)
{
- char buffer[20];
- std::sprintf(buffer, "0x%06x", col->rgb);
- config.setValue("Colour" + col->text, buffer);
+ config.setValue("Colour" + col->text, toString(col->rgb));
}
}
@@ -95,6 +93,15 @@ std::string Colour::getElementAt(int i)
return mColVector[i].text;
}
+char Colour::getColourCharAt(int i)
+{
+ if (i < 0 || i >= getNumberOfElements())
+ {
+ return 'C';
+ }
+ return mColVector[i].ch;
+}
+
void Colour::addColour(const char c, const int rgb, const std::string &text)
{
int trueRgb = config.getValue("Colour" + text, rgb);
diff --git a/src/gui/colour.h b/src/gui/colour.h
index 1ffe6e30..6ea02840 100644
--- a/src/gui/colour.h
+++ b/src/gui/colour.h
@@ -22,14 +22,11 @@
#ifndef COLOUR_H
#define COLOUR_H
-#include <cstdio>
#include <string>
#include <vector>
#include <guichan/listmodel.hpp>
-#include "../guichanfwd.h"
-
class Colour : public gcn::ListModel
{
public:
@@ -91,6 +88,12 @@ class Colour : public gcn::ListModel
int getColourAt(int i);
/**
+ * Get the character used by the colour for the element at index i in
+ * the current colour model
+ */
+ char getColourCharAt(int i);
+
+ /**
* Set the colour for the element at index i
*/
void setColourAt(int i, int rgb);
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index ce0a8a68..38697f3a 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -21,7 +21,10 @@
#include <guichan/font.hpp>
+#include "button.h"
#include "confirm_dialog.h"
+#include "scrollarea.h"
+#include "textbox.h"
#include "../utils/gettext.h"
@@ -41,8 +44,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setOpaque(false);
- mTextBox->setMinWidth(260);
- mTextBox->setTextWrapped(msg);
+ mTextBox->setTextWrapped(msg, 260);
int numRows = mTextBox->getNumberOfRows();
int width = getFont()->getWidth(title);
@@ -77,7 +79,8 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
add(yesButton);
add(noButton);
- if (getParent()) {
+ if (getParent())
+ {
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h
index fb8290c8..3fa2b90d 100644
--- a/src/gui/confirm_dialog.h
+++ b/src/gui/confirm_dialog.h
@@ -24,19 +24,18 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../guichanfwd.h"
+class ScrollArea;
+class TextBox;
/**
* An option dialog.
*
* \ingroup GUI
*/
-class ConfirmDialog : public Window, public gcn::ActionListener {
+class ConfirmDialog : public Window, public gcn::ActionListener
+{
public:
/**
* Constructor.
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 15d85bbc..a69698e9 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -31,7 +31,8 @@
#include "../utils/gettext.h"
-namespace {
+namespace
+{
struct ConnectionActionListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event) { state = EXIT_STATE; }
@@ -62,10 +63,10 @@ ConnectionDialog::ConnectionDialog():
void ConnectionDialog::logic()
{
mProgress += 0.005f;
+
if (mProgress > 1.0f)
- {
mProgress = 0.0f;
- }
+
mProgressBar->setProgress(mProgress);
Window::logic();
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 223b7fbd..5a5acfad 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -23,9 +23,7 @@
#include <guichan/widgets/label.hpp>
-#include "button.h"
#include "debugwindow.h"
-#include "gui.h"
#include "viewport.h"
#include "widgets/layout.h"
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index 00119d15..e089de27 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -22,14 +22,10 @@
#ifndef DEBUGWINDOW_H
#define DEBUGWINDOW_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The debug window.
*
diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h
index ca7b533a..fefce793 100644
--- a/src/gui/emotecontainer.h
+++ b/src/gui/emotecontainer.h
@@ -29,8 +29,6 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class AnimatedSprite;
class Image;
diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp
index a0142663..b66592c1 100644
--- a/src/gui/emoteshortcutcontainer.cpp
+++ b/src/gui/emoteshortcutcontainer.cpp
@@ -22,6 +22,7 @@
#include "emoteshortcutcontainer.h"
#include "../animatedsprite.h"
+#include "../configuration.h"
#include "../emoteshortcut.h"
#include "../graphics.h"
#include "../inventory.h"
@@ -42,11 +43,10 @@
static const int MAX_ITEMS = 12;
EmoteShortcutContainer::EmoteShortcutContainer():
+ ShortcutContainer(),
mEmoteClicked(false),
mEmoteMoved(0)
{
- mGridWidth = 1,
- mGridHeight = 1,
addMouseListener(this);
addWidgetListener(this);
@@ -54,6 +54,8 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
+ mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
@@ -96,6 +98,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
}
}
+
if (mEmoteMoved)
{
// Draw the emote image being dragged by the cursor.
@@ -108,6 +111,12 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
sprite->draw(g, tPosX, tPosY);
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ mBackgroundImg->setAlpha(mAlpha);
+ }
}
void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event)
diff --git a/src/gui/emoteshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h
index 54ca1714..d32a9f79 100644
--- a/src/gui/emoteshortcutcontainer.h
+++ b/src/gui/emoteshortcutcontainer.h
@@ -24,12 +24,8 @@
#include <vector>
-#include <guichan/mouselistener.hpp>
-
#include "shortcutcontainer.h"
-#include "../guichanfwd.h"
-
class AnimatedSprite;
class Image;
diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp
index 95f73933..f4a8999a 100644
--- a/src/gui/emotewindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -19,16 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-
-#include <guichan/mouseinput.hpp>
-
#include "button.h"
#include "gui.h"
#include "emotewindow.h"
#include "emotecontainer.h"
#include "scrollarea.h"
-#include "textbox.h"
#include "widgets/layout.h"
diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h
index 0e938bc9..8af24a7b 100644
--- a/src/gui/emotewindow.h
+++ b/src/gui/emotewindow.h
@@ -27,8 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class EmoteContainer;
class TextBox;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 40496381..a2be6b00 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -26,7 +26,9 @@
#include "button.h"
#include "equipmentwindow.h"
+#include "itempopup.h"
#include "playerbox.h"
+#include "viewport.h"
#include "../equipment.h"
#include "../graphics.h"
@@ -55,12 +57,12 @@ static const int boxPosition[][2] = {
{129, 78} // EQUIP_AMMO_SLOT
};
-EquipmentWindow::EquipmentWindow(Equipment *equipment):
+EquipmentWindow::EquipmentWindow():
Window(_("Equipment")),
- mEquipment(equipment),
mSelected(-1)
-
{
+ mItemPopup = new ItemPopup();
+
// Control that shows the Player
mPlayerBox = new PlayerBox;
mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 123));
@@ -85,12 +87,15 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
}
+ mEquipment = player_node->mEquipment.get();
mInventory = player_node->getInventory();
}
EquipmentWindow::~EquipmentWindow()
{
delete mUnequip;
+ delete mItemPopup;
+ delete mPlayerBox;
}
void EquipmentWindow::draw(gcn::Graphics *graphics)
@@ -153,6 +158,23 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
}
}
+Item* EquipmentWindow::getItem(const int &x, const int &y)
+{
+ for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
+ {
+ gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT);
+
+ if (tRect.isPointInRect(x, y))
+ {
+ return (i != EQUIP_AMMO_SLOT) ?
+ mInventory->getItem(mEquipment->getEquipment(i)) :
+ mInventory->getItem(mEquipment->getArrows());
+ }
+ }
+ return NULL;
+}
+
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
@@ -162,21 +184,67 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
Item* item;
- // Checks if any of the presses were in the equip boxes.
- for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
+ if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
- item = (i != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(i)) :
- mInventory->getItem(mEquipment->getArrows());
- gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT);
- if (tRect.isPointInRect(x, y))
+ // Checks if any of the presses were in the equip boxes.
+ for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
{
- if (item)
+ item = (i != EQUIP_AMMO_SLOT) ?
+ mInventory->getItem(mEquipment->getEquipment(i)) :
+ mInventory->getItem(mEquipment->getArrows());
+ gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT);
+
+ if (tRect.isPointInRect(x, y))
{
- mSelected = i;
+ if (item)
+ {
+ mSelected = i;
+ }
}
}
}
+ else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ item = getItem(x, y);
+
+ if (!item)
+ return;
+
+ /* Convert relative to the window coordinates to absolute screen
+ * coordinates.
+ */
+ const int mx = x + getX();
+ const int my = y + getY();
+ viewport->showPopup(mx, my, item);
+ }
}
+// Show ItemTooltip
+void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
+{
+ const int x = event.getX();
+ const int y = event.getY();
+
+ Item* item = getItem(x, y);
+
+ if (item)
+ {
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
+
+ mItemPopup->setItem(item->getInfo());
+ mItemPopup->setOpaque(false);
+ mItemPopup->view(x + getX(), y + getY());
+ }
+ else
+ {
+ mItemPopup->setVisible(false);
+ }
+}
+
+// Hide ItemTooltip
+void EquipmentWindow::mouseExited(gcn::MouseEvent &event)
+{
+ mItemPopup->setVisible(false);
+}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0b3aede0..c491062a 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -28,6 +28,8 @@
class Equipment;
class Inventory;
+class Item;
+class ItemPopup;
class PlayerBox;
/**
@@ -50,7 +52,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
/**
* Constructor.
*/
- EquipmentWindow(Equipment *equipment);
+ EquipmentWindow();
/**
* Destructor.
@@ -84,11 +86,18 @@ class EquipmentWindow : public Window, public gcn::ActionListener
private:
+ void mouseExited(gcn::MouseEvent &event);
+ void mouseMoved(gcn::MouseEvent &event);
+
+ Item* getItem(const int &x, const int &y);
+
Equipment *mEquipment;
Inventory *mInventory;
gcn::Button *mUnequip; /**< Button for unequipping. */
EquipBox mEquipBox[EQUIP_VECTOREND]; /**< Equipment Boxes. */
+ ItemPopup *mItemPopup;
+
PlayerBox *mPlayerBox;
int mSelected; /**< Index of selected item. */
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
index 124b5472..b0639bd8 100644
--- a/src/gui/focushandler.h
+++ b/src/gui/focushandler.h
@@ -26,8 +26,6 @@
#include <guichan/focushandler.hpp>
-#include "../guichanfwd.h"
-
/**
* The focus handler. This focus handler does exactly the same as the Guichan
* focus handler, but keeps a stack of modal widgets to be able to handle
diff --git a/src/gui/gccontainer.h b/src/gui/gccontainer.h
index 0a573645..da584a42 100644
--- a/src/gui/gccontainer.h
+++ b/src/gui/gccontainer.h
@@ -26,8 +26,6 @@
#include <guichan/widgets/container.hpp>
-#include "../guichanfwd.h"
-
/**
* A garbage collecting container. Childs added to this container are
* automatically deleted when the container is deleted.
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 642e916b..7779a503 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -63,7 +63,8 @@ class GuiConfigListener : public ConfigListener
void optionChanged(const std::string &name)
{
- if (name == "customcursor") {
+ if (name == "customcursor")
+ {
bool bCustomCursor = config.getValue("customcursor", 1) == 1;
mGui->setUseCustomCursor(bCustomCursor);
}
@@ -107,7 +108,8 @@ Gui::Gui(Graphics *graphics):
// Set global font
std::string path = resman->getPath("fonts/dejavusans.ttf");
- try {
+ try
+ {
const int fontSize = config.getValue("fontSize", 11);
mGuiFont = new TrueTypeFont(path, fontSize);
}
@@ -119,7 +121,8 @@ Gui::Gui(Graphics *graphics):
// Set bold font
path = resman->getPath("fonts/dejavusans-bold.ttf");
- try {
+ try
+ {
const int fontSize = config.getValue("fontSize", 11);
boldFont = new TrueTypeFont(path, fontSize);
}
@@ -132,7 +135,8 @@ Gui::Gui(Graphics *graphics):
gcn::Widget::setGlobalFont(mGuiFont);
// Load hits' colourful fonts
- try {
+ try
+ {
hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png",
"0123456789crit! ");
hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png",
@@ -182,12 +186,13 @@ Gui::~Gui()
void Gui::logic()
{
// Fade out mouse cursor after extended inactivity
- if (mMouseInactivityTimer < 100 * 15) {
+ if (mMouseInactivityTimer < 100 * 15)
+ {
++mMouseInactivityTimer;
mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f);
- } else {
- mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f);
}
+ else
+ mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f);
gcn::Gui::logic();
}
@@ -232,9 +237,8 @@ void Gui::setUseCustomCursor(bool customCursor)
mMouseCursors =
resman->getImageSet("graphics/gui/mouse.png", 40, 40);
- if (!mMouseCursors) {
+ if (!mMouseCursors)
logger->error("Unable to load mouse cursors.");
- }
}
else
{
@@ -242,7 +246,8 @@ void Gui::setUseCustomCursor(bool customCursor)
SDL_ShowCursor(SDL_ENABLE);
// Unload the mouse cursor
- if (mMouseCursors) {
+ if (mMouseCursors)
+ {
mMouseCursors->decRef();
mMouseCursors = NULL;
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 9681d44a..5c0c24f7 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -115,7 +115,6 @@ class Gui : public gcn::Gui
};
extern Gui *gui; /**< The GUI system */
-extern Viewport *viewport; /**< The viewport */
extern SDLInput *guiInput; /**< GUI input */
/**
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 6b14f6d8..ece2dce4 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -33,6 +33,8 @@
HelpWindow::HelpWindow():
Window(_("Help"))
{
+ setMinWidth(300);
+ setMinHeight(250);
setContentSize(455, 350);
setWindowName(_("Help"));
setResizable(true);
diff --git a/src/gui/help.h b/src/gui/help.h
index 2ba74c0a..98e3aa67 100644
--- a/src/gui/help.h
+++ b/src/gui/help.h
@@ -27,8 +27,6 @@
#include "linkhandler.h"
#include "window.h"
-#include "../guichanfwd.h"
-
class BrowserBox;
/**
diff --git a/src/gui/inttextfield.h b/src/gui/inttextfield.h
index 2a913ef6..add78084 100644
--- a/src/gui/inttextfield.h
+++ b/src/gui/inttextfield.h
@@ -24,8 +24,6 @@
#include "textfield.h"
-#include "../guichanfwd.h"
-
/**
* TextBox which only accepts numbers as input.
*/
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 3b868610..b9fe1c90 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -27,13 +27,11 @@
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "gui.h"
#include "inventorywindow.h"
#include "item_amount.h"
#include "itemcontainer.h"
#include "progressbar.h"
#include "scrollarea.h"
-#include "textbox.h"
#include "viewport.h"
#include "widgets/layout.h"
@@ -91,21 +89,33 @@ InventoryWindow::InventoryWindow(int invSize):
setMinHeight(130);
setMinWidth(mWeightLabel->getWidth() + mSlotsLabel->getWidth() + 310);
- place(0, 0, mInvenScroll, 7, 4);
- place(0, 4, mWeightLabel).setPadding(3);
- place(1, 4, mWeightBar, 2);
- place(3, 4, mSlotsLabel).setPadding(3);
- place(4, 4, mSlotsBar, 2);
+ place(0, 0, mWeightLabel).setPadding(3);
+ place(1, 0, mWeightBar, 2);
+ place(3, 0, mSlotsLabel).setPadding(3);
+ place(4, 0, mSlotsBar, 2);
+ place(0, 1, mInvenScroll, 7, 4);
place(5, 5, mDropButton);
place(6, 5, mUseButton);
Layout &layout = getLayout();
- layout.setRowHeight(0, Layout::AUTO_SET);
+ layout.setRowHeight(0, mDropButton->getHeight());
loadWindowState();
setLocationRelativeTo(getParent());
}
+InventoryWindow::~InventoryWindow()
+{
+ delete mWeightBar;
+ delete mSlotsBar;
+ delete mUseButton;
+ delete mDropButton;
+ delete mItems;
+ delete mWeightLabel;
+ delete mSlotsLabel;
+ delete mInvenScroll;
+}
+
void InventoryWindow::logic()
{
Window::logic();
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 2c19ce26..78d30461 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -27,7 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
#include "../localplayer.h"
class Item;
@@ -50,6 +49,11 @@ class InventoryWindow : public Window, gcn::ActionListener,
InventoryWindow(int invSize = (INVENTORY_SIZE - 2));
/**
+ * Destructor.
+ */
+ ~InventoryWindow();
+
+ /**
* Logic (updates buttons and weight information).
*/
void logic();
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index d8682c95..92be3d6e 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -70,7 +70,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
resetAmount();
- switch (usage) {
+ switch (usage)
+ {
case AMOUNT_TRADE_ADD:
setCaption(_("Select amount of items to trade."));
okButton->setActionEventId("AddTrade");
diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h
index d8eedadb..618d7d51 100644
--- a/src/gui/item_amount.h
+++ b/src/gui/item_amount.h
@@ -22,14 +22,10 @@
#ifndef ITEM_AMOUNT_WINDOW_H
#define ITEM_AMOUNT_WINDOW_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class IntTextField;
class Item;
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index e3ecdd4e..0beb5cfb 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -36,7 +36,6 @@
#include "../log.h"
#include "../resources/image.h"
-#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
#include "../utils/tostring.h"
@@ -68,6 +67,7 @@ ItemContainer::ItemContainer(Inventory *inventory, int offset):
ItemContainer::~ItemContainer()
{
mSelImg->decRef();
+ delete mItemPopup;
}
void ItemContainer::logic()
@@ -124,6 +124,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
}
// Draw item caption
+ graphics->setFont(getFont());
graphics->setColor(gcn::Color(0, 0, 0));
graphics->drawText(
(item->isEquipped() ? "Eq." : toString(item->getQuantity())),
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 1905e820..71fcc5d0 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -28,8 +28,6 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class Image;
class Inventory;
class Item;
diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp
index 34c12a0c..97c0b94f 100644
--- a/src/gui/itemlinkhandler.cpp
+++ b/src/gui/itemlinkhandler.cpp
@@ -19,6 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <sstream>
+#include <string>
+
#include <SDL_mouse.h>
#include "itemlinkhandler.h"
@@ -27,9 +30,6 @@
#include "../resources/iteminfo.h"
#include "../resources/itemdb.h"
-#include <sstream>
-#include <string>
-
ItemLinkHandler::ItemLinkHandler()
{
mItemPopup = new ItemPopup;
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 2d3797c9..df7afa48 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -26,16 +26,15 @@
#include "gui.h"
#include "itempopup.h"
+#include "scrollarea.h"
+#include "textbox.h"
#include "windowcontainer.h"
#include "widgets/layout.h"
-#include "../resources/image.h"
#include "../resources/iteminfo.h"
-#include "../resources/resourcemanager.h"
#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
#include "../utils/tostring.h"
ItemPopup::ItemPopup():
@@ -47,16 +46,12 @@ ItemPopup::ItemPopup():
// Item Name
mItemName = new gcn::Label("Label");
- mItemName->setFont(gui->getFont());
- mItemName->setPosition(2, 2);
- mItemName->setWidth(getWidth() - 4);
mItemName->setFont(boldFont);
+ mItemName->setPosition(2, 2);
// Item Description
mItemDesc = new TextBox();
mItemDesc->setEditable(false);
- mItemDesc->setMinWidth(186);
- mItemDesc->setTextWrapped("");
mItemDescScroll = new ScrollArea(mItemDesc);
mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -68,8 +63,6 @@ ItemPopup::ItemPopup():
// Item Effect
mItemEffect = new TextBox();
mItemEffect->setEditable(false);
- mItemEffect->setMinWidth(186);
- mItemEffect->setTextWrapped("");
mItemEffectScroll = new ScrollArea(mItemEffect);
mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -81,8 +74,6 @@ ItemPopup::ItemPopup():
// Item Weight
mItemWeight = new TextBox();
mItemWeight->setEditable(false);
- mItemWeight->setMinWidth(186);
- mItemWeight->setTextWrapped("");
mItemWeightScroll = new ScrollArea(mItemWeight);
mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -97,42 +88,57 @@ ItemPopup::ItemPopup():
add(mItemWeightScroll);
setLocationRelativeTo(getParent());
+}
- // LEEOR / TODO: This causes an exception error.
- //moveToBottom(getParent());
+ItemPopup::~ItemPopup()
+{
+ delete mItemName;
+ delete mItemDesc;
+ delete mItemDescScroll;
+ delete mItemEffect;
+ delete mItemEffectScroll;
+ delete mItemWeight;
+ delete mItemWeightScroll;
}
void ItemPopup::setItem(const ItemInfo &item)
{
- const gcn::Rectangle &area = getChildrenArea();
- const int width = area.width;
+ mItemName->setCaption(item.getName());
+ mItemName->setForegroundColor(getColor(item.getType()));
+ mItemName->setWidth(boldFont->getWidth(item.getName()));
+ mItemDesc->setTextWrapped(item.getDescription(), 196);
+ mItemEffect->setTextWrapped(item.getEffect(), 196);
+ mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
+ _(" grams"), 196);
- mItemDesc->setMinWidth(width - 10);
- mItemEffect->setMinWidth(width - 10);
- mItemWeight->setMinWidth(width - 10);
+ int minWidth = mItemName->getWidth();
- mItemName->setCaption(item.getName());
- mItemDesc->setTextWrapped(item.getDescription());
- mItemEffect->setTextWrapped(item.getEffect());
- mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
- _(" grams"));
+ if (mItemDesc->getMinWidth() > minWidth)
+ minWidth = mItemDesc->getMinWidth();
+ if (mItemEffect->getMinWidth() > minWidth)
+ minWidth = mItemEffect->getMinWidth();
+ if (mItemWeight->getMinWidth() > minWidth)
+ minWidth = mItemWeight->getMinWidth();
+
+ minWidth += 8;
+ setWidth(minWidth);
int numRowsDesc = mItemDesc->getNumberOfRows();
int numRowsEffect = mItemEffect->getNumberOfRows();
int numRowsWeight = mItemWeight->getNumberOfRows();
- mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsDesc * getFont()->getHeight()));
- mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsEffect * getFont()->getHeight()));
- mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsWeight * getFont()->getHeight()));
if (item.getEffect() == "")
{
- setContentSize(200, (numRowsDesc * getFont()->getHeight() +
+ setContentSize(minWidth, (numRowsDesc * getFont()->getHeight() +
(3 * getFont()->getHeight())));
mItemWeightScroll->setPosition(2,
@@ -141,7 +147,7 @@ void ItemPopup::setItem(const ItemInfo &item)
}
else
{
- setContentSize(200, (numRowsDesc * getFont()->getHeight()) +
+ setContentSize(minWidth, (numRowsDesc * getFont()->getHeight()) +
(numRowsEffect * getFont()->getHeight()) +
(3 * getFont()->getHeight()));
@@ -156,6 +162,40 @@ void ItemPopup::setItem(const ItemInfo &item)
(2 * getFont()->getHeight()));
}
+gcn::Color ItemPopup::getColor(const std::string& type)
+{
+ gcn::Color color;
+
+ if (type.compare("generic") == 0)
+ color = 0x21a5b1;
+ else if (type.compare("equip-head") == 0)
+ color = 0x527fa4;
+ else if (type.compare("usable") == 0)
+ color = 0x268d24;
+ else if (type.compare("equip-torso") == 0)
+ color = 0xd12aa4;
+ else if (type.compare("equip-1hand") == 0)
+ color = 0xf42a2a;
+ else if (type.compare("equip-legs") == 0)
+ color = 0x699900;
+ else if (type.compare("equip-feet") == 0)
+ color = 0xaa1d48;
+ else if (type.compare("equip-2hand") == 0)
+ color = 0xf46d0e;
+ else if (type.compare("equip-shield") == 0)
+ color = 0x9c2424;
+ else if (type.compare("equip-ring") == 0)
+ color = 0x0000ff;
+ else if (type.compare("equip-arms") == 0)
+ color = 0x9c24e8;
+ else if (type.compare("equip-ammo") == 0)
+ color = 0x8b6311;
+ else
+ color = 0x000000;
+
+ return color;
+}
+
unsigned int ItemPopup::getNumRows()
{
return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() +
@@ -166,10 +206,10 @@ void ItemPopup::view(int x, int y)
{
if (windowContainer->getWidth() < (x + getWidth() + 5))
x = windowContainer->getWidth() - getWidth();
- if ((y - getHeight() - 5) < 0)
+ if ((y - getHeight() - 10) < 0)
y = 0;
else
- y = y - getHeight() - 5;
+ y = y - getHeight() - 10;
setPosition(x, y);
setVisible(true);
requestMoveToTop();
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index d4ad0e20..c820e3a0 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -23,16 +23,17 @@
#ifndef ITEMPOPUP_H
#define ITEMPOPUP_H
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../item.h"
+class ItemInfo;
+class ScrollArea;
+class TextBox;
class ItemPopup : public Window
{
public:
ItemPopup();
+ ~ItemPopup();
void setItem(const ItemInfo &item);
unsigned int getNumRows();
@@ -46,6 +47,8 @@ class ItemPopup : public Window
ScrollArea *mItemDescScroll;
ScrollArea *mItemEffectScroll;
ScrollArea *mItemWeightScroll;
+
+ gcn::Color getColor(const std::string& type);
};
#endif // ITEMPOPUP_H
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 3735afe2..42e3b853 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -20,7 +20,6 @@
*/
#include <SDL_mouse.h>
-#include "gui.h"
#include "itemshortcutcontainer.h"
#include "itempopup.h"
#include "viewport.h"
@@ -39,11 +38,10 @@
#include "../utils/tostring.h"
ItemShortcutContainer::ItemShortcutContainer():
+ ShortcutContainer(),
mItemClicked(false),
mItemMoved(NULL)
{
- mGridWidth=1;
- mGridHeight=1;
addMouseListener(this);
addWidgetListener(this);
@@ -63,6 +61,7 @@ ItemShortcutContainer::ItemShortcutContainer():
ItemShortcutContainer::~ItemShortcutContainer()
{
mBackgroundImg->decRef();
+ delete mItemPopup;
}
void ItemShortcutContainer::logic()
@@ -137,6 +136,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
gcn::Graphics::CENTER);
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ }
}
void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h
index d6a04d7b..22d94ec2 100644
--- a/src/gui/itemshortcutcontainer.h
+++ b/src/gui/itemshortcutcontainer.h
@@ -26,8 +26,6 @@
#include "shortcutcontainer.h"
-#include "../guichanfwd.h"
-
class Image;
class Item;
class ItemPopup;
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index 990a0ade..b63d6424 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -22,10 +22,14 @@
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
#include <guichan/listmodel.hpp>
-#include <guichan/mouseinput.hpp>
+#include "colour.h"
#include "listbox.h"
+#include "../configuration.h"
+
+float ListBox::mAlpha = config.getValue("guialpha", 0.8);
+
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel)
{
@@ -36,21 +40,28 @@ void ListBox::draw(gcn::Graphics *graphics)
if (!mListModel)
return;
- graphics->setColor(gcn::Color(235, 200, 115));
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ bool valid;
+ const int red = (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green = (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 255;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
graphics->setFont(getFont());
- int fontHeight = getFont()->getHeight();
+ const int fontHeight = getFont()->getHeight();
// Draw rectangle below the selected list element
- if (mSelected >= 0) {
+ if (mSelected >= 0)
graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected,
getWidth(), fontHeight));
- }
// Draw the list elements
- graphics->setColor(gcn::Color(0, 0, 0));
- for (int i = 0, y = 0;
- i < mListModel->getNumberOfElements();
+ graphics->setColor(gcn::Color(0, 0, 0, 255));
+ for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += fontHeight)
{
graphics->drawText(mListModel->getElementAt(i), 1, y);
diff --git a/src/gui/listbox.h b/src/gui/listbox.h
index 3d0062bc..12fcb955 100644
--- a/src/gui/listbox.h
+++ b/src/gui/listbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/listbox.hpp>
-#include "../guichanfwd.h"
-
class SelectionListener;
/**
@@ -49,6 +47,9 @@ class ListBox : public gcn::ListBox
void draw(gcn::Graphics *graphics);
void mouseDragged(gcn::MouseEvent &event);
+
+ private:
+ static float mAlpha;
};
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index bf1727ac..e22ee2ad 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -19,18 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-#include <vector>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "checkbox.h"
+#include "listbox.h"
#include "login.h"
#include "ok_dialog.h"
#include "passwordfield.h"
+#include "scrollarea.h"
#include "textfield.h"
+#include "widgets/dropdown.h"
#include "widgets/layout.h"
#include "../main.h"
@@ -62,7 +62,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
dfltPort.push_back("21001");
mServerList = new DropDownList("MostRecent00", dfltServer, dfltPort,
MAX_SERVER_LIST_SIZE);
- mServerListBox = new gcn::ListBox(mServerList);
+ mServerListBox = new ListBox(mServerList);
mServerScrollArea = new ScrollArea();
mUserField = new TextField(mLoginData->username);
@@ -72,6 +72,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
mServerDropDown = new DropDown(mServerList,
mServerScrollArea,
mServerListBox);
+ mServerDropDown->setOpaque(false);
mKeepCheck = new CheckBox(_("Remember Username"), mLoginData->remember);
mOkButton = new Button(_("OK"), "ok", this);
diff --git a/src/gui/login.h b/src/gui/login.h
index b7abbb2a..c0d6e755 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -22,21 +22,18 @@
#ifndef LOGIN_H
#define LOGIN_H
-#include <iosfwd>
#include <string>
#include <vector>
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
+#include <guichan/listmodel.hpp>
-#include "scrollarea.h"
#include "window.h"
-#include "widgets/dropdown.h"
-
-#include "../guichanfwd.h"
-
+class DropDown;
class LoginData;
+class ScrollArea;
/**
* The login dialog.
@@ -132,7 +129,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
};
DropDownList *mServerList;
gcn::ListBox *mServerListBox;
- ScrollArea *mServerScrollArea;
+ gcn::ScrollArea *mServerScrollArea;
};
#endif
diff --git a/src/gui/menuwindow.h b/src/gui/menuwindow.h
index 9b784c35..9bb54e29 100644
--- a/src/gui/menuwindow.h
+++ b/src/gui/menuwindow.h
@@ -24,8 +24,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The Button Menu.
*
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index cc9173ef..55cd8b5d 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -41,15 +41,19 @@ Minimap::Minimap():
mProportion(0.5)
{
setWindowName(_("MiniMap"));
- mShow = config.getValue(getWindowName() + "Visible", true);
+ mShow = config.getValue(getWindowName() + "Show", true);
setDefaultSize(5, 25, 100, 100);
setResizable(true);
+
+ loadWindowState();
}
Minimap::~Minimap()
{
if (mMapImage)
mMapImage->decRef();
+
+ config.setValue(getWindowName() + "Show", mShow);
}
void Minimap::setMapImage(Image *img)
@@ -71,23 +75,26 @@ void Minimap::setMapImage(Image *img)
setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
setMinHeight(mapHeight);
- setMaxWidth(mMapImage->getWidth() + offsetX);
+ setMaxWidth(mMapImage->getWidth() > titleWidth ?
+ mMapImage->getWidth() + offsetX : titleWidth);
setMaxHeight(mMapImage->getHeight() + offsetY);
- mMapImage->setAlpha(config.getValue("guialpha", 0.8));
-
- // Set content size to be within the minimum and maximum boundaries
- setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth());
- if (getMaxWidth() > getWidth())
+ // Make sure the window is within the minimum and maximum boundaries
+ // TODO: Shouldn't this be happening automatically within the Window
+ // class?
+ if (getMinWidth() > getWidth())
+ setWidth(getMinWidth());
+ else if (getMaxWidth() < getWidth())
setWidth(getMaxWidth());
- setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight());
- if (getMaxHeight() > getHeight())
+ if (getMinHeight() > getHeight())
+ setHeight(getMinHeight());
+ else if (getMaxHeight() < getHeight())
setHeight(getMaxHeight());
+ setContentSize(getWidth() - offsetX, getHeight() - offsetY);
setDefaultSize(getX(), getY(), getWidth(), getHeight());
resetToDefaultSize();
- loadWindowState();
setVisible(mShow);
}
else
@@ -99,7 +106,6 @@ void Minimap::setMapImage(Image *img)
void Minimap::toggle()
{
mShow = !mShow;
- config.setValue(getWindowName() + "Visible", mShow);
}
void Minimap::draw(gcn::Graphics *graphics)
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index b4574ad5..3ce0aacd 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -24,8 +24,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class Image;
/**
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 39813883..7058d572 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -23,6 +23,7 @@
#include "ministatus.h"
#include "progressbar.h"
+#include "../animatedsprite.h"
#include "../configuration.h"
#include "../graphics.h"
#include "../localplayer.h"
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index c6a36a98..f262a2a0 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -22,14 +22,11 @@
#ifndef MINISTATUS_H
#define MINISTATUS_H
-#include <iosfwd>
-#include <vector>
-
#include "window.h"
-#include "../guichanfwd.h"
-#include "../animatedsprite.h"
+#include <vector>
+class AnimatedSprite;
class ProgressBar;
/**
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index a2e043d1..b4313b70 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -19,12 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-
-#include "npc_text.h"
-#include "browserbox.h"
#include "button.h"
+#include "npc_text.h"
#include "scrollarea.h"
+#include "textbox.h"
#include "widgets/layout.h"
@@ -42,10 +40,11 @@ NpcTextDialog::NpcTextDialog():
setDefaultSize(0, 0, 260, 200);
- mBrowserBox = new BrowserBox(BrowserBox::AUTO_WRAP);
- mBrowserBox->setOpaque(false);
+ mTextBox = new TextBox;
+ mTextBox->setEditable(false);
+ mTextBox->setOpaque(false);
- scrollArea = new ScrollArea(mBrowserBox);
+ scrollArea = new ScrollArea(mTextBox);
okButton = new Button(_("OK"), "ok", this);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -61,30 +60,33 @@ NpcTextDialog::NpcTextDialog():
setLocationRelativeTo(getParent());
}
-void NpcTextDialog::clearText()
-{
- mBrowserBox->clearRows();
-}
-
void NpcTextDialog::setText(const std::string &text)
{
- mBrowserBox->clearRows();
- mBrowserBox->addRow(text);
+ mText = text;
+ mTextBox->setTextWrapped(mText, scrollArea->getWidth() - 15);
}
void NpcTextDialog::addText(const std::string &text)
{
- mBrowserBox->addRow(text);
+ setText(mText + text + "\n");
}
void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- clearText();
+ setText("");
setVisible(false);
if (current_npc)
current_npc->nextDialog();
current_npc = 0;
}
}
+
+void NpcTextDialog::widgetResized(const gcn::Event &event)
+{
+ Window::widgetResized(event);
+
+ setText(mText);
+}
+
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h
index b4b6f1af..a07aa04f 100644
--- a/src/gui/npc_text.h
+++ b/src/gui/npc_text.h
@@ -22,14 +22,13 @@
#ifndef NPC_TEXT_H
#define NPC_TEXT_H
-#include <iosfwd>
+#include <string>
#include <guichan/actionlistener.hpp>
-#include "scrollarea.h"
#include "window.h"
-class BrowserBox;
+class TextBox;
/**
* The npc text dialog.
@@ -71,10 +70,19 @@ class NpcTextDialog : public Window, public gcn::ActionListener
*/
void addText(const std::string &string);
+ /**
+ * Called when resizing the window.
+ *
+ * @param event The calling event
+ */
+ void widgetResized(const gcn::Event &event);
+
private:
gcn::Button *okButton;
gcn::ScrollArea *scrollArea;
- BrowserBox *mBrowserBox;
+ TextBox *mTextBox;
+
+ std::string mText;
};
#endif // NPC_TEXT_H
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 65a1a7f1..c58fc460 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -19,27 +19,23 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "npcintegerdialog.h"
-
-#include <limits>
-#include <sstream>
-
#include "button.h"
#include "inttextfield.h"
+#include "npcintegerdialog.h"
+
+#include "widgets/layout.h"
#include "../npc.h"
#include "../utils/gettext.h"
-#include "../utils/tostring.h"
-
-#include "widgets/layout.h"
NpcIntegerDialog::NpcIntegerDialog():
Window(_("NPC Number Request"))
{
+ mValueField = new IntTextField();
+
mDecButton = new Button("-", "decvalue", this);
mIncButton = new Button("+", "incvalue", this);
- mValueField = new IntTextField();
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
resetButton = new Button(_("Reset"), "reset", this);
@@ -61,9 +57,6 @@ NpcIntegerDialog::NpcIntegerDialog():
reflowLayout(175, 0);
setLocationRelativeTo(getParent());
-
- mValueField->setActionEventId("valuefield");
- mValueField->addKeyListener(this);
}
void NpcIntegerDialog::setRange(const int min, const int max)
@@ -110,3 +103,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
mValueField->reset();
}
}
+
+bool NpcIntegerDialog::isInputFocused()
+{
+ return mValueField->isFocused();
+}
+
+void NpcIntegerDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h
index 983c46fe..10ec60b9 100644
--- a/src/gui/npcintegerdialog.h
+++ b/src/gui/npcintegerdialog.h
@@ -22,16 +22,10 @@
#ifndef GUI_NPCINTEGERDIALOG_H
#define GUI_NPCINTEGERDIALOG_H
-#include <iosfwd>
-#include <vector>
-
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class IntTextField;
/**
@@ -39,8 +33,7 @@ class IntTextField;
*
* \ingroup Interface
*/
-class NpcIntegerDialog : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class NpcIntegerDialog : public Window, public gcn::ActionListener
{
public:
/**
@@ -68,6 +61,16 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener,
*/
void setRange(const int min, const int max);
+ /**
+ * Checks whether NpcStringDialog is Focused or not.
+ */
+ bool isInputFocused();
+
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::Button *mDecButton;
gcn::Button *mIncButton;
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index bb815680..7d8a362a 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -21,8 +21,10 @@
#include <sstream>
+#include "button.h"
#include "listbox.h"
#include "npclistdialog.h"
+#include "scrollarea.h"
#include "widgets/layout.h"
@@ -41,6 +43,7 @@ NpcListDialog::NpcListDialog():
setDefaultSize(0, 0, 260, 200);
mItemList = new ListBox(this);
+ mItemList->setWrappingEnabled(true);
scrollArea = new ScrollArea(mItemList);
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h
index ffeced3d..30167a5e 100644
--- a/src/gui/npclistdialog.h
+++ b/src/gui/npclistdialog.h
@@ -22,18 +22,13 @@
#ifndef GUI_NPCLISTDIALOG_H
#define GUI_NPCLISTDIALOG_H
-#include <iosfwd>
#include <vector>
#include <guichan/actionlistener.hpp>
#include <guichan/listmodel.hpp>
-#include "button.h"
-#include "scrollarea.h"
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The npc list dialog.
*
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index ccb3c411..718c416f 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -19,18 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "npcstringdialog.h"
-
-#include <limits>
-#include <sstream>
-
#include "button.h"
+#include "npcstringdialog.h"
#include "textfield.h"
#include "../npc.h"
#include "../utils/gettext.h"
-#include "../utils/tostring.h"
#include "widgets/layout.h"
@@ -38,6 +33,7 @@ NpcStringDialog::NpcStringDialog():
Window(_("NPC Text Request"))
{
mValueField = new TextField("");
+
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
@@ -76,3 +72,8 @@ bool NpcStringDialog::isInputFocused()
{
return mValueField->isFocused();
}
+
+void NpcStringDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h
index 5aea2de0..1933e0f1 100644
--- a/src/gui/npcstringdialog.h
+++ b/src/gui/npcstringdialog.h
@@ -22,16 +22,10 @@
#ifndef GUI_NPCSTRINGDIALOG_H
#define GUI_NPCSTRINGDIALOG_H
-#include <iosfwd>
-#include <vector>
-
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The npc integer input dialog.
*
@@ -69,6 +63,11 @@ class NpcStringDialog : public Window, public gcn::ActionListener
*/
bool isInputFocused();
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::TextField *mValueField;
gcn::Button *okButton;
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 018fa489..2c67e71f 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -19,10 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ok_dialog.h"
-
#include <guichan/font.hpp>
+#include "button.h"
+#include "ok_dialog.h"
+#include "scrollarea.h"
+#include "textbox.h"
+
#include "../utils/gettext.h"
OkDialog::OkDialog(const std::string &title, const std::string &msg,
@@ -40,8 +43,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setOpaque(false);
- mTextBox->setMinWidth(260);
- mTextBox->setTextWrapped(msg);
+ mTextBox->setTextWrapped(msg, 260);
int numRows = mTextBox->getNumberOfRows();
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index 78b3d44f..3a438513 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -24,12 +24,10 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../guichanfwd.h"
+class ScrollArea;
+class TextBox;
/**
* An 'Ok' button dialog.
diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp
index 09b6abda..345ee1c3 100644
--- a/src/gui/passwordfield.cpp
+++ b/src/gui/passwordfield.cpp
@@ -21,8 +21,6 @@
#include "passwordfield.h"
-#include <string>
-
PasswordField::PasswordField(const std::string& text):
TextField(text)
{
diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h
index bc50e267..42f8d187 100644
--- a/src/gui/passwordfield.h
+++ b/src/gui/passwordfield.h
@@ -22,9 +22,9 @@
#ifndef PASSWORDFIELD_H
#define PASSWORDFIELD_H
-#include "textfield.h"
+#include <string>
-#include "../guichanfwd.h"
+#include "textfield.h"
/**
* A password field.
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index c22d407c..60003fb5 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "playerbox.h"
#include "../animatedsprite.h"
@@ -34,6 +32,7 @@
#include "../utils/dtor.h"
int PlayerBox::instances = 0;
+float PlayerBox::mAlpha = config.getValue("guialpha", 0.8);
ImageRect PlayerBox::background;
PlayerBox::PlayerBox(const Player *player):
@@ -94,6 +93,14 @@ void PlayerBox::draw(gcn::Graphics *graphics)
}
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ for (int a = 0; a < 9; a++)
+ {
+ background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ }
+ }
}
void PlayerBox::drawFrame(gcn::Graphics *graphics)
diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h
index 5aacd26f..7c08defd 100644
--- a/src/gui/playerbox.h
+++ b/src/gui/playerbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/scrollarea.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
class Player;
@@ -68,6 +66,7 @@ class PlayerBox : public gcn::ScrollArea
private:
const Player *mPlayer; /**< The character used for display */
+ static float mAlpha;
static int instances;
static ImageRect background;
};
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 8cb22c55..be5252f7 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -20,9 +20,6 @@
*/
#include <cassert>
-#include <iostream>
-
-#include <guichan/focushandler.hpp>
#include "browserbox.h"
#include "chat.h"
@@ -43,7 +40,6 @@
#include "../net/protocol.h"
#include "../resources/itemdb.h"
-#include "../resources/iteminfo.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
@@ -80,27 +76,27 @@ void PopupMenu::showPopup(int x, int y, Being *being)
// 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();
- mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@");
- mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name)) {
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str()));
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@");
- mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str()));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
- mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str()));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
break;
}
@@ -108,8 +104,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
//mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(_("@@party-invite|Invite ") + name +
- " to party@@");
+ mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str()));
}
break;
@@ -254,7 +249,7 @@ void PopupMenu::handleLink(const std::string& link)
else if (link == "chat")
{
- chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName());
+ chatWindow->addItemText(mItem->getInfo().getName());
}
else if (link == "drop")
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index ecc0017d..867477e0 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -19,18 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/font.hpp>
+
#include "gui.h"
#include "progressbar.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
-#include <guichan/font.hpp>
-
ImageRect ProgressBar::mBorder;
int ProgressBar::mInstances = 0;
+float ProgressBar::mAlpha = config.getValue("guialpha", 0.8);
ProgressBar::ProgressBar(float progress,
unsigned int width, unsigned int height,
@@ -56,6 +58,12 @@ ProgressBar::ProgressBar(float progress,
mBorder.grid[6] = dBorders->getSubImage(0, 15, 4, 4);
mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4);
+
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+
dBorders->decRef();
}
@@ -93,12 +101,27 @@ void ProgressBar::logic()
void ProgressBar::draw(gcn::Graphics *graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ if (config.getValue("opengl", 0))
+ mAlpha = config.getValue("guialpha", 0.8);
+ else
+ mAlpha = 1.0f;
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+ }
+
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
+ const int alpha = mAlpha * 255;
+
// The bar
if (mProgress > 0) {
- graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200));
+
+ graphics->setColor(gcn::Color(mRed, mGreen, mBlue, alpha));
graphics->fillRectangle(gcn::Rectangle(4, 4,
(int) (mProgress * (getWidth() - 8)),
getHeight() - 8));
@@ -112,14 +135,16 @@ void ProgressBar::draw(gcn::Graphics *graphics)
graphics->setFont(f);
- graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->setColor(gcn::Color(0, 0, 0, alpha));
graphics->drawText(mText, textX + 1, textY, gcn::Graphics::CENTER);
graphics->drawText(mText, textX, textY - 1, gcn::Graphics::CENTER);
graphics->drawText(mText, textX, textY + 1, gcn::Graphics::CENTER);
graphics->drawText(mText, textX - 1, textY, gcn::Graphics::CENTER);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(gcn::Color(255, 255, 255, alpha));
graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER);
+
+ graphics->setColor(gcn::Color(0, 0, 0));
}
}
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index ee0a5f81..2c1b22da 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -22,12 +22,11 @@
#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
+#include <string>
+
#include <guichan/widget.hpp>
#include <SDL_types.h>
-#include <string>
-
-#include "../guichanfwd.h"
class ImageRect;
@@ -111,6 +110,7 @@ class ProgressBar : public gcn::Widget
static ImageRect mBorder;
static int mInstances;
+ static float mAlpha;
};
#endif
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index 245112a7..de8d4d9d 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -21,12 +21,14 @@
#include "radiobutton.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
int RadioButton::instances = 0;
+float RadioButton::mAlpha = config.getValue("guialpha", 0.8);
Image *RadioButton::radioNormal;
Image *RadioButton::radioChecked;
Image *RadioButton::radioDisabled;
@@ -43,6 +45,10 @@ RadioButton::RadioButton(const std::string& caption, const std::string& group,
radioChecked = resman->getImage("graphics/gui/radioin.png");
radioDisabled = resman->getImage("graphics/gui/radioout.png");
radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
+ radioNormal->setAlpha(mAlpha);
+ radioChecked->setAlpha(mAlpha);
+ radioDisabled->setAlpha(mAlpha);
+ radioDisabledChecked->setAlpha(mAlpha);
}
instances++;
@@ -63,32 +69,37 @@ RadioButton::~RadioButton()
void RadioButton::drawBox(gcn::Graphics* graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ radioNormal->setAlpha(mAlpha);
+ radioChecked->setAlpha(mAlpha);
+ radioDisabled->setAlpha(mAlpha);
+ radioDisabledChecked->setAlpha(mAlpha);
+ }
+
Image *box = NULL;
- if (isSelected()) {
- if (isEnabled()) {
+ if (isSelected())
+ {
+ if (isEnabled())
box = radioChecked;
- } else {
+ else
box = radioDisabledChecked;
- }
- } else if (isEnabled()) {
+ }
+ else if (isEnabled())
box = radioNormal;
- } else {
+ else
box = radioDisabled;
- }
- if (box != NULL) {
+ if (box != NULL)
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
- }
}
void RadioButton::draw(gcn::Graphics* graphics)
{
-
- graphics->pushClipArea(gcn::Rectangle(1,
- 1,
- getWidth() - 1,
- getHeight() - 1));
+ graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1,
+ getHeight() - 1));
drawBox(graphics);
diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h
index dcd62802..3d952b3f 100644
--- a/src/gui/radiobutton.h
+++ b/src/gui/radiobutton.h
@@ -24,14 +24,13 @@
#include <guichan/widgets/radiobutton.hpp>
-#include "../guichanfwd.h"
-
class Image;
/*
* Guichan based RadioButton with custom look
*/
-class RadioButton : public gcn::RadioButton {
+class RadioButton : public gcn::RadioButton
+{
public:
/*
* Constructor.
@@ -57,6 +56,7 @@ class RadioButton : public gcn::RadioButton {
private:
static int instances;
+ static float mAlpha;
static Image *radioNormal;
static Image *radioChecked;
static Image *radioDisabled;
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
new file mode 100644
index 00000000..1e7d8e13
--- /dev/null
+++ b/src/gui/recorder.cpp
@@ -0,0 +1,115 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <physfs.h>
+
+#include "button.h"
+#include "chat.h"
+#include "recorder.h"
+#include "windowcontainer.h"
+
+#include "widgets/layout.h"
+
+#include "../utils/trim.h"
+
+Recorder::Recorder(ChatWindow *chat, const std::string &title,
+ const std::string &buttonTxt) :
+ Window(title)
+{
+ setWindowName(_("Recorder"));
+ const int offsetX = 2 * getPadding() + 10;
+ const int offsetY = getTitleBarHeight() + getPadding() + 10;
+
+ mChat = chat;
+ Button *button = new Button(buttonTxt, "activate", this);
+ setDefaultSize(0, windowContainer->getHeight() - 123 - button->getHeight() -
+ offsetY, button->getWidth() + offsetX, button->getHeight() +
+ offsetY);
+
+ place(0, 0, button);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+
+ loadWindowState();
+}
+
+void Recorder::record(const std::string &msg)
+{
+ if (mStream.is_open())
+ {
+ mStream << msg << std::endl;
+ }
+}
+
+void Recorder::changeRecordingStatus(const std::string &msg)
+{
+ std::string msgCopy = msg;
+ trim(msgCopy);
+
+ if (msgCopy == "")
+ {
+ if (mStream.is_open())
+ {
+ mStream.close();
+ setVisible(false);
+
+ /*
+ * Message should go after mStream is closed so that it isn't
+ * recorded.
+ */
+ mChat->chatLog(_("Finishing recording."), BY_SERVER);
+ }
+ else
+ {
+ mChat->chatLog(_("Not currently recording."), BY_SERVER);
+ }
+ }
+ else if (mStream.is_open())
+ {
+ mChat->chatLog(_("Already recording."), BY_SERVER);
+ }
+ else
+ {
+ /*
+ * Message should go before mStream is opened so that it isn't
+ * recorded.
+ */
+ mChat->chatLog(_("Starting to record..."), BY_SERVER);
+ std::string file = std::string(PHYSFS_getUserDir()) + "/.aethyra/" + msgCopy;
+
+ mStream.open(file.c_str(), std::ios_base::trunc);
+
+ if (mStream.is_open())
+ setVisible(true);
+ else
+ mChat->chatLog(_("Failed to start recording."), BY_SERVER);
+ }
+}
+
+void Recorder::action(const gcn::ActionEvent &event)
+{
+ changeRecordingStatus("");
+}
+
+Recorder::~Recorder()
+{
+}
diff --git a/src/gui/recorder.h b/src/gui/recorder.h
new file mode 100644
index 00000000..0bbab012
--- /dev/null
+++ b/src/gui/recorder.h
@@ -0,0 +1,76 @@
+/*
+ * A chat recorder
+ * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef RECORD_H
+#define RECORD_H
+
+#include <fstream>
+#include <string>
+
+#include <guichan/actionlistener.hpp>
+
+#include "window.h"
+
+#include "../utils/gettext.h"
+
+class ChatWindow;
+
+class Recorder : public Window, public gcn::ActionListener
+{
+ public:
+ Recorder(ChatWindow *chat, const std::string &title = _("Recording..."),
+ const std::string &buttonTxt = _("Stop recording"));
+
+ virtual ~Recorder();
+
+ /*
+ * Outputs the message to the recorder file
+ *
+ * @param msg the line to write to the recorded file.
+ */
+ void record(const std::string &msg);
+
+ /*
+ * Outputs the message to the recorder file
+ *
+ * @param msg The file to write out to. If null, then stop recording.
+ */
+ void changeRecordingStatus(const std::string &msg);
+
+ /*
+ * Whether or not the recorder is in use.
+ */
+ bool isRecording() {return (bool) mStream.is_open();}
+
+ /*
+ * called when the button is pressed
+ *
+ * @param event is the event that is generated
+ */
+ void action(const gcn::ActionEvent &event);
+
+ private:
+ ChatWindow *mChat;
+
+ std::ofstream mStream;
+};
+
+#endif
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index bf45b711..cf12375c 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -19,15 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-#include <sstream>
-
#include <guichan/widgets/label.hpp>
-#include "../main.h"
#include "../configuration.h"
#include "../log.h"
#include "../logindata.h"
+#include "../main.h"
#include "button.h"
#include "checkbox.h"
@@ -38,12 +35,11 @@
#include "register.h"
#include "textfield.h"
-#include "../utils/tostring.h"
-
#include "widgets/layout.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/tostring.h"
/**
* Listener used while dealing with wrong data. It is used to direct the focus
diff --git a/src/gui/register.h b/src/gui/register.h
index 8ba377fa..9588e07e 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -22,15 +22,13 @@
#ifndef REGISTER_H
#define REGISTER_H
-#include <iosfwd>
+#include <string>
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class LoginData;
class OkDialog;
class WrongDataNoticeListener;
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 3ee27064..eacc4714 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "scrollarea.h"
#include "../configuration.h"
@@ -32,19 +30,22 @@
#include "../utils/dtor.h"
int ScrollArea::instances = 0;
+float ScrollArea::mAlpha = config.getValue("guialpha", 0.8);
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
Image *ScrollArea::buttons[4][2];
-ScrollArea::ScrollArea(bool gc):
+ScrollArea::ScrollArea(bool gc, bool opaque):
gcn::ScrollArea(),
+ mOpaque(opaque),
mGC(gc)
{
init();
}
-ScrollArea::ScrollArea(gcn::Widget *widget, bool gc):
+ScrollArea::ScrollArea(gcn::Widget *widget, bool gc, bool opaque):
gcn::ScrollArea(widget),
+ mOpaque(opaque),
mGC(gc)
{
init();
@@ -53,9 +54,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget, bool gc):
ScrollArea::~ScrollArea()
{
// Garbage collection
- if (mGC) {
+ if (mGC)
delete getContent();
- }
instances--;
@@ -89,8 +89,10 @@ void ScrollArea::init()
const int bggridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
+ for (y = 0; y < 3; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
background.grid[a] = textbox->getSubImage(
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
@@ -193,6 +195,16 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mScrollbarWidth));
}
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ background.grid[a]->setAlpha(mAlpha);
+ vMarker.grid[a]->setAlpha(mAlpha);
+ }
+ }
+
drawChildren(graphics);
}
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
index 4fababfa..33ebc692 100644
--- a/src/gui/scrollarea.h
+++ b/src/gui/scrollarea.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/scrollarea.hpp>
-#include "../guichanfwd.h"
-
class Image;
class ImageRect;
@@ -40,12 +38,12 @@ class ScrollArea : public gcn::ScrollArea
/**
* Constructor.
*/
- ScrollArea(bool gc = true);
+ ScrollArea(bool gc = true, bool opaque = true);
/**
* Constructor.
*/
- ScrollArea(gcn::Widget *content, bool gc = true);
+ ScrollArea(gcn::Widget *content, bool gc = true, bool opaque = true);
/**
* Destructor.
@@ -102,6 +100,7 @@ class ScrollArea : public gcn::ScrollArea
void drawHMarker(gcn::Graphics *graphics);
static int instances;
+ static float mAlpha;
static ImageRect background;
static ImageRect vMarker;
static Image *buttons[4][2];
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 7976e32e..e4be7921 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -19,30 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "shoplistbox.h"
#include "scrollarea.h"
#include "sell.h"
#include "shop.h"
+#include "shoplistbox.h"
#include "slider.h"
#include "widgets/layout.h"
-#include "../item.h"
#include "../npc.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../resources/iteminfo.h"
-
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-#include "../utils/tostring.h"
SellDialog::SellDialog(Network *network):
Window(_("Sell")),
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 8e639a3d..c11a7b7c 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -25,9 +25,9 @@
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
-#include "window.h"
+#include <SDL_types.h>
-#include "../guichanfwd.h"
+#include "window.h"
class Item;
class Network;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index d18f365c..19575cfb 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-#include <iostream>
-
#include "button.h"
#include "setup.h"
#include "setup_audio.h"
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 7090136e..5c189882 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -109,8 +109,8 @@ void Setup_Audio::cancel()
sound.setMusicVolume(mMusicVolume);
mMusicSlider->setValue(mMusicVolume);
- config.setValue("sound", mSoundEnabled ? 1 : 0);
- config.setValue("sfxVolume", mSfxVolume ? 1 : 0);
+ config.setValue("sound", mSoundEnabled ? true : false);
+ config.setValue("sfxVolume", mSfxVolume);
config.setValue("musicVolume", mMusicVolume);
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 2f5cd736..9e951895 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -26,8 +26,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Audio : public SetupTab, public gcn::ActionListener
{
public:
diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp
index 112925ae..49e08aeb 100644
--- a/src/gui/setup_colours.cpp
+++ b/src/gui/setup_colours.cpp
@@ -19,13 +19,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <vector>
+#include <string>
#include <guichan/listmodel.hpp>
#include <guichan/widgets/label.hpp>
#include <guichan/widgets/slider.hpp>
+#include "browserbox.h"
#include "colour.h"
+#include "itemlinkhandler.h"
+#include "listbox.h"
#include "scrollarea.h"
#include "setup_colours.h"
#include "slider.h"
@@ -36,19 +39,31 @@
#include "../configuration.h"
#include "../utils/gettext.h"
+#include "../utils/tostring.h"
Setup_Colours::Setup_Colours() :
mSelected(-1)
{
setOpaque(false);
- mColourBox = new gcn::ListBox(textColour);
+ mColourBox = new ListBox(textColour);
mColourBox->setActionEventId("colour_box");
mColourBox->addActionListener(this);
mScroll = new ScrollArea(mColourBox);
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScroll->setWidth(90);
+
+ mPreview = new BrowserBox(BrowserBox::AUTO_WRAP);
+ mPreview->setOpaque(false);
+
+ // Replace this later with a more appropriate link handler. For now, this'll
+ // do, as it'll do nothing when clicked on.
+ mPreview->setLinkHandler(new ItemLinkHandler());
+
+ mPreviewBox = new ScrollArea(mPreview);
+ mPreviewBox->setHeight(20);
+ mPreviewBox->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
+ gcn::ScrollArea::SHOW_NEVER);
mRedLabel = new gcn::Label(_("Red: "));
@@ -59,7 +74,7 @@ Setup_Colours::Setup_Colours() :
mRedText->addListener(this);
mRedSlider = new Slider(0, 255);
- mRedSlider->setWidth(90);
+ mRedSlider->setWidth(160);
mRedSlider->setValue(mRedText->getValue());
mRedSlider->setActionEventId("slider_red");
mRedSlider->addActionListener(this);
@@ -73,7 +88,7 @@ Setup_Colours::Setup_Colours() :
mGreenText->addListener(this);
mGreenSlider = new Slider(0, 255);
- mGreenSlider->setWidth(90);
+ mGreenSlider->setWidth(160);
mGreenSlider->setValue(mGreenText->getValue());
mGreenSlider->setActionEventId("slider_green");
mGreenSlider->addActionListener(this);
@@ -87,7 +102,7 @@ Setup_Colours::Setup_Colours() :
mBlueText->addListener(this);
mBlueSlider = new Slider(0, 255);
- mBlueSlider->setWidth(90);
+ mBlueSlider->setWidth(160);
mBlueSlider->setValue(mBlueText->getValue());
mBlueSlider->setActionEventId("slider_blue");
mBlueSlider->addActionListener(this);
@@ -98,18 +113,19 @@ Setup_Colours::Setup_Colours() :
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 1, 3).setPadding(2);
- place(1, 0, mRedLabel, 2);
- place(3, 0, mRedSlider);
- place(4, 0, mRedText).setPadding(1);
- place(1, 1, mGreenLabel, 2);
- place(3, 1, mGreenSlider);
- place(4, 1, mGreenText).setPadding(1);
- place(1, 2, mBlueLabel, 2);
- place(3, 2, mBlueSlider);
- place(4, 2, mBlueText).setPadding(1);
-
- setDimension(gcn::Rectangle(0, 0, 290, 150));
+ place(0, 0, mScroll, 4, 7).setPadding(2);
+ place(0, 7, mPreviewBox, 4).setPadding(2);
+ place(0, 8, mRedLabel, 2);
+ place(2, 8, mRedSlider);
+ place(3, 8, mRedText).setPadding(1);
+ place(0, 9, mGreenLabel, 2);
+ place(2, 9, mGreenSlider);
+ place(3, 9, mGreenText).setPadding(1);
+ place(0, 10, mBlueLabel, 2);
+ place(2, 10, mBlueSlider);
+ place(3, 10, mBlueText).setPadding(1);
+
+ setDimension(gcn::Rectangle(0, 0, 290, 250));
}
Setup_Colours::~Setup_Colours()
@@ -135,6 +151,18 @@ void Setup_Colours::action(const gcn::ActionEvent &event)
{
mSelected = mColourBox->getSelected();
int col = textColour->getColourAt(mSelected);
+ char ch = textColour->getColourCharAt(mSelected);
+ std::string msg;
+
+ if (ch == '<')
+ msg = toString("@@|") +
+ _("This is what the color looks like") + "@@";
+ else
+ msg = "##" + toString(ch) +
+ _("This is what the color looks like");
+
+ mPreview->clearRows();
+ mPreview->addRow(msg);
setEntry(mRedSlider, mRedText, col >> 16);
setEntry(mGreenSlider, mGreenText, (col >> 8) & 0xff);
setEntry(mBlueSlider, mBlueText, col & 0xff);
@@ -169,7 +197,7 @@ void Setup_Colours::action(const gcn::ActionEvent &event)
}
}
-void Setup_Colours::setEntry(Slider *s, TextField *t, int value)
+void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value)
{
s->setValue(value);
char buffer[100];
diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h
index 79afe122..57d9e304 100644
--- a/src/gui/setup_colours.h
+++ b/src/gui/setup_colours.h
@@ -23,19 +23,19 @@
#define SETUP_COLOURS_H
#include <string>
-#include <vector>
#include <guichan/actionlistener.hpp>
+
#include <guichan/widgets/label.hpp>
#include <guichan/widgets/listbox.hpp>
-#include "scrollarea.h"
#include "setuptab.h"
-#include "slider.h"
#include "textfield.h"
#include "../guichanfwd.h"
+class BrowserBox;
+
class Setup_Colours : public SetupTab, public gcn::ActionListener,
public TextFieldListener
{
@@ -49,25 +49,27 @@ class Setup_Colours : public SetupTab, public gcn::ActionListener,
void listen(const TextField *tf);
private:
gcn::ListBox *mColourBox;
- ScrollArea *mScroll;
+ gcn::ScrollArea *mScroll;
+ BrowserBox *mPreview;
+ gcn::ScrollArea *mPreviewBox;
int mSelected;
gcn::Label *mRedLabel;
- Slider *mRedSlider;
+ gcn::Slider *mRedSlider;
TextField *mRedText;
int mRedValue;
gcn::Label *mGreenLabel;
- Slider *mGreenSlider;
+ gcn::Slider *mGreenSlider;
TextField *mGreenText;
int mGreenValue;
gcn::Label *mBlueLabel;
- Slider *mBlueSlider;
+ gcn::Slider *mBlueSlider;
TextField *mBlueText;
int mBlueValue;
- void setEntry(Slider *s, TextField *t, int value);
+ void setEntry(gcn::Slider *s, TextField *t, int value);
void updateColour();
};
#endif
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 2c726b87..2ebcdbde 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -41,7 +41,7 @@ Setup_Joystick::Setup_Joystick():
{
setOpaque(false);
- mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0;
+ mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->addActionListener(this);
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index 2dc56439..eba8a2cc 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -26,8 +26,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Joystick : public SetupTab, public gcn::ActionListener
{
public:
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index e38b9b8c..5d7519ef 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -33,9 +33,6 @@
#include "widgets/layouthelper.h"
-#include "widgets/layouthelper.h"
-
-#include "../configuration.h"
#include "../keyboardconfig.h"
#include "../utils/gettext.h"
@@ -81,11 +78,10 @@ Setup_Keyboard::Setup_Keyboard():
refreshKeys();
- mKeyList->setDimension(gcn::Rectangle(0, 0, 185, 140));
mKeyList->addActionListener(this);
- mKeyList->setSelected(-1);
ScrollArea *scrollArea = new ScrollArea(mKeyList);
+ scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mAssignKeyButton = new Button(_("Assign"), "assign", this);
mAssignKeyButton->addActionListener(this);
@@ -142,9 +138,8 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
if (event.getSource() == mKeyList)
{
- if (!mKeySetting) {
+ if (!mKeySetting)
mAssignKeyButton->setEnabled(true);
- }
}
else if (event.getId() == "assign")
{
@@ -188,7 +183,8 @@ void Setup_Keyboard::refreshKeys()
void Setup_Keyboard::keyUnresolved()
{
- if (mKeySetting) {
+ if (mKeySetting)
+ {
newKeyCallback(keyboard.getNewKeyIndex());
keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE);
}
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index 6aa2bfa2..dee12135 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -26,7 +26,6 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
#include "setuptab.h"
#include "../guichanfwd.h"
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 9a7fb441..5c19bd2b 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -19,22 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <string>
#include <vector>
-#include <guichan/widgets/dropdown.hpp>
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "checkbox.h"
+#include "listbox.h"
#include "ok_dialog.h"
+#include "scrollarea.h"
#include "setup_players.h"
+#include "table.h"
+#include "widgets/dropdown.h"
#include "widgets/layouthelper.h"
#include "../configuration.h"
#include "../log.h"
-#include "../player_relations.h"
-#include "../sound.h"
#include "../utils/gettext.h"
@@ -135,8 +137,12 @@ public:
std::string name = (*player_names)[r];
gcn::Widget *widget = new gcn::Label(name);
mWidgets.push_back(widget);
+ gcn::ListModel *playerRelation = new PlayerRelationListModel();
- gcn::DropDown *choicebox = new gcn::DropDown(new PlayerRelationListModel());
+ gcn::DropDown *choicebox = new DropDown(playerRelation,
+ new ScrollArea(),
+ new ListBox(playerRelation),
+ false);
choicebox->setSelected(player_relations.getRelation(name));
mWidgets.push_back(choicebox);
}
@@ -219,19 +225,23 @@ Setup_Players::Setup_Players():
player_relations.getDefault() & PlayerRelation::TRADE)),
mDefaultWhisper(new CheckBox(_("Allow whispers"),
player_relations.getDefault() & PlayerRelation::WHISPER)),
- mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
- mIgnoreActionChoicesBox(new gcn::DropDown(new IgnoreChoicesListModel()))
+ mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this))
{
setOpaque(false);
+ mPlayerTable->setOpaque(false);
int table_width = NAME_COLUMN_WIDTH + RELATION_CHOICE_COLUMN_WIDTH;
mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN,
RELATION_CHOICE_COLUMN_WIDTH);
- mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width, 10));
+ mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width - 1, 10));
mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf));
- for (int i = 0; i < COLUMNS_NR; i++)
+ gcn::ListModel *ignoreChoices = new IgnoreChoicesListModel();
+ mIgnoreActionChoicesBox = new DropDown(ignoreChoices, new ScrollArea(),
+ new ListBox(ignoreChoices), false);
+
+ for (int i = 0; i < COLUMNS_NR; i++)
{
mPlayerTableTitleModel->set(0, i,
new gcn::Label(gettext(table_titles[i])));
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 22c8a9b6..2edc6983 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -24,17 +24,16 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
#include "setuptab.h"
-#include "table.h"
-#include "../guichanfwd.h"
#include "../player_relations.h"
+class GuiTable;
class PlayerTableModel;
+class StaticTableModel;
-class Setup_Players : public SetupTab, public gcn::ActionListener, public PlayerRelationsListener
+class Setup_Players : public SetupTab,
+ public gcn::ActionListener, public PlayerRelationsListener
{
public:
Setup_Players();
@@ -54,13 +53,13 @@ private:
PlayerTableModel *mPlayerTableModel;
GuiTable *mPlayerTable;
GuiTable *mPlayerTitleTable;
- ScrollArea *mPlayerScrollArea;
+ gcn::ScrollArea *mPlayerScrollArea;
gcn::CheckBox *mPersistIgnores;
gcn::CheckBox *mDefaultTrading;
gcn::CheckBox *mDefaultWhisper;
- Button *mDeleteButton;
+ gcn::Button *mDeleteButton;
gcn::DropDown *mIgnoreActionChoicesBox;
};
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 2381ab41..b1d33b09 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -104,12 +104,12 @@ ModeListModel::ModeListModel()
}
Setup_Video::Setup_Video():
- mFullScreenEnabled(config.getValue("screen", 0)),
- mOpenGLEnabled(config.getValue("opengl", 0)),
- mCustomCursorEnabled(config.getValue("customcursor", 1)),
- mParticleEffectsEnabled(config.getValue("particleeffects", 1)),
- mSpeechBubbleEnabled(config.getValue("speechbubble", 1)),
- mNameEnabled(config.getValue("showownname", 0)),
+ mFullScreenEnabled(config.getValue("screen", false)),
+ mOpenGLEnabled(config.getValue("opengl", false)),
+ mCustomCursorEnabled(config.getValue("customcursor", true)),
+ mParticleEffectsEnabled(config.getValue("particleeffects", true)),
+ mSpeechBubbleEnabled(config.getValue("speechbubble", true)),
+ mNameEnabled(config.getValue("showownname", false)),
mOpacity(config.getValue("guialpha", 0.8)),
mFps((int) config.getValue("fpslimit", 0)),
mModeListModel(new ModeListModel),
@@ -280,7 +280,7 @@ void Setup_Video::apply()
{
// Full screen changes
bool fullscreen = mFsCheckBox->isSelected();
- if (fullscreen != (config.getValue("screen", 0) == 1))
+ if (fullscreen != (config.getValue("screen", false) == 1))
{
/* The OpenGL test is only necessary on Windows, since switching
* to/from full screen works fine on Linux. On Windows we'd have to
@@ -291,7 +291,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__)
// checks for opengl usage
- if (!(config.getValue("opengl", 0) == 1))
+ if (!(config.getValue("opengl", false) == 1))
{
#endif
if (!graphics->setFullscreen(fullscreen))
@@ -313,13 +313,13 @@ void Setup_Video::apply()
_("Restart needed for changes to take effect."));
}
#endif
- config.setValue("screen", fullscreen ? 1 : 0);
+ config.setValue("screen", fullscreen ? true : false);
}
// OpenGL change
if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled)
{
- config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0);
+ config.setValue("opengl", mOpenGLCheckBox->isSelected() ? true : false);
// OpenGL can currently only be changed by restarting, notify user.
new OkDialog(_("Changing OpenGL"),
@@ -330,14 +330,14 @@ void Setup_Video::apply()
config.setValue("fpslimit", mFps);
// We sync old and new values at apply time
- mFullScreenEnabled = config.getValue("screen", 0);
- mCustomCursorEnabled = config.getValue("customcursor", 1);
- mParticleEffectsEnabled = config.getValue("particleeffects", 1);
- mSpeechBubbleEnabled = config.getValue("speechbubble", 1);
- mNameEnabled = config.getValue("showownname", 0);
+ mFullScreenEnabled = config.getValue("screen", false);
+ mCustomCursorEnabled = config.getValue("customcursor", true);
+ mParticleEffectsEnabled = config.getValue("particleeffects", true);
+ mSpeechBubbleEnabled = config.getValue("speechbubble", true);
+ mNameEnabled = config.getValue("showownname", false);
mOpacity = config.getValue("guialpha", 0.8);
mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
- mOpenGLEnabled = config.getValue("opengl", 0);
+ mOpenGLEnabled = config.getValue("opengl", false);
}
int Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field,
@@ -377,13 +377,13 @@ void Setup_Video::cancel()
updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius");
updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness");
- config.setValue("screen", mFullScreenEnabled ? 1 : 0);
- config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
- config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0);
- config.setValue("speechbubble", mSpeechBubbleEnabled ? 1 : 0);
- config.setValue("showownname", mNameEnabled ? 1 : 0);
+ config.setValue("screen", mFullScreenEnabled ? true : false);
+ config.setValue("customcursor", mCustomCursorEnabled ? true : false);
+ config.setValue("particleeffects", mParticleEffectsEnabled ? true : false);
+ config.setValue("speechbubble", mSpeechBubbleEnabled ? true : false);
+ config.setValue("showownname", mNameEnabled ? true : false);
config.setValue("guialpha", mOpacity);
- config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
+ config.setValue("opengl", mOpenGLEnabled ? true : false);
}
void Setup_Video::action(const gcn::ActionEvent &event)
@@ -393,23 +393,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
const std::string mode = mModeListModel->getElementAt(mModeList->getSelected());
const int width = atoi(mode.substr(0, mode.find("x")).c_str());
const int height = atoi(mode.substr(mode.find("x") + 1).c_str());
- const int bpp = 0;
- const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
- const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
-
- // Try to set the desired video mode
- if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
- {
- std::cerr << _("Couldn't set ")
- << width << "x" << height << "x" << bpp << _(" video mode: ")
- << SDL_GetError() << std::endl;
- exit(1);
- }
-
- // Initialize for drawing
- graphics->_endDraw();
- graphics->_beginDraw();
- graphics->updateScreen();
// TODO: Find out why the drawing area doesn't resize without a restart.
new OkDialog(_("Screen resolution changed"),
@@ -425,19 +408,19 @@ void Setup_Video::action(const gcn::ActionEvent &event)
else if (event.getId() == "customcursor")
{
config.setValue("customcursor",
- mCustomCursorCheckBox->isSelected() ? 1 : 0);
+ mCustomCursorCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "particleeffects")
{
config.setValue("particleeffects",
- mParticleEffectsCheckBox->isSelected() ? 1 : 0);
+ mParticleEffectsCheckBox->isSelected() ? true : false);
new OkDialog(_("Particle effect settings changed"),
_("Restart your client or change maps for the change to take effect."));
}
else if (event.getId() == "speechbubble")
{
config.setValue("speechbubble",
- mSpeechBubbleCheckBox->isSelected() ? 1 : 0);
+ mSpeechBubbleCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "showownname")
{
@@ -446,7 +429,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (player_node)
player_node->mUpdateName = true;
config.setValue("showownname",
- mNameCheckBox->isSelected() ? 1 : 0);
+ mNameCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "fpslimitslider")
{
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index d863fb64..303b5bfc 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -27,8 +27,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Video : public SetupTab, public gcn::ActionListener,
public gcn::KeyListener
{
diff --git a/src/gui/shop.h b/src/gui/shop.h
index 22b649d0..e0db4c59 100644
--- a/src/gui/shop.h
+++ b/src/gui/shop.h
@@ -27,10 +27,9 @@
#include <guichan/listmodel.hpp>
-#include "../guichanfwd.h"
#include "../shopitem.h"
-#include "../resources/image.h"
+class ShopItem;
class ShopItems : public gcn::ListModel
{
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp
index 765b9f08..b5761535 100644
--- a/src/gui/shoplistbox.cpp
+++ b/src/gui/shoplistbox.cpp
@@ -19,19 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <guichan/basiccontainer.hpp>
#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/imagefont.hpp>
#include <guichan/listmodel.hpp>
-#include <guichan/mouseinput.hpp>
+#include "colour.h"
+#include "shop.h"
#include "shoplistbox.h"
+#include "../configuration.h"
#include "../graphics.h"
const int ITEM_ICON_SIZE = 32;
+float ShopListBox::mAlpha = config.getValue("guialpha", 0.8);
+
ShopListBox::ShopListBox(gcn::ListModel *listModel):
ListBox(listModel),
mPlayerMoney(0)
@@ -59,6 +60,15 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (!mListModel)
return;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ bool valid;
+ const int red = (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green = (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 255;
+
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
graphics->setFont(getFont());
@@ -68,16 +78,16 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
i < mListModel->getNumberOfElements();
++i, y += mRowHeight)
{
- gcn::Color backgroundColor = gcn::Color(0xffffff);
+ gcn::Color backgroundColor = gcn::Color(255, 255, 255, alpha);
if (i == mSelected)
{
- backgroundColor = gcn::Color(235, 200, 115);
+ backgroundColor = gcn::Color(red, green, blue, alpha);
}
else if (mShopItems &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
{
- backgroundColor = gcn::Color(0x919191);
+ backgroundColor = gcn::Color(145, 145, 145, alpha);
}
graphics->setColor(backgroundColor);
diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h
index 733af4eb..cde4786e 100644
--- a/src/gui/shoplistbox.h
+++ b/src/gui/shoplistbox.h
@@ -23,9 +23,8 @@
#define SHOPLISTBOX_H
#include "listbox.h"
-#include "shop.h"
-#include "../guichanfwd.h"
+class ShopItems;
/**
* A list box, meant to be used inside a scroll area. Same as the Guichan list
@@ -86,6 +85,8 @@ class ShopListBox : public ListBox
unsigned int mRowHeight; /**< Row Height */
+ static float mAlpha;
+
bool mPriceCheck;
};
diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp
index e7675c7d..4472818e 100644
--- a/src/gui/shortcutcontainer.cpp
+++ b/src/gui/shortcutcontainer.cpp
@@ -21,25 +21,20 @@
#include "shortcutcontainer.h"
-#include "../graphics.h"
-#include "../inventory.h"
-#include "../item.h"
-#include "../itemshortcut.h"
-#include "../keyboardconfig.h"
-#include "../localplayer.h"
+#include "../configuration.h"
#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
#include "../utils/tostring.h"
+float ShortcutContainer::mAlpha = config.getValue("guialpha", 0.8);
+
ShortcutContainer::ShortcutContainer():
mGridWidth(1),
mGridHeight(1)
{
}
-
void ShortcutContainer::widgetResized(const gcn::Event &event)
{
mGridWidth = getWidth() / mBoxWidth;
diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h
index 66aca6c3..f5f06163 100644
--- a/src/gui/shortcutcontainer.h
+++ b/src/gui/shortcutcontainer.h
@@ -26,12 +26,10 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
- * An item shortcut container. Used to quickly use items.
+ * A generic shortcut container.
*
* \ingroup GUI
*/
@@ -41,7 +39,7 @@ class ShortcutContainer : public gcn::Widget,
{
public:
/**
- * Constructor. Initializes the graphic.
+ * Constructor. Initializes the shortcut container.
*/
ShortcutContainer();
@@ -51,7 +49,7 @@ class ShortcutContainer : public gcn::Widget,
~ShortcutContainer(){}
/**
- * Draws the items.
+ * Draws the shortcuts
*/
virtual void draw(gcn::Graphics *graphics) = 0;
@@ -97,6 +95,8 @@ class ShortcutContainer : public gcn::Widget,
Image *mBackgroundImg;
+ static float mAlpha;
+
int mMaxItems;
int mBoxWidth;
int mBoxHeight;
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 799fc35b..5d49a3c6 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -19,14 +19,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "scrollarea.h"
#include "shortcutcontainer.h"
#include "shortcutwindow.h"
-#include "scrollarea.h"
#include "../configuration.h"
static const int SCROLL_PADDING = 0;
+int ShortcutWindow::mInstances = 0;
+
ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
{
setWindowName(title);
@@ -37,6 +39,8 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
mItems = content;
+ mInstances++;
+
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
setMinWidth(mItems->getBoxWidth() + border);
setMinHeight(mItems->getBoxHeight() + border);
@@ -46,10 +50,11 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
const int width = (int) config.getValue("screenwidth", 800);
const int height = (int) config.getValue("screenheight", 600);
- setDefaultSize(width - mItems->getBoxWidth() - border,
- height - (mItems->getBoxHeight() * mItems->getMaxItems()) -
- border, mItems->getBoxWidth() + border,
- (mItems->getBoxHeight() * mItems->getMaxItems()) + border);
+ setDefaultSize(width - (mInstances * mItems->getBoxWidth()) -
+ (mInstances * border), height - (mItems->getBoxHeight() *
+ mItems->getMaxItems()) - border, mItems->getBoxWidth() +
+ border, (mItems->getBoxHeight() * mItems->getMaxItems()) +
+ border);
mScrollArea = new ScrollArea(mItems);
mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index 0168669e..64592328 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -24,10 +24,8 @@
#include "window.h"
-#include "../guichanfwd.h"
-
-class ShortcutContainer;
class ScrollArea;
+class ShortcutContainer;
/**
* A window around the ItemShortcutContainer.
@@ -57,6 +55,8 @@ class ShortcutWindow : public Window
ShortcutContainer *mItems;
ScrollArea *mScrollArea;
+
+ static int mInstances;
};
extern ShortcutWindow *itemShortcutWindow;
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 304719b6..c4f8737b 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -23,7 +23,9 @@
#include "button.h"
#include "listbox.h"
+#include "scrollarea.h"
#include "skill.h"
+#include "table.h"
#include "windowcontainer.h"
#include "widgets/layout.h"
@@ -51,7 +53,7 @@ class SkillGuiTableModel : public StaticTableModel
{
public:
SkillGuiTableModel(SkillDialog *dialog) :
- StaticTableModel(0, 3, 0xbdb5aa)
+ StaticTableModel(0, 3)
{
mEntriesNr = 0;
mDialog = dialog;
@@ -124,8 +126,12 @@ SkillDialog::SkillDialog():
{
initSkillinfo();
mTableModel = new SkillGuiTableModel(this);
- mTable.setModel(mTableModel);
- mTable.setLinewiseSelection(true);
+ mTable = new GuiTable(mTableModel);
+ mTable->setOpaque(false);
+ mTable->setLinewiseSelection(true);
+ mTable->setWrappingEnabled(true);
+ mTable->setActionEventId("skill");
+ mTable->addActionListener(this);
setWindowName(_("Skills"));
setCloseButton(true);
@@ -134,18 +140,13 @@ SkillDialog::SkillDialog():
setMinHeight(50 + mTableModel->getHeight());
setMinWidth(200);
-// mSkillListBox = new ListBox(this);
- ScrollArea *skillScrollArea = new ScrollArea(&mTable);
+ ScrollArea *skillScrollArea = new ScrollArea(mTable);
mPointsLabel = new gcn::Label(strprintf(_("Skill points: %d"), 0));
mIncButton = new Button(_("Up"), _("inc"), this);
mUseButton = new Button(_("Use"), _("use"), this);
mUseButton->setEnabled(false);
-// mSkillListBox->setActionEventId("skill");
- mTable.setActionEventId("skill");
-
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- skillScrollArea->setOpaque(false);
place(0, 0, skillScrollArea, 5).setPadding(3);
place(0, 1, mPointsLabel, 2);
@@ -155,15 +156,13 @@ SkillDialog::SkillDialog():
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
-// mSkillListBox->addActionListener(this);
- mTable.addActionListener(this);
-
setLocationRelativeTo(getParent());
loadWindowState();
}
SkillDialog::~SkillDialog()
{
+ delete mTable;
}
void SkillDialog::action(const gcn::ActionEvent &event)
@@ -171,15 +170,14 @@ void SkillDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "inc")
{
// Increment skill
- int selectedSkill = mTable.getSelectedRow();//mSkillListBox->getSelected();
+ int selectedSkill = mTable->getSelectedRow();
if (selectedSkill >= 0)
player_node->raiseSkill(mSkillList[selectedSkill]->id);
}
else if (event.getId() == "skill")
{
- mIncButton->setEnabled(
- mTable.getSelectedRow() > -1 &&
- player_node->mSkillPoint > 0);
+ mIncButton->setEnabled(mTable->getSelectedRow() > -1 &&
+ player_node->mSkillPoint > 0);
}
else if (event.getId() == "close")
setVisible(false);
@@ -190,7 +188,7 @@ void SkillDialog::update()
mPointsLabel->setCaption(strprintf(_("Skill points: %d"),
player_node->mSkillPoint));
- int selectedSkill = mTable.getSelectedRow();
+ int selectedSkill = mTable->getSelectedRow();
if (selectedSkill >= 0)
{
@@ -278,7 +276,8 @@ static void initSkillinfo()
std::string name = XML::getProperty(node, "name", "");
bool modifiable = !atoi(XML::getProperty(node, "fixed", "0").c_str());
- if (index >= 0) {
+ if (index >= 0)
+ {
skill_db.resize(index + 1, emptySkillInfo);
skill_db[index].name = name;
skill_db[index].modifiable = modifiable;
diff --git a/src/gui/skill.h b/src/gui/skill.h
index 582892f0..0600d106 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -25,20 +25,15 @@
#include <vector>
#include <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
-#include "scrollarea.h"
-#include "table.h"
#include "window.h"
-#include "table.h"
-
-#include "../guichanfwd.h"
struct SKILL {
short id; /**< Index into "skill_db" array */
short lv, sp;
};
+class GuiTable;
class SkillGuiTableModel;
/**
@@ -73,7 +68,7 @@ class SkillDialog : public Window, public gcn::ActionListener
const std::vector<SKILL*>& getSkills() const { return mSkillList; }
private:
- GuiTable mTable;//gcn::ListBox *mSkillListBox;
+ GuiTable *mTable;
ScrollArea *skillScrollArea;
SkillGuiTableModel *mTableModel;
gcn::Label *mPointsLabel;
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 37136012..9bfa840f 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -21,6 +21,7 @@
#include "slider.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -28,6 +29,7 @@
Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip;
Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip;
+float Slider::mAlpha = config.getValue("guialpha", 0.8);
int Slider::mInstances = 0;
Slider::Slider(double scaleEnd):
@@ -107,6 +109,20 @@ void Slider::draw(gcn::Graphics *graphics)
int x = 0;
int y = (h - hStart->getHeight()) / 2;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ hStart->setAlpha(mAlpha);
+ hMid->setAlpha(mAlpha);
+ hEnd->setAlpha(mAlpha);
+ hGrip->setAlpha(mAlpha);
+
+ vStart->setAlpha(mAlpha);
+ vMid->setAlpha(mAlpha);
+ vEnd->setAlpha(mAlpha);
+ vGrip->setAlpha(mAlpha);
+ }
+
static_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
w -= hStart->getWidth() + hEnd->getWidth();
diff --git a/src/gui/slider.h b/src/gui/slider.h
index c14c5be9..56ea334a 100644
--- a/src/gui/slider.h
+++ b/src/gui/slider.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/slider.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
@@ -68,6 +66,7 @@ class Slider : public gcn::Slider {
static Image *hStart, *hMid, *hEnd, *hGrip;
static Image *vStart, *vMid, *vEnd, *vGrip;
+ static float mAlpha;
static int mInstances;
};
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 84eeb7d4..c76558e4 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -24,19 +24,15 @@
#include <guichan/widgets/label.hpp>
#include "gui.h"
+#include "scrollarea.h"
#include "speechbubble.h"
-
-#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
+#include "textbox.h"
#include "../utils/gettext.h"
-// TODO: Fix windows so that they can each load their own skins without the
-// other windows overriding another window's skin.
SpeechBubble::SpeechBubble():
Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml")
{
- // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px)
setContentSize(140, 46);
setShowTitle(false);
setTitleBarHeight(0);
@@ -61,11 +57,13 @@ SpeechBubble::SpeechBubble():
add(mSpeechArea);
setLocationRelativeTo(getParent());
+}
- // LEEOR / TODO: This causes an exception error.
- //moveToBottom(getParent());
-
- mSpeechBox->setTextWrapped( "" );
+SpeechBubble::~SpeechBubble()
+{
+ delete mCaption;
+ delete mSpeechBox;
+ delete mSpeechArea;
}
void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
@@ -77,31 +75,18 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
void SpeechBubble::setText(std::string mText)
{
- mSpeechBox->setMinWidth(140);
- mSpeechBox->setTextWrapped(mText);
+ int width = mCaption->getWidth() + 3;
+ mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width);
const int fontHeight = getFont()->getHeight();
const int numRows = mSpeechBox->getNumberOfRows() + 1;
- if (numRows > 2)
- {
- // 15 == height of each line of text (based on font heights)
- // 14 == speechbubble Top + Bottom graphic pixel heights
- setContentSize(mSpeechBox->getMinWidth() + fontHeight,
- (numRows * fontHeight) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- mSpeechBox->getMinWidth() + 5,
- (numRows * fontHeight)));
- }
- else
- {
- int width = mCaption->getWidth() + 3;
- if (width < getFont()->getWidth(mText))
- width = getFont()->getWidth(mText);
- setContentSize(width + fontHeight, (fontHeight * 2) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- width, fontHeight));
- }
+ if (width < mSpeechBox->getMinWidth())
+ width = mSpeechBox->getMinWidth();
+
+ setContentSize(width + fontHeight, (numRows * fontHeight) + 6);
+ mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5,
+ (numRows * fontHeight)));
}
unsigned int SpeechBubble::getNumRows()
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index 9606f8f7..d2d81332 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -22,14 +22,16 @@
#ifndef SPEECHBUBBLE_H
#define SPEECHBUBBLE_H
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
+class ScrollArea;
+class TextBox;
+
class SpeechBubble : public Window
{
public:
SpeechBubble();
+ ~SpeechBubble();
void setCaption(const std::string &name,
const gcn::Color &color = 0x000000);
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 526fa6b1..21087fad 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -26,6 +26,8 @@
#include "status.h"
#include "windowcontainer.h"
+#include "widgets/layout.h"
+
#include "../localplayer.h"
#include "../utils/gettext.h"
@@ -39,83 +41,27 @@ StatusWindow::StatusWindow(LocalPlayer *player):
setWindowName(_("Status"));
setCloseButton(true);
setDefaultSize((windowContainer->getWidth() - 365) / 2,
- (windowContainer->getHeight() - 255) / 2, 400, 275);
- loadWindowState();
+ (windowContainer->getHeight() - 255) / 2, 400, 335);
// ----------------------
// Status Part
// ----------------------
mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
- mGpLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
- mJobLvlLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
+ mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
+ mGpLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
mHpLabel = new gcn::Label(_("HP:"));
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
- mHpValueLabel = new gcn::Label;
mXpLabel = new gcn::Label(_("Exp:"));
mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mXpValueLabel = new gcn::Label;
mMpLabel = new gcn::Label(_("MP:"));
mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- mMpValueLabel = new gcn::Label;
-
- mJobXpLabel = new gcn::Label(_("Job:"));
- mJobXpBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
- mJobValueLabel = new gcn::Label;
-
- int y = 3;
- int x = 5;
-
- mLvlLabel->setPosition(x, y);
- x += mLvlLabel->getWidth() + 40;
- mJobLvlLabel->setPosition(x, y);
- x += mJobLvlLabel->getWidth() + 40;
- mGpLabel->setPosition(x, y);
-
- y += mLvlLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mHpLabel->setPosition(x, y);
- x += mHpLabel->getWidth() + 5;
- mHpBar->setPosition(x, y);
- x += mHpBar->getWidth() + 5;
- mHpValueLabel->setPosition(x, y);
-
- mXpLabel->setPosition(175, y);
- mXpBar->setPosition(205, y);
- mXpValueLabel->setPosition(290, y);
-
- y += mHpLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mMpLabel->setPosition(x, y);
- x += mMpLabel->getWidth() + 5;
- mMpBar->setPosition(x, y);
- x += mMpBar->getWidth() + 5;
- mMpValueLabel->setPosition(x, y);
-
- mJobXpLabel->setPosition(175, y);
- mJobXpBar->setPosition(205, y);
- mJobValueLabel->setPosition(290, y);
-
- add(mLvlLabel);
- add(mJobLvlLabel);
- add(mGpLabel);
- add(mHpLabel);
- add(mHpValueLabel);
- add(mMpLabel);
- add(mMpValueLabel);
- add(mXpLabel);
- add(mXpValueLabel);
- add(mJobXpLabel);
- add(mJobValueLabel);
- add(mHpBar);
- add(mMpBar);
- add(mXpBar);
- add(mJobXpBar);
+
+ mJobLabel = new gcn::Label(_("Job:"));
+ mJobBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
// ----------------------
// Stats Part
@@ -125,6 +71,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
gcn::Label *mStatsTitleLabel = new gcn::Label(_("Stats"));
gcn::Label *mStatsTotalLabel = new gcn::Label(_("Total"));
gcn::Label *mStatsCostLabel = new gcn::Label(_("Cost"));
+ mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER);
// Derived Stats
mStatsAttackLabel = new gcn::Label(_("Attack:"));
@@ -147,10 +94,13 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsReflexPoints = new gcn::Label;
// New labels
- for (int i = 0; i < 6; i++) {
- mStatsLabel[i] = new gcn::Label;
+ for (int i = 0; i < 6; i++)
+ {
+ mStatsLabel[i] = new gcn::Label("0");
+ mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER);
mStatsDisplayLabel[i] = new gcn::Label;
mPointsLabel[i] = new gcn::Label("0");
+ mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER);
}
mRemainingStatsPointsLabel = new gcn::Label;
@@ -162,68 +112,53 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsButton[4] = new Button("+", "DEX", this);
mStatsButton[5] = new Button("+", "LUK", this);
-
- // Set position
- mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 );
- mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
- int totalLabelY = mStatsTotalLabel->getY();
- mStatsCostLabel->setPosition(170, totalLabelY);
-
- for (int i = 0; i < 6; i++)
- {
- mStatsLabel[i]->setPosition(5, mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(115,
- totalLabelY + (i * 23) + 15);
- mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15);
- }
-
- mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[5]->getY() + 25);
-
- mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
- mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
- mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY());
- mStatsMagicDefenseLabel->setPosition(220, mStatsLabel[3]->getY());
- mStatsAccuracyLabel->setPosition(220, mStatsLabel[4]->getY());
- mStatsEvadeLabel->setPosition(220, mStatsLabel[5]->getY());
- mStatsReflexLabel->setPosition(220, mRemainingStatsPointsLabel->getY());
-
- mStatsAttackPoints->setPosition(310, mStatsLabel[0]->getY());
- mStatsDefensePoints->setPosition(310, mStatsLabel[1]->getY());
- mStatsMagicAttackPoints->setPosition(310, mStatsLabel[2]->getY());
- mStatsMagicDefensePoints->setPosition(310, mStatsLabel[3]->getY());
- mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY());
- mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY());
- mStatsReflexPoints->setPosition(310, mRemainingStatsPointsLabel->getY());
-
// Assemble
- add(mStatsTitleLabel);
- add(mStatsTotalLabel);
- add(mStatsCostLabel);
- for (int i = 0; i < 6; i++)
+ ContainerPlacer place;
+ place = getPlacer(0, 0);
+
+ place(0, 0, mLvlLabel, 3);
+ place(5, 0, mJobLvlLabel, 3);
+ place(8, 0, mGpLabel, 3);
+ place(1, 1, mHpLabel);
+ place(2, 1, mHpBar, 3);
+ place(6, 1, mXpLabel);
+ place(7, 1, mXpBar, 3);
+ place(1, 2, mMpLabel);
+ place(2, 2, mMpBar, 3);
+ place(6, 2, mJobLabel);
+ place(7, 2, mJobBar, 3);
+ place.getCell().matchColWidth(0, 1);
+ place = getPlacer(0, 3);
+ place(0, 0, mStatsTitleLabel, 5);
+ place(5, 1, mStatsTotalLabel, 5);
+ place(12, 1, mStatsCostLabel, 5);
+ for(int i = 0; i < 6; i++)
{
- add(mStatsLabel[i]);
- add(mStatsDisplayLabel[i]);
- add(mStatsButton[i]);
- add(mPointsLabel[i]);
+ place(0, 2 + i, mStatsLabel[i], 7).setPadding(5);
+ place(7, 2 + i, mStatsDisplayLabel[i]).setPadding(5);
+ place(10, 2 + i, mStatsButton[i]);
+ place(12, 2 + i, mPointsLabel[i]).setPadding(5);
}
- add(mStatsAttackLabel);
- add(mStatsDefenseLabel);
- add(mStatsMagicAttackLabel);
- add(mStatsMagicDefenseLabel);
- add(mStatsAccuracyLabel);
- add(mStatsEvadeLabel);
- add(mStatsReflexLabel);
-
- add(mStatsAttackPoints);
- add(mStatsDefensePoints);
- add(mStatsMagicAttackPoints);
- add(mStatsMagicDefensePoints);
- add(mStatsAccuracyPoints);
- add(mStatsEvadePoints);
- add(mStatsReflexPoints);
-
- add(mRemainingStatsPointsLabel);
+ place(14, 2, mStatsAttackLabel, 7).setPadding(5);
+ place(14, 3, mStatsDefenseLabel, 7).setPadding(5);
+ place(14, 4, mStatsMagicAttackLabel, 7).setPadding(5);
+ place(14, 5, mStatsMagicDefenseLabel, 7).setPadding(5);
+ place(14, 6, mStatsAccuracyLabel, 7).setPadding(5);
+ place(14, 7, mStatsEvadeLabel, 7).setPadding(5);
+ place(14, 8, mStatsReflexLabel, 7).setPadding(5);
+ place(21, 2, mStatsAttackPoints, 3).setPadding(5);
+ place(21, 3, mStatsDefensePoints, 3).setPadding(5);
+ place(21, 4, mStatsMagicAttackPoints, 3).setPadding(5);
+ place(21, 5, mStatsMagicDefensePoints, 3).setPadding(5);
+ place(21, 6, mStatsAccuracyPoints, 3).setPadding(5);
+ place(21, 7, mStatsEvadePoints, 3).setPadding(5);
+ place(21, 8, mStatsReflexPoints, 3).setPadding(5);
+ place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+
+ loadWindowState();
}
void StatusWindow::update()
@@ -239,21 +174,17 @@ void StatusWindow::update()
mGpLabel->setCaption(strprintf(_("Money: %d GP"), mPlayer->mGp));
mGpLabel->adjustSize();
- mHpValueLabel->setCaption(toString(mPlayer->mHp) +
- "/" + toString(mPlayer->mMaxHp));
- mHpValueLabel->adjustSize();
+ mHpBar->setText(toString(mPlayer->mHp) +
+ "/" + toString(mPlayer->mMaxHp));
- mMpValueLabel->setCaption(toString(mPlayer->mMp) +
- "/" + toString(mPlayer->mMaxMp));
- mMpValueLabel->adjustSize();
+ mMpBar->setText(toString(mPlayer->mMp) +
+ "/" + toString(mPlayer->mMaxMp));
- mXpValueLabel->setCaption(toString(mPlayer->getXp()) +
- "/" + toString(mPlayer->mXpForNextLevel));
- mXpValueLabel->adjustSize();
+ mXpBar->setText(toString(mPlayer->getXp()) +
+ "/" + toString(mPlayer->mXpForNextLevel));
- mJobValueLabel->setCaption(toString(mPlayer->mJobXp) +
- "/" + toString(mPlayer->mJobXpForNextLevel));
- mJobValueLabel->adjustSize();
+ mJobBar->setText(toString(mPlayer->mJobXp) +
+ "/" + toString(mPlayer->mJobXpForNextLevel));
// HP Bar coloration
if (mPlayer->mHp < int(mPlayer->mMaxHp / 3))
@@ -274,7 +205,7 @@ void StatusWindow::update()
mXpBar->setProgress(
(float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel);
- mJobXpBar->setProgress(
+ mJobBar->setProgress(
(float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel);
// Stats Part
@@ -339,30 +270,6 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-
- // Update Second column widgets position
- mJobLvlLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
- mLvlLabel->getY());
- mGpLabel->setPosition(mJobLvlLabel->getX() + mJobLvlLabel->getWidth() + 20,
- mJobLvlLabel->getY());
-
- mXpLabel->setPosition(
- mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(
- mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(
- mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
-
- mJobXpLabel->setPosition(mXpBar->getX() - mJobXpLabel->getWidth() - 5,
- mMpLabel->getY());
- mJobXpBar->setPosition(
- mJobXpLabel->getX() + mJobXpLabel->getWidth() + 5,
- mJobXpLabel->getY());
- mJobValueLabel->setPosition(mJobXpBar->getX() + mJobXpBar->getWidth() + 5,
- mJobXpLabel->getY());
}
void StatusWindow::draw(gcn::Graphics *g)
diff --git a/src/gui/status.h b/src/gui/status.h
index 14a7617e..00a48f4e 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -22,14 +22,10 @@
#ifndef STATUS_H
#define STATUS_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class LocalPlayer;
class ProgressBar;
@@ -69,11 +65,9 @@ class StatusWindow : public Window, public gcn::ActionListener
*/
gcn::Label *mLvlLabel, *mJobLvlLabel;
gcn::Label *mGpLabel;
- gcn::Label *mHpLabel, *mHpValueLabel;
- gcn::Label *mMpLabel, *mMpValueLabel;
- gcn::Label *mXpLabel, *mXpValueLabel, *mJobXpLabel, *mJobValueLabel;
+ gcn::Label *mHpLabel, *mMpLabel, *mXpLabel, *mJobLabel;
ProgressBar *mHpBar, *mMpBar;
- ProgressBar *mXpBar, *mJobXpBar;
+ ProgressBar *mXpBar, *mJobBar;
/**
* Derived Statistics captions
diff --git a/src/gui/table.cpp b/src/gui/table.cpp
index 7e855523..19039b2d 100644
--- a/src/gui/table.cpp
+++ b/src/gui/table.cpp
@@ -19,13 +19,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
-#include <guichan/graphics.hpp>
#include <guichan/actionlistener.hpp>
+#include <guichan/graphics.hpp>
+#include <guichan/key.hpp>
+#include "colour.h"
#include "table.h"
+#include "../configuration.h"
+
+#include "../utils/dtor.h"
+
+float GuiTable::mAlpha = config.getValue("guialpha", 0.8);
+
class GuiTableActionListener : public gcn::ActionListener
{
public:
@@ -49,7 +55,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid
mColumn(column),
mWidget(widget)
{
- if (widget) {
+ if (widget)
+ {
widget->addActionListener(this);
widget->_setParent(table);
}
@@ -57,7 +64,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid
GuiTableActionListener::~GuiTableActionListener()
{
- if (mWidget) {
+ if (mWidget)
+ {
mWidget->removeActionListener(this);
mWidget->_setParent(NULL);
}
@@ -70,14 +78,20 @@ void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent)
}
-GuiTable::GuiTable(TableModel *initial_model) :
+GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
+ bool opacity) :
mLinewiseMode(false),
+ mWrappingEnabled(false),
+ mOpaque(opacity),
+ mBackgroundColor(background),
mModel(NULL),
mSelectedRow(0),
mSelectedColumn(0),
mTopWidget(NULL)
{
setModel(initial_model);
+ setFocusable(true);
+
addMouseListener(this);
addKeyListener(this);
}
@@ -94,16 +108,17 @@ TableModel *GuiTable::getModel() const
void GuiTable::setModel(TableModel *new_model)
{
- if (mModel) {
+ if (mModel)
+ {
uninstallActionListeners();
mModel->removeListener(this);
}
-
mModel = new_model;
installActionListeners();
- if (new_model) {
+ if (new_model)
+ {
new_model->installListener(this);
recomputeDimensions();
}
@@ -168,10 +183,62 @@ int GuiTable::getColumnWidth(int i)
return 0;
}
-void GuiTable::uninstallActionListeners()
+void GuiTable::setSelectedRow(int selected)
+{
+ if (mModel == NULL)
+ {
+ mSelectedRow = -1;
+ }
+ else
+ {
+ if (selected < 0 && !mWrappingEnabled)
+ {
+ mSelectedRow = -1;
+ }
+ else if (selected >= mModel->getRows() && mWrappingEnabled)
+ {
+ mSelectedRow = 0;
+ }
+ else if ((selected >= mModel->getRows() && !mWrappingEnabled) ||
+ (selected < 0 && mWrappingEnabled))
+ {
+ mSelectedRow = mModel->getRows() - 1;
+ }
+ else
+ {
+ mSelectedRow = selected;
+ }
+ }
+}
+
+void GuiTable::setSelectedColumn(int selected)
{
- for (std::vector<GuiTableActionListener *>::const_iterator it = action_listeners.begin(); it != action_listeners.end(); it++)
- delete *it;
+ if (mModel == NULL)
+ {
+ mSelectedColumn = -1;
+ }
+ else
+ {
+ if ((selected >= mModel->getColumns() && mWrappingEnabled) ||
+ (selected < 0 && !mWrappingEnabled))
+ {
+ mSelectedColumn = 0;
+ }
+ else if ((selected >= mModel->getColumns() && !mWrappingEnabled) ||
+ (selected < 0 && mWrappingEnabled))
+ {
+ mSelectedColumn = mModel->getColumns() - 1;
+ }
+ else
+ {
+ mSelectedColumn = selected;
+ }
+ }
+}
+
+void GuiTable::uninstallActionListeners(void)
+{
+ delete_all(action_listeners);
action_listeners.clear();
}
@@ -184,10 +251,11 @@ void GuiTable::installActionListeners()
int columns = mModel->getColumns();
for (int row = 0; row < rows; ++row)
- for (int column = 0; column < columns; ++column) {
+ for (int column = 0; column < columns; ++column)
+ {
gcn::Widget *widget = mModel->getElementAt(row, column);
action_listeners.push_back(new GuiTableActionListener(this, widget,
- row, column));
+ row, column));
}
_setFocusHandler(_getFocusHandler()); // propagate focus handler to widgets
@@ -196,12 +264,22 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(gcn::Graphics* graphics)
{
- graphics->setColor(getBackgroundColor());
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
-
if (!mModel)
return;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ if (mOpaque)
+ {
+ const int red = getBackgroundColor().r;
+ const int green = getBackgroundColor().g;
+ const int blue = getBackgroundColor().b;
+ const int alpha = mAlpha * 255;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ }
+
// First, determine how many rows we need to draw, and where we should start.
int first_row = -(getY() / getRowHeight());
@@ -223,44 +301,68 @@ void GuiTable::draw(gcn::Graphics* graphics)
int height = getRowHeight();
int y_offset = first_row * height;
- for (int r = first_row; r < first_row + rows_nr; ++r) {
+ for (int r = first_row; r < first_row + rows_nr; ++r)
+ {
int x_offset = 0;
- for (int c = first_column; c <= last_column; ++c) {
+ for (int c = first_column; c <= last_column; ++c)
+ {
gcn::Widget *widget = mModel->getElementAt(r, c);
int width = getColumnWidth(c);
- if (widget) {
+ if (widget)
+ {
gcn::Rectangle bounds(x_offset, y_offset, width, height);
- if (widget == mTopWidget) {
+ if (widget == mTopWidget)
+ {
bounds.height = widget->getHeight();
bounds.width = widget->getWidth();
}
widget->setDimension(bounds);
+ if (!mLinewiseMode && c == mSelectedColumn && r == mSelectedRow)
+ {
+ bool valid;
+ const int red =
+ (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green =
+ (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 127;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(bounds);
+ }
+
graphics->pushClipArea(bounds);
widget->draw(graphics);
graphics->popClipArea();
-
- if (!mLinewiseMode
- && c == mSelectedColumn
- && r == mSelectedRow)
- graphics->drawRectangle(bounds);
}
x_offset += width;
}
- if (mLinewiseMode
- && r == mSelectedRow)
- graphics->drawRectangle(gcn::Rectangle(0, y_offset,
+ if (mLinewiseMode && r == mSelectedRow)
+ {
+ bool valid;
+ const int red =
+ (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green =
+ (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 127;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, y_offset,
x_offset, height));
+ }
y_offset += height;
}
- if (mTopWidget) {
+ if (mTopWidget)
+ {
gcn::Rectangle bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
mTopWidget->draw(graphics);
@@ -268,21 +370,17 @@ void GuiTable::draw(gcn::Graphics* graphics)
}
}
-void GuiTable::logic()
-{
-}
-
void GuiTable::moveToTop(gcn::Widget *widget)
{
gcn::Widget::moveToTop(widget);
- this->mTopWidget = widget;
+ mTopWidget = widget;
}
void GuiTable::moveToBottom(gcn::Widget *widget)
{
gcn::Widget::moveToBottom(widget);
- if (widget == this->mTopWidget)
- this->mTopWidget = NULL;
+ if (widget == mTopWidget)
+ mTopWidget = NULL;
}
gcn::Rectangle GuiTable::getChildrenArea()
@@ -293,16 +391,62 @@ gcn::Rectangle GuiTable::getChildrenArea()
// -- KeyListener notifications
void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
+ gcn::Key key = keyEvent.getKey();
+
+ if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE)
+ {
+ distributeActionEvent();
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::UP)
+ {
+ setSelectedRow(mSelectedRow - 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::DOWN)
+ {
+ setSelectedRow(mSelectedRow + 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::LEFT)
+ {
+ setSelectedColumn(mSelectedColumn - 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::RIGHT)
+ {
+ setSelectedColumn(mSelectedColumn + 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::HOME)
+ {
+ setSelectedRow(0);
+ setSelectedColumn(0);
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::END)
+ {
+ setSelectedRow(mModel->getRows() - 1);
+ setSelectedColumn(mModel->getColumns() - 1);
+ keyEvent.consume();
+ }
}
// -- MouseListener notifications
void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
{
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) {
+ if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ {
int row = getRowForY(mouseEvent.getY());
int column = getColumnForX(mouseEvent.getX());
- if (row > -1 && column > -1) {
+ if (row > -1 && column > -1 &&
+ row < mModel->getRows() && column < mModel->getColumns())
+ {
mSelectedColumn = column;
mSelectedRow = row;
}
@@ -313,10 +457,25 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
+ if (isFocused())
+ {
+ if (getSelectedRow() >= 0 )
+ {
+ setSelectedRow(getSelectedRow() - 1);
+ }
+
+ mouseEvent.consume();
+ }
}
void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
+ if (isFocused())
+ {
+ setSelectedRow(getSelectedRow() + 1);
+
+ mouseEvent.consume();
+ }
}
void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
@@ -326,10 +485,13 @@ void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
// -- TableModelListener notifications
void GuiTable::modelUpdated(bool completed)
{
- if (completed) {
+ if (completed)
+ {
recomputeDimensions();
installActionListeners();
- } else { // before the update?
+ }
+ else
+ { // before the update?
mTopWidget = NULL; // No longer valid in general
uninstallActionListeners();
}
@@ -340,18 +502,18 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y)
int row = getRowForY(y);
int column = getColumnForX(x);
- if (mTopWidget
- && mTopWidget->getDimension().isPointInRect(x, y))
+ if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
return mTopWidget;
- if (row > -1
- && column > -1) {
+ if (row > -1 && column > -1)
+ {
gcn::Widget *w = mModel->getElementAt(row, column);
if (w && w->isFocusable())
return w;
else
return NULL; // Grab the event locally
- } else
+ }
+ else
return NULL;
}
@@ -359,8 +521,7 @@ int GuiTable::getRowForY(int y)
{
int row = y / getRowHeight();
- if (row < 0
- || row >= mModel->getRows())
+ if (row < 0 || row >= mModel->getRows())
return -1;
else
return row;
@@ -371,14 +532,14 @@ int GuiTable::getColumnForX(int x)
int column;
int delta = 0;
- for (column = 0; column < mModel->getColumns(); column++) {
+ for (column = 0; column < mModel->getColumns(); column++)
+ {
delta += getColumnWidth(column);
if (x <= delta)
break;
}
- if (column < 0
- || column >= mModel->getColumns())
+ if (column < 0 || column >= mModel->getColumns())
return -1;
else
return column;
diff --git a/src/gui/table.h b/src/gui/table.h
index 9dde8900..841f6ef2 100644
--- a/src/gui/table.h
+++ b/src/gui/table.h
@@ -24,16 +24,12 @@
#include <vector>
-#include <guichan/gui.hpp>
#include <guichan/keylistener.hpp>
#include <guichan/mouselistener.hpp>
-#include <guichan/platform.hpp>
#include <guichan/widget.hpp>
#include "table_model.h"
-#include "../guichanfwd.h"
-
class GuiTableActionListener;
/**
@@ -54,7 +50,8 @@ class GuiTable : public gcn::Widget,
friend class GuiTableActionListener;
public:
- GuiTable(TableModel * initial_model = NULL);
+ GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff,
+ bool opacity = true);
virtual ~GuiTable();
@@ -68,25 +65,36 @@ public:
*
* Note that actions issued by widgets returned from the model will update
* the table selection, but only AFTER any event handlers installed within
- * the widget have been triggered. To be notified after such an update,
- * add an action listener to the table instead.
+ * the widget have been triggered. To be notified after such an update, add
+ * an action listener to the table instead.
*/
void setModel(TableModel *m);
+ const TableModel* getModel() {return mModel;}
+
void setSelected(int row, int column);
int getSelectedRow();
int getSelectedColumn();
- gcn::Rectangle getChildrenArea();
+ void setSelectedRow(int selected);
+
+ void setSelectedColumn(int selected);
+
+ bool isWrappingEnabled() const {return mWrappingEnabled;}
+
+ void setWrappingEnabled(bool wrappingEnabled)
+ {mWrappingEnabled = wrappingEnabled;}
+
+ gcn::Rectangle getChildrenArea(void);
/**
- * Toggle whether to use linewise selection mode, in which the table
- * selects an entire line at a time, rather than a single cell.
+ * Toggle whether to use linewise selection mode, in which the table selects
+ * an entire line at a time, rather than a single cell.
*
- * Note that column information is tracked even in linewise selection
- * mode; this mode therefore only affects visualisation.
+ * Note that column information is tracked even in linewise selection mode;
+ * this mode therefore only affects visualisation.
*
* Disabled by default.
*
@@ -97,8 +105,6 @@ public:
// Inherited from Widget
virtual void draw(gcn::Graphics* graphics);
- virtual void logic();
-
virtual gcn::Widget *getWidgetAt(int x, int y);
virtual void moveToTop(gcn::Widget *child);
@@ -110,6 +116,21 @@ public:
// Inherited from KeyListener
virtual void keyPressed(gcn::KeyEvent& keyEvent);
+ /**
+ * Sets the table to be opaque, that is sets the table
+ * to display its background.
+ *
+ * @param opaque True if the table should be opaque, false otherwise.
+ */
+ virtual void setOpaque(bool opaque) {mOpaque = opaque;}
+
+ /**
+ * Checks if the table is opaque, that is if the table area displays its
+ * background.
+ *
+ * @return True if the table is opaque, false otherwise.
+ */
+ virtual bool isOpaque() const {return mOpaque;}
// Inherited from MouseListener
virtual void mousePressed(gcn::MouseEvent& mouseEvent);
@@ -137,6 +158,15 @@ private:
int getColumnForX(int x); // -1 on error
void recomputeDimensions();
bool mLinewiseMode;
+ bool mWrappingEnabled;
+ bool mOpaque;
+
+ static float mAlpha;
+
+ /**
+ * Holds the background color of the table.
+ */
+ gcn::Color mBackgroundColor;
TableModel *mModel;
diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp
index 33dd8cb2..4fa13bae 100644
--- a/src/gui/table_model.cpp
+++ b/src/gui/table_model.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstdlib>
-
-#include <guichan/graphics.hpp>
#include <guichan/widget.hpp>
#include "table_model.h"
@@ -54,13 +51,10 @@ void TableModel::signalAfterUpdate()
#define WIDGET_AT(row, column) (((row) * mColumns) + (column))
#define DYN_SIZE(h) ((h) >= 0) // determines whether this size is tagged for auto-detection
-StaticTableModel::StaticTableModel(int row, int column,
- gcn::Color backgroundColor, bool opacity) :
+StaticTableModel::StaticTableModel(int row, int column) :
mRows(row),
mColumns(column),
- mHeight(1),
- mOpaque(opacity),
- mBackgroundColor(backgroundColor)
+ mHeight(1)
{
mTableModel.resize(row * column, NULL);
mWidths.resize(column, 1);
@@ -165,24 +159,3 @@ int StaticTableModel::getHeight(void)
return (mColumns * mHeight);
}
-void StaticTableModel::drawBackground(gcn::Graphics *graphics)
-{
- if (isOpaque())
- {
- for (unsigned int i = 0; i < mTableModel.size(); i++)
- {
- mTableModel[i]->setBackgroundColor(mBackgroundColor);
- }
- }
-}
-
-void StaticTableModel::setOpaque(bool opaque)
-{
- mOpaque = opaque;
-}
-
-bool StaticTableModel::isOpaque() const
-{
- return mOpaque;
-}
-
diff --git a/src/gui/table_model.h b/src/gui/table_model.h
index 03b69dba..9ca36120 100644
--- a/src/gui/table_model.h
+++ b/src/gui/table_model.h
@@ -25,11 +25,6 @@
#include <set>
#include <vector>
-#include <guichan/color.hpp>
-#include <guichan/gui.hpp>
-
-#include "../guichanfwd.h"
-
class TableModelListener
{
public:
@@ -101,8 +96,7 @@ private:
class StaticTableModel : public TableModel
{
public:
- StaticTableModel(int width, int height, gcn::Color background = 0xffffff,
- bool opacity = true);
+ StaticTableModel(int width, int height);
virtual ~StaticTableModel();
/**
@@ -132,22 +126,6 @@ public:
*/
virtual void resize();
- /**
- * Sets the table to be opaque, that is sets the table
- * to display its background.
- *
- * @param opaque True if the table should be opaque, false otherwise.
- */
- virtual void setOpaque(bool opaque);
-
- /**
- * Checks if the scroll area is opaque, that is if the scroll area
- * displays its background.
- *
- * @return True if the scroll area is opaque, false otherwise.
- */
- virtual bool isOpaque() const;
-
virtual int getRows();
virtual int getColumns();
virtual int getRowHeight();
@@ -159,22 +137,8 @@ public:
protected:
int mRows, mColumns;
int mHeight;
- bool mOpaque;
std::vector<gcn::Widget *> mTableModel;
std::vector<int> mWidths;
-
- /**
- * Holds the background color of the table.
- */
- gcn::Color mBackgroundColor;
-
- /**
- * Draws the background of the table, that is
- * the area behind the content.
- *
- * @param graphics a Graphics object to draw with.
- */
- virtual void drawBackground(gcn::Graphics *graphics);
};
#endif /* !defined(TABLE_MODEL_H) */
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index ee03c79d..2a86d549 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -21,7 +21,6 @@
#include <sstream>
-#include <guichan/basiccontainer.hpp>
#include <guichan/font.hpp>
#include "textbox.h"
@@ -31,9 +30,10 @@ TextBox::TextBox():
{
setOpaque(false);
setFrameSize(0);
+ mMinWidth = getWidth();
}
-void TextBox::setTextWrapped(const std::string &text)
+void TextBox::setTextWrapped(const std::string &text, int minDimension)
{
// Make sure parent scroll area sets width of this widget
if (getParent())
@@ -41,6 +41,9 @@ void TextBox::setTextWrapped(const std::string &text)
getParent()->logic();
}
+ // Take the supplied minimum dimension as a starting point and try to beat it
+ mMinWidth = minDimension;
+
std::stringstream wrappedStream;
std::string::size_type newlinePos, lastNewlinePos = 0;
int minWidth = 0;
@@ -61,6 +64,17 @@ void TextBox::setTextWrapped(const std::string &text)
std::string::size_type spacePos, lastSpacePos = 0;
xpos = 0;
+ spacePos = text.rfind(" ", text.size());
+
+ if (spacePos != std::string::npos)
+ {
+ const std::string word = text.substr(spacePos + 1);
+ const int length = getFont()->getWidth(word);
+
+ if (length > mMinWidth)
+ mMinWidth = length;
+ }
+
do
{
spacePos = line.find(" ", lastSpacePos);
@@ -88,9 +102,8 @@ void TextBox::setTextWrapped(const std::string &text)
else
{
if (xpos > minWidth)
- {
minWidth = xpos;
- }
+
// The window wasn't big enough. Resize it and try again.
if (minWidth > mMinWidth)
{
@@ -100,6 +113,8 @@ void TextBox::setTextWrapped(const std::string &text)
spacePos = 0;
lastNewlinePos = 0;
newlinePos = text.find("\n", lastNewlinePos);
+ if (newlinePos == std::string::npos)
+ newlinePos = text.size();
line = text.substr(lastNewlinePos, newlinePos -
lastNewlinePos);
width = 0;
@@ -116,17 +131,15 @@ void TextBox::setTextWrapped(const std::string &text)
while (spacePos != line.size());
if (text.find("\n", lastNewlinePos) != std::string::npos)
- {
wrappedStream << "\n";
- }
+
lastNewlinePos = newlinePos + 1;
}
while (newlinePos != text.size());
if (xpos > minWidth)
- {
minWidth = xpos;
- }
+
mMinWidth = minWidth;
gcn::TextBox::setText(wrappedStream.str());
diff --git a/src/gui/textbox.h b/src/gui/textbox.h
index 98b60402..10a81fc0 100644
--- a/src/gui/textbox.h
+++ b/src/gui/textbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/textbox.hpp>
-#include "../guichanfwd.h"
-
/**
* A text box, meant to be used inside a scroll area. Same as the Guichan text
* box except this one doesn't have a background or border, instead completely
@@ -33,7 +31,8 @@
*
* \ingroup GUI
*/
-class TextBox : public gcn::TextBox {
+class TextBox : public gcn::TextBox
+{
public:
/**
* Constructor.
@@ -43,18 +42,13 @@ class TextBox : public gcn::TextBox {
/**
* Sets the text after wrapping it to the current width of the widget.
*/
- void setTextWrapped(const std::string &text);
+ void setTextWrapped(const std::string &text, int minDimension);
/**
* Get the minimum text width for the text box.
*/
int getMinWidth() { return mMinWidth; }
- /**
- * Set the minimum text width for the text box.
- */
- void setMinWidth(int width) { mMinWidth = width; }
-
private:
int mMinWidth;
};
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 3369195d..99a95a2e 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include <guichan/font.hpp>
#include "sdlinput.h"
@@ -37,6 +35,7 @@
#undef DELETE //Win32 compatibility hack
int TextField::instances = 0;
+float TextField::mAlpha = config.getValue("guialpha", 0.8);
ImageRect TextField::skin;
TextField::TextField(const std::string& text):
@@ -53,9 +52,6 @@ TextField::TextField(const std::string& text):
Image *textbox = resman->getImage("graphics/gui/deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
- //Image *textbox = resman->getImage("graphics/gui/textbox.png");
- //int gridx[4] = {0, 5, 26, 31};
- //int gridy[4] = {0, 5, 26, 31};
int a = 0, x, y;
for (y = 0; y < 3; y++) {
@@ -96,6 +92,15 @@ void TextField::draw(gcn::Graphics *graphics)
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ skin.grid[a]->setAlpha(mAlpha);
+ }
+ }
}
void TextField::drawFrame(gcn::Graphics *graphics)
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index a2432175..73824615 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/textfield.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
class TextField;
@@ -99,6 +97,7 @@ class TextField : public gcn::TextField {
private:
static int instances;
+ static float mAlpha;
static ImageRect skin;
bool mNumeric;
int mMinimum;
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index b20b7c86..af30d1fe 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -41,8 +41,6 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../resources/iteminfo.h"
-
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
#include "../utils/tostring.h"
diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h
index 6f0671a2..cd68a94e 100644
--- a/src/gui/truetypefont.h
+++ b/src/gui/truetypefont.h
@@ -25,7 +25,6 @@
#include <string>
#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
#ifndef __APPLE__
#include <SDL/SDL_ttf.h>
#else
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 67e05bbd..1f62bd2d 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -26,6 +26,9 @@
#include <guichan/widgets/label.hpp>
+// Curl should be included after Guichan to avoid Windows redefinitions
+#include <curl/curl.h>
+
#include "browserbox.h"
#include "button.h"
#include "progressbar.h"
@@ -34,9 +37,6 @@
#include "widgets/layout.h"
-// Curl should be included after Guichan to avoid Windows redefinitions
-#include <curl/curl.h>
-
#include "../configuration.h"
#include "../log.h"
#include "../main.h"
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 6450ece2..4ada3c3a 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -29,8 +29,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
#include "../utils/mutex.h"
class BrowserBox;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index fe058c0a..f5a6edb4 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
-#include "gui.h"
#include "ministatus.h"
#include "popupmenu.h"
#include "viewport.h"
@@ -37,9 +34,6 @@
#include "../npc.h"
#include "../textmanager.h"
-#include "../resources/animation.h"
-#include "../resources/image.h"
-#include "../resources/imageset.h"
#include "../resources/monsterinfo.h"
#include "../resources/resourcemanager.h"
@@ -216,7 +210,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
{
- (*i)->drawSpeech(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
+ (*i)->drawSpeech(-(int) mPixelViewX, -(int) mPixelViewY);
(*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 5ed40166..522ea734 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -26,16 +26,15 @@
#include "windowcontainer.h"
-#include "../being.h"
#include "../configlistener.h"
-#include "../guichanfwd.h"
+#include "../position.h"
-class Map;
class FloorItem;
+class Graphics;
class ImageSet;
class Item;
+class Map;
class PopupMenu;
-class Graphics;
/**
* The viewport on the map. Displays the current map and handles mouse input
@@ -139,4 +138,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
PopupMenu *mPopupMenu; /**< Popup menu. */
};
+extern Viewport *viewport; /**< The viewport */
+
#endif
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 88a12d68..31d35cb0 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -23,6 +23,11 @@
#include "dropdown.h"
+#include "../colour.h"
+#include "../listbox.h"
+#include "../scrollarea.h"
+
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -33,12 +38,12 @@
int DropDown::instances = 0;
Image *DropDown::buttons[2][2];
ImageRect DropDown::skin;
+float DropDown::mAlpha = config.getValue("guialpha", 0.8);
-DropDown::DropDown(gcn::ListModel *listModel,
- gcn::ScrollArea *scrollArea,
- gcn::ListBox *listBox):
- gcn::DropDown::DropDown(listModel,
- scrollArea, listBox)
+DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea,
+ gcn::ListBox *listBox, bool opacity):
+ gcn::DropDown::DropDown(listModel, scrollArea, listBox),
+ mOpaque(opacity)
{
setFrameSize(2);
@@ -58,6 +63,11 @@ DropDown::DropDown(gcn::ListModel *listModel,
buttons[0][1] =
resman->getImage("graphics/gui/vscroll_down_pressed.png");
+ buttons[0][0]->setAlpha(mAlpha);
+ buttons[0][1]->setAlpha(mAlpha);
+ buttons[1][0]->setAlpha(mAlpha);
+ buttons[1][1]->setAlpha(mAlpha);
+
// get the border skin
Image *boxBorder = resman->getImage("graphics/gui/deepbox.png");
int gridx[4] = {0, 3, 28, 31};
@@ -70,6 +80,7 @@ DropDown::DropDown(gcn::ListModel *listModel,
gridx[x], gridy[y],
gridx[x + 1] - gridx[x] + 1,
gridy[y + 1] - gridy[y] + 1);
+ skin.grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -108,19 +119,44 @@ void DropDown::draw(gcn::Graphics* graphics)
h = getHeight();
}
- int alpha = getBaseColor().a;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ buttons[0][0]->setAlpha(mAlpha);
+ buttons[0][1]->setAlpha(mAlpha);
+ buttons[1][0]->setAlpha(mAlpha);
+ buttons[1][1]->setAlpha(mAlpha);
+
+ for (int a = 0; a < 9; a++)
+ {
+ skin.grid[a]->setAlpha(mAlpha);
+ }
+ }
+
+ bool valid;
+ const int alpha = mAlpha * 255;
gcn::Color faceColor = getBaseColor();
faceColor.a = alpha;
- gcn::Color highlightColor = faceColor + 0x303030;
+ gcn::Color highlightColor = textColour->getColour('H', valid);
highlightColor.a = alpha;
gcn::Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
+ if (mOpaque)
+ {
+ int red = getBackgroundColor().r;
+ int green = getBackgroundColor().g;
+ int blue = getBackgroundColor().b;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h));
+
+ red = getForegroundColor().r;
+ green = getForegroundColor().g;
+ blue = getForegroundColor().b;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ }
- graphics->setColor(getBackgroundColor());
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h));
-
- graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
if (mListBox->getListModel() && mListBox->getSelected() >= 0)
@@ -140,7 +176,7 @@ void DropDown::draw(gcn::Graphics* graphics)
{
drawChildren(graphics);
- // Draw two lines separating the ListBox with se selected
+ // Draw two lines separating the ListBox with selected
// element view.
graphics->setColor(highlightColor);
graphics->drawLine(0, h, getWidth(), h);
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 25ae05f8..e5919dc7 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -22,15 +22,8 @@
#ifndef DROPDOWN_H
#define DROPDOWN_H
-#include <iosfwd>
-
#include <guichan/widgets/dropdown.hpp>
-#include "../listbox.h"
-#include "../scrollarea.h"
-
-#include "../../guichanfwd.h"
-
class Image;
class ImageRect;
@@ -56,7 +49,8 @@ class DropDown : public gcn::DropDown
*/
DropDown(gcn::ListModel *listModel = NULL,
gcn::ScrollArea *scrollArea = NULL,
- gcn::ListBox *listBox = NULL);
+ gcn::ListBox *listBox = NULL,
+ bool opacity = true);
/**
* Destructor.
@@ -67,6 +61,22 @@ class DropDown : public gcn::DropDown
void drawFrame(gcn::Graphics* graphics);
+ /**
+ * Sets the widget to be opaque, that is sets the widget to display its
+ * background.
+ *
+ * @param opaque True if the widget should be opaque, false otherwise.
+ */
+ void setOpaque(bool opaque) {mOpaque = opaque;}
+
+ /**
+ * Checks if the widget is opaque, that is if the widget area displays
+ * its background.
+ *
+ * @return True if the widget is opaque, false otherwise.
+ */
+ bool isOpaque() const {return mOpaque;}
+
protected:
/**
@@ -80,6 +90,9 @@ class DropDown : public gcn::DropDown
static int instances;
static Image *buttons[2][2];
static ImageRect skin;
+ static float mAlpha;
+
+ bool mOpaque;
};
#endif // end DROPDOWN_H
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index 4b8bb4da..fa264e37 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -23,6 +23,7 @@
#include "resizegrip.h"
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -30,6 +31,7 @@
Image *ResizeGrip::gripImage = 0;
int ResizeGrip::mInstances = 0;
+float ResizeGrip::mAlpha = config.getValue("guialpha", 0.8);
ResizeGrip::ResizeGrip(std::string image)
{
@@ -38,6 +40,7 @@ ResizeGrip::ResizeGrip(std::string image)
// Load the grip image
ResourceManager *resman = ResourceManager::getInstance();
gripImage = resman->getImage(image);
+ gripImage->setAlpha(mAlpha);
}
mInstances++;
@@ -58,5 +61,11 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ gripImage->setAlpha(mAlpha);
+ }
+
static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
}
diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h
index 7f1329a2..620c133f 100644
--- a/src/gui/widgets/resizegrip.h
+++ b/src/gui/widgets/resizegrip.h
@@ -24,8 +24,6 @@
#include <guichan/widget.hpp>
-#include "../../guichanfwd.h"
-
class Image;
/**
@@ -56,6 +54,7 @@ class ResizeGrip : public gcn::Widget
private:
static Image *gripImage; /**< Resize grip image */
static int mInstances; /**< Number of resize grip instances */
+ static float mAlpha;
};
#endif
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index c54b2390..22e952e7 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -19,12 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
+#include <guichan/widgets/label.hpp>
#include "tab.h"
-
#include "tabbedarea.h"
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -33,6 +33,7 @@
#include "../../utils/dtor.h"
int Tab::mInstances = 0;
+float Tab::mAlpha = config.getValue("guialpha", 0.8);
enum{
TAB_STANDARD, // 0
@@ -79,6 +80,7 @@ Tab::~Tab()
void Tab::init()
{
setFrameSize(0);
+ mHighlighted = false;
if (mInstances == 0)
{
@@ -98,6 +100,7 @@ void Tab::init()
data[x].gridX, data[y].gridY,
data[x + 1].gridX - data[x].gridX + 1,
data[y + 1].gridY - data[y].gridY + 1);
+ tabImg[mode].grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -109,16 +112,33 @@ void Tab::init()
void Tab::draw(gcn::Graphics *graphics)
{
- int mode;
+ int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea && mTabbedArea->isTabSelected(this))
+ if (mTabbedArea)
{
- mode = TAB_SELECTED;
+ if(mTabbedArea->isTabSelected(this))
+ {
+ mode = TAB_SELECTED;
+ // if tab is selected, it doesnt need to highlight activity
+ mLabel->setForegroundColor(gcn::Color(0, 0, 0));
+ mHighlighted = false;
+ }
+ else if (mHighlighted)
+ {
+ mode = TAB_HIGHLIGHTED;
+ mLabel->setForegroundColor(gcn::Color(255, 0, 0));
+ }
}
- else
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
{
- mode = TAB_STANDARD;
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ tabImg[TAB_SELECTED].grid[a]->setAlpha(mAlpha);
+ tabImg[TAB_STANDARD].grid[a]->setAlpha(mAlpha);
+ }
}
// draw tab
@@ -128,3 +148,8 @@ void Tab::draw(gcn::Graphics *graphics)
// draw label
drawChildren(graphics);
}
+
+void Tab::setHighlighted(bool high)
+{
+ mHighlighted = high;
+}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 8382df83..3af4e2bf 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -47,12 +47,20 @@ class Tab : public gcn::Tab
*/
void draw(gcn::Graphics *graphics);
+ /**
+ * Set tab highlighted
+ */
+ void setHighlighted(bool high);
+
private:
/** Load images if no other instances exist yet */
void init();
static ImageRect tabImg[4]; /**< Tab state graphics */
static int mInstances; /**< Number of tab instances */
+ static float mAlpha;
+
+ bool mHighlighted;
};
#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index e97e9416..797b4be9 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -25,10 +25,7 @@
#include <guichan/exception.hpp>
-#include <guichan/widgets/icon.hpp>
-
#include "gui.h"
-#include "gccontainer.h"
#include "window.h"
#include "windowcontainer.h"
@@ -37,7 +34,6 @@
#include "../configlistener.h"
#include "../configuration.h"
-#include "../graphics.h"
#include "../log.h"
#include "../resources/image.h"
@@ -58,9 +54,6 @@ class WindowConfigListener : public ConfigListener
void optionChanged(const std::string &)
{
Window::mAlphaChanged = true;
-// for_each(Window::border.grid, Window::border.grid + 9,
-// std::bind2nd(std::mem_fun(&Image::setAlpha),
-// config.getValue("guialpha", 0.8)));
}
};
@@ -195,6 +188,15 @@ void Window::draw(gcn::Graphics *graphics)
getPadding()
);
}
+
+ // Update window alpha values
+ if (mAlphaChanged)
+ {
+ for_each(border.grid, border.grid + 9,
+ std::bind2nd(std::mem_fun(&Image::setAlpha),
+ config.getValue("guialpha", 0.8)));
+ closeImage->setAlpha(config.getValue("guialpha", 0.8));
+ }
drawChildren(graphics);
}
diff --git a/src/gui/windowcontainer.h b/src/gui/windowcontainer.h
index a3e80223..62704d1b 100644
--- a/src/gui/windowcontainer.h
+++ b/src/gui/windowcontainer.h
@@ -24,15 +24,14 @@
#include <guichan/widgets/container.hpp>
-#include "../guichanfwd.h"
-
/**
* A window container. This container adds functionality for more convenient
* widget (windows in particular) destruction.
*
* \ingroup GUI
*/
-class WindowContainer : public gcn::Container {
+class WindowContainer : public gcn::Container
+{
public:
/**
* Do GUI logic. This functions adds automatic deletion of objects that