summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/changeemaildialog.cpp3
-rw-r--r--src/gui/changepassworddialog.cpp3
-rw-r--r--src/gui/charcreatedialog.cpp14
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/chatwindow.cpp4
-rw-r--r--src/gui/confirmdialog.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/editserverdialog.cpp5
-rw-r--r--src/gui/editserverdialog.h3
-rw-r--r--src/gui/equipmentwindow.cpp10
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/minimap.cpp46
-rw-r--r--src/gui/minimap.h2
-rw-r--r--src/gui/npcdialog.cpp16
-rw-r--r--src/gui/npcdialog.h2
-rw-r--r--src/gui/okdialog.cpp10
-rw-r--r--src/gui/okdialog.h11
-rw-r--r--src/gui/outfitwindow.cpp2
-rw-r--r--src/gui/popupmenu.cpp39
-rw-r--r--src/gui/popupmenu.h2
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/sdlinput.h3
-rw-r--r--src/gui/serverdialog.cpp4
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup_audio.cpp226
-rw-r--r--src/gui/setup_audio.h19
-rw-r--r--src/gui/setup_joystick.cpp31
-rw-r--r--src/gui/setup_keyboard.cpp2
-rw-r--r--src/gui/setup_other.cpp5
-rw-r--r--src/gui/setup_relations.cpp8
-rw-r--r--src/gui/setup_theme.cpp33
-rw-r--r--src/gui/setup_video.cpp246
-rw-r--r--src/gui/setup_video.h30
-rw-r--r--src/gui/setup_visual.cpp118
-rw-r--r--src/gui/setup_visual.h50
-rw-r--r--src/gui/shopwindow.cpp2
-rw-r--r--src/gui/socialwindow.cpp6
-rw-r--r--src/gui/textcommandeditor.cpp6
-rw-r--r--src/gui/theme.cpp19
-rw-r--r--src/gui/theme.h2
-rw-r--r--src/gui/unregisterdialog.cpp3
-rw-r--r--src/gui/updaterwindow.cpp32
-rw-r--r--src/gui/viewport.cpp23
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/whoisonline.cpp8
-rw-r--r--src/gui/widgets/avatarlistbox.cpp3
-rw-r--r--src/gui/widgets/browserbox.cpp22
-rw-r--r--src/gui/widgets/browserbox.h3
-rw-r--r--src/gui/widgets/button.cpp190
-rw-r--r--src/gui/widgets/button.h31
-rw-r--r--src/gui/widgets/chattab.cpp21
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/gui/widgets/flowcontainer.h3
-rw-r--r--src/gui/widgets/guildchattab.cpp6
-rw-r--r--src/gui/widgets/guildchattab.h2
-rw-r--r--src/gui/widgets/guitable.cpp9
-rw-r--r--src/gui/widgets/horizontcontainer.cpp7
-rw-r--r--src/gui/widgets/horizontcontainer.h2
-rw-r--r--src/gui/widgets/linkhandler.h3
-rw-r--r--src/gui/widgets/listbox.cpp10
-rw-r--r--src/gui/widgets/listbox.h2
-rw-r--r--src/gui/widgets/namesmodel.cpp51
-rw-r--r--src/gui/widgets/namesmodel.h51
-rw-r--r--src/gui/widgets/setupitem.cpp416
-rw-r--r--src/gui/widgets/setupitem.h149
-rw-r--r--src/gui/widgets/setuptabscroll.cpp9
-rw-r--r--src/gui/widgets/setuptabscroll.h4
-rw-r--r--src/gui/widgets/sliderlist.cpp216
-rw-r--r--src/gui/widgets/sliderlist.h83
-rw-r--r--src/gui/widgets/tablemodel.h3
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/worldselectdialog.cpp3
72 files changed, 1791 insertions, 574 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 518ed3da1..1a468d44f 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -154,7 +154,8 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
else if (error == 2)
mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
+ OkDialog *dlg = new OkDialog(_("Error"),
+ errorMsg.str(), DIALOG_ERROR);
if (dlg)
dlg->addActionListener(mWrongDataNoticeListener);
}
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 8082b8d58..a58d8616b 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -144,7 +144,8 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
else if (error == 3)
mWrongDataNoticeListener->setTarget(this->mSecondPassField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
+ OkDialog *dlg = new OkDialog(_("Error"),
+ errorMsg.str(), DIALOG_ERROR);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 8d4767a15..124476f1c 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -270,8 +270,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
else
{
new OkDialog(_("Error"),
- _("Your name needs to be at least 4 characters."),
- true, this);
+ _("Your name needs to be at least 4 characters."),
+ DIALOG_ERROR, true, this);
}
}
else if (id == "cancel")
@@ -474,8 +474,11 @@ void CharCreateDialog::updateHair()
mHairStyle %= Being::getNumOfHairstyles();
if (mHairStyle < 0)
mHairStyle += Being::getNumOfHairstyles();
- if (mHairStyle < (signed)minHairStyle || mHairStyle > (signed)maxHairStyle)
+ if (mHairStyle < static_cast<signed>(minHairStyle)
+ || mHairStyle > static_cast<signed>(maxHairStyle))
+ {
mHairStyle = minHairStyle;
+ }
const ItemInfo &item = ItemDB::get(-mHairStyle);
mHairStyleNameLabel->setCaption(item.getName());
mHairStyleNameLabel->adjustSize();
@@ -483,8 +486,11 @@ void CharCreateDialog::updateHair()
mHairColor %= ColorDB::getHairSize();
if (mHairColor < 0)
mHairColor += ColorDB::getHairSize();
- if (mHairColor < (signed)minHairColor || mHairColor > (signed)maxHairColor)
+ if (mHairColor < static_cast<signed>(minHairColor)
+ || mHairColor > static_cast<signed>(maxHairColor))
+ {
mHairColor = minHairColor;
+ }
mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor));
mHairColorNameLabel->adjustSize();
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index d2b74a632..b1b8009a4 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -253,7 +253,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
}
else
{
- new OkDialog(_("Error"), _("Incorrect password"));
+ new OkDialog(_("Error"), _("Incorrect password"), DIALOG_ERROR);
}
mDeleteIndex = -1;
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 69e4d703f..eb8669223 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -133,7 +133,8 @@ const char *COLOR_NAME[14] =
class ColorListModel : public gcn::ListModel
{
public:
- virtual ~ColorListModel() { }
+ virtual ~ColorListModel()
+ { }
virtual int getNumberOfElements()
{
@@ -306,6 +307,7 @@ void ChatWindow::fillCommands()
mCommands.push_back("/serverunignoreall");
mCommands.push_back("/dumpg");
mCommands.push_back("/dumpt");
+ mCommands.push_back("/dumpogl");
mCommands.push_back("/pseudoaway ");
mCommands.push_back("<PLAYER>");
mCommands.push_back("<MONSTER>");
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index 22acf5116..a2fb7b6cc 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -97,7 +97,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
}
setVisible(true);
yesButton->requestFocus();
- sound.playGuiSfx("system/newmessage.ogg");
+ sound.playGuiSound(SOUND_REQUEST);
}
void ConfirmDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index b65068dc5..fa01b5aa8 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -390,7 +390,7 @@ void NetDebugTab::logic()
if (player_node && player_node->getPingTime() != 0)
{
mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
- toString((int)player_node->getPingTime()).c_str()));
+ toString(static_cast<int>(player_node->getPingTime())).c_str()));
}
else
{
diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp
index 8a4a9579d..ca1afeaba 100644
--- a/src/gui/editserverdialog.cpp
+++ b/src/gui/editserverdialog.cpp
@@ -173,7 +173,7 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
{
OkDialog *dlg = new OkDialog(_("Error"),
_("Please at least type both the address and the port "
- "of the server."));
+ "of the server."), DIALOG_ERROR);
dlg->addActionListener(this);
}
else
@@ -184,7 +184,8 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
mServer.name = mNameField->getText();
mServer.description = mDescriptionField->getText();
mServer.hostname = mServerAddressField->getText();
- mServer.port = (short) atoi(mPortField->getText().c_str());
+ mServer.port = static_cast<short>(atoi(
+ mPortField->getText().c_str()));
if (mTypeField)
{
diff --git a/src/gui/editserverdialog.h b/src/gui/editserverdialog.h
index 6035b0e50..4ad6b8fcb 100644
--- a/src/gui/editserverdialog.h
+++ b/src/gui/editserverdialog.h
@@ -44,7 +44,8 @@ class TypeListModel;
class TypeListModel : public gcn::ListModel
{
public:
- TypeListModel() {}
+ TypeListModel()
+ { }
/**
* Used to get number of line in the list
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 275bf19bb..89063c3dc 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -407,8 +407,11 @@ void EquipmentWindow::loadSlot(XmlNodePtr slotNode, ImageSet *imageset)
const int imageIndex = XML::getProperty(slotNode, "image", -1);
Image *image = nullptr;
- if (imageset && imageIndex >= 0 && imageIndex < (signed)imageset->size())
+ if (imageset && imageIndex >= 0 && imageIndex
+ < static_cast<signed>(imageset->size()))
+ {
image = imageset->get(imageIndex);
+ }
if (mBoxes[slot])
{
@@ -510,8 +513,11 @@ void EquipmentWindow::addBox(int idx, int x, int y, int imageIndex)
{
Image *image = nullptr;
- if (mImageSet && imageIndex >= 0 && imageIndex < (signed)mImageSet->size())
+ if (mImageSet && imageIndex >= 0 && imageIndex
+ < static_cast<signed>(mImageSet->size()))
+ {
image = mImageSet->get(imageIndex);
+ }
mBoxes[idx] = new EquipmentBox(x + getPadding(), y + getTitleBarHeight(),
image);
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index d96aa564f..f33f77e83 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -123,7 +123,7 @@ void ItemPopup::setItem(const Item *item, bool showImage)
}
mItemName->adjustSize();
unsigned minWidth = mItemName->getWidth() + 8;
- if ((unsigned)getWidth() < minWidth)
+ if (static_cast<unsigned>(getWidth()) < minWidth)
setWidth(minWidth);
}
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 74da37341..b76e71069 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -60,7 +60,7 @@ Minimap::Minimap():
setDefaultSize(5, 25, 100, 100);
// set this to false as the minimap window size is changed
//depending on the map size
- setResizable(false);
+ setResizable(true);
setupWindow->registerWindowForReset(this);
setDefaultVisible(true);
@@ -229,13 +229,11 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapImage->mBounds.h > a.height)
{
const Vector &p = player_node->getPosition();
- mMapOriginX = ((a.width) / 2) - static_cast<int>((p.x
- + viewport->getCameraRelativeX()) * static_cast<int>(
- mWidthProportion)) / 32;
+ mMapOriginX = ((a.width) / 2) - (static_cast<float>(p.x
+ + viewport->getCameraRelativeX()) * mWidthProportion) / 32;
- mMapOriginY = ((a.height) / 2) - static_cast<int>((p.y
- + viewport->getCameraRelativeX()) * static_cast<int>(
- mHeightProportion)) / 32;
+ mMapOriginY = ((a.height) / 2) - (static_cast<float>(p.y
+ + viewport->getCameraRelativeX()) * mHeightProportion) / 32;
const int minOriginX = a.width - mMapImage->mBounds.w;
const int minOriginY = a.height - mMapImage->mBounds.h;
@@ -314,9 +312,9 @@ void Minimap::draw(gcn::Graphics *graphics)
const Vector &pos = being->getPosition();
graphics->fillRectangle(gcn::Rectangle(
- static_cast<int>(pos.x * mWidthProportion) / 32
+ static_cast<float>(pos.x * mWidthProportion) / 32
+ mMapOriginX - offsetWidth,
- static_cast<int>(pos.y * mHeightProportion) / 32
+ static_cast<float>(pos.y * mHeightProportion) / 32
+ mMapOriginY - offsetHeight,
dotSize, dotSize));
}
@@ -367,10 +365,10 @@ void Minimap::draw(gcn::Graphics *graphics)
const Vector &pos = player_node->getPosition();
// logger->log("width:" + toString(graph->getWidth()));
- int x = static_cast<int>((pos.x - (graph->getWidth() / 2)
+ int x = static_cast<float>((pos.x - (graph->getWidth() / 2)
+ viewport->getCameraRelativeX())
* mWidthProportion) / 32 + mMapOriginX;
- int y = static_cast<int>((pos.y - (graph->getHeight() / 2)
+ int y = static_cast<float>((pos.y - (graph->getHeight() / 2)
+ viewport->getCameraRelativeY())
* mHeightProportion) / 32 + mMapOriginY;
@@ -403,17 +401,29 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
{
gcn::Window::mouseReleased(event);
- if (!player_node)
+ if (!player_node || !viewport)
return;
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- const gcn::Rectangle a = getChildrenArea();
- const int x = event.getX() - a.x;
- const int y = event.getY() - a.y;
+ int x = event.getX();
+ int y = event.getY();
+ screenToMap(x, y);
- player_node->navigateTo((x - mMapOriginX + mWidthProportion)
- / mWidthProportion, (y - mMapOriginY + mHeightProportion)
- / mHeightProportion);
+ player_node->navigateTo(x, y);
}
+ else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ int x = event.getX();
+ int y = event.getY();
+ screenToMap(x, y);
+ viewport->showMapPopup(x, y);
+ }
+}
+
+void Minimap::screenToMap(int &x, int &y)
+{
+ const gcn::Rectangle a = getChildrenArea();
+ x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
+ y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 8b7da5849..12835edd5 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -60,6 +60,8 @@ class Minimap : public Window
void mouseReleased(gcn::MouseEvent &event);
+ void screenToMap(int &x, int &y);
+
private:
Image *mMapImage;
float mWidthProportion;
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 3e5b30a9c..12b3e1244 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -78,7 +78,7 @@ NpcDialog::NpcDialog(int npcId) :
setMinWidth(200);
setMinHeight(150);
- setDefaultSize(260, 200, ImageRect::CENTER);
+ setDefaultSize(400, 400, ImageRect::CENTER);
mItemLinkHandler = new ItemLinkHandler;
// Setup output text box
@@ -342,9 +342,20 @@ void NpcDialog::parseListItems(const std::string &itemString)
mItems.push_back(tmp);
if (!mItems.empty())
+ {
mItemList->setSelected(0);
+ mItemList->requestFocus();
+ }
else
+ {
mItemList->setSelected(-1);
+ }
+}
+
+void NpcDialog::refocus()
+{
+ if (!mItems.empty())
+ mItemList->refocus();
}
void NpcDialog::textRequest(const std::string &defaultText)
@@ -363,7 +374,8 @@ bool NpcDialog::isTextInputFocused() const
bool NpcDialog::isInputFocused() const
{
- return mTextField->isFocused() || mIntField->isFocused();
+ return mTextField->isFocused() || mIntField->isFocused()
+ || mItemList->isFocused();
}
bool NpcDialog::isAnyInputFocused()
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index d4288d5c9..7bd2ee76d 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -177,6 +177,8 @@ class NpcDialog : public Window, public gcn::ActionListener,
void restoreCamera();
+ void refocus();
+
private:
typedef std::list<NpcDialog*> DialogList;
static DialogList instances;
diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp
index 4a3bdf731..3259cb6d6 100644
--- a/src/gui/okdialog.cpp
+++ b/src/gui/okdialog.cpp
@@ -22,6 +22,8 @@
#include "gui/okdialog.h"
+#include "sound.h"
+
#include "gui/gui.h"
#include "gui/widgets/button.h"
@@ -34,7 +36,8 @@
#include "debug.h"
OkDialog::OkDialog(const std::string &title, const std::string &msg,
- bool modal, bool showCenter, Window *parent):
+ int soundEvent, bool modal, bool showCenter,
+ Window *parent):
Window(title, modal, parent, "ok.xml")
{
mTextBox = new TextBox;
@@ -71,6 +74,11 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
centerHorisontally();
setVisible(true);
okButton->requestFocus();
+
+ if (soundEvent == DIALOG_OK)
+ sound.playGuiSound(SOUND_INFO);
+ else if (soundEvent == DIALOG_ERROR)
+ sound.playGuiSound(SOUND_ERROR);
}
void OkDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h
index 5705be568..b6f17480b 100644
--- a/src/gui/okdialog.h
+++ b/src/gui/okdialog.h
@@ -31,6 +31,13 @@
class TextBox;
+enum
+{
+ DIALOG_OK = 0,
+ DIALOG_ERROR,
+ DIALOG_SILENCE
+};
+
/**
* An 'Ok' button dialog.
*
@@ -45,8 +52,8 @@ class OkDialog : public Window, public gcn::ActionListener
* @see Window::Window
*/
OkDialog(const std::string &title, const std::string &msg,
- bool modal = true, bool showCenter = true,
- Window *parent = nullptr);
+ int soundEvent = DIALOG_OK, bool modal = true,
+ bool showCenter = true, Window *parent = nullptr);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 73484f1d5..6eaa2ac4e 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -190,7 +190,7 @@ void OutfitWindow::save()
outfitStr += toString(res);
if (i < OUTFIT_ITEM_COUNT - 1)
outfitStr += " ";
- outfitColorsStr += toString((int)mItemColors[o][i]);
+ outfitColorsStr += toString(static_cast<int>(mItemColors[o][i]));
if (i < OUTFIT_ITEM_COUNT - 1)
outfitColorsStr += " ";
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index c987843d3..5e5f310dc 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -579,6 +579,25 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
showPopup(x, y);
}
+void PopupMenu::showMapPopup(int x, int y, int x2, int y2)
+{
+ mX = x2;
+ mY = y2;
+
+ mBrowserBox->clearRows();
+
+ mBrowserBox->addRow(_("Map Item"));
+
+ if (player_node && player_node->isGM())
+ mBrowserBox->addRow("warp map", _("Warp"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("movecamera", _("Move camera"));
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("cancel", _("Cancel"));
+
+ showPopup(x, y);
+}
+
void PopupMenu::showOutfitsPopup(int x, int y)
{
mX = x;
@@ -1161,6 +1180,16 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
+ else if (link == "move" && (mX || mY))
+ {
+ if (player_node)
+ player_node->navigateTo(mX, mY);
+ }
+ else if (link == "movecamera" && (mX || mY))
+ {
+ if (viewport)
+ viewport->moveCameraToPosition(mX * 32, mY * 32);
+ }
else if (link == "split" && mItem)
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit,
@@ -1304,6 +1333,14 @@ void PopupMenu::handleLink(const std::string &link,
mMapItem->getX(), mMapItem->getY());
}
}
+ else if (link == "warp map" && (mX || mY))
+ {
+ if (Game::instance())
+ {
+ Net::getAdminHandler()->warp(Game::instance()->getCurrentMapName(),
+ mX, mY);
+ }
+ }
else if (link == "remove map" && mMapItem)
{
if (viewport)
@@ -2205,7 +2242,7 @@ void PlayerListener::action(const gcn::ActionEvent &event)
{
std::string comment = mDialog->getText();
Being* being = actorSpriteManager->findBeingByName(
- mNick, (ActorSprite::Type)mType);
+ mNick, static_cast<ActorSprite::Type>(mType));
if (being)
being->setComment(comment);
Being::saveComment(mNick, comment, mType);
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 8b9107300..f616e46ee 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -142,6 +142,8 @@ class PopupMenu : public Popup, public LinkHandler
void showUndressPopup(int x, int y, Being *being, Item *item);
+ void showMapPopup(int x, int y, int x2, int y2);
+
/**
* Shows the related popup menu when right click on the chat
* at the specified mouse coordinates.
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 2122e0d6b..bf0cb299e 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *dlg = new OkDialog(_("Error"), errorMsg);
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg, DIALOG_ERROR);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index 17cb4ea8a..f68612793 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -147,7 +147,8 @@ public:
* only use SDL and plan sticking with SDL you can safely ignore this
* function as it in the SDL case does nothing.
*/
- virtual void _pollInput() { }
+ virtual void _pollInput()
+ { }
// Inherited from Input
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index da61e105b..ed9696892 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -125,7 +125,7 @@ std::string ServersListModel::getElementAt(int elementIndex)
void ServersListModel::setVersionString(int index, const std::string &version)
{
- if (index >= (int)mVersionStrings.size())
+ if (index >= static_cast<int>(mVersionStrings.size()))
return;
if (version.empty())
@@ -632,7 +632,7 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
// Make sure the current server is mentioned first
if (currentServer.isValid())
{
- if (index >= 0 && (unsigned)index < mServers.size())
+ if (index >= 0 && static_cast<unsigned>(index) < mServers.size())
{
mServers[index] = currentServer;
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 3408fba33..c7908a6ac 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -38,6 +38,7 @@
#include "gui/setup_players.h"
#include "gui/setup_relations.h"
#include "gui/setup_video.h"
+#include "gui/setup_visual.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -92,6 +93,7 @@ Setup::Setup():
mPanel->enableScrollButtons(true);
mTabs.push_back(new Setup_Video);
+ mTabs.push_back(new Setup_Visual);
mTabs.push_back(new Setup_Audio);
mTabs.push_back(new Setup_Perfomance);
mTabs.push_back(new Setup_Joystick);
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index bc058faf9..69ca4e759 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -23,179 +23,125 @@
#include "gui/setup_audio.h"
#include "configuration.h"
-#include "logger.h"
#include "sound.h"
-#include "gui/okdialog.h"
+#include "gui/theme.h"
#include "gui/viewport.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/slider.h"
+#include "gui/widgets/namesmodel.h"
+#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
#include "utils/gettext.h"
#include "debug.h"
-Setup_Audio::Setup_Audio():
- mMusicVolume(config.getIntValue("musicVolume")),
- mSfxVolume(config.getIntValue("sfxVolume")),
- mAudioEnabled(config.getBoolValue("sound")),
- mGameSoundEnabled(config.getBoolValue("playBattleSound")),
- mGuiSoundEnabled(config.getBoolValue("playGuiSound")),
- mMusicEnabled(config.getBoolValue("playMusic")),
- mMumbleEnabled(config.getBoolValue("enableMumble")),
- mDownloadEnabled(config.getBoolValue("download-music")),
- mAudioCheckBox(new CheckBox(_("Enable Audio"), mAudioEnabled)),
- mGameSoundCheckBox(new CheckBox(_("Enable game sfx"), mGameSoundEnabled)),
- mGuiSoundCheckBox(new CheckBox(_("Enable gui sfx"), mGuiSoundEnabled)),
- mMusicCheckBox(new CheckBox(_("Enable music"), mMusicEnabled)),
- mMumbleCheckBox(new CheckBox(_("Enable mumble voice chat"),
- mMumbleEnabled)),
- mDownloadMusicCheckBox(new CheckBox(_("Download music"),
- mDownloadEnabled)),
- mSfxSlider(new Slider(0, sound.getMaxVolume())),
- mMusicSlider(new Slider(0, sound.getMaxVolume()))
+class SoundsModel : public NamesModel
+{
+public:
+ SoundsModel()
+ {
+ mNames.push_back(gettext("(no sound)"));
+ Theme::fillSoundsList(mNames);
+ }
+
+ virtual ~SoundsModel()
+ { }
+};
+
+Setup_Audio::Setup_Audio()
{
setName(_("Audio"));
- setDimension(gcn::Rectangle(0, 0, 250, 200));
- gcn::Label *sfxLabel = new Label(_("Sfx volume"));
- gcn::Label *musicLabel = new Label(_("Music volume"));
+ // Do the layout
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+ place(0, 0, mScroll, 10, 10);
+
+ mSoundModel = new SoundsModel();
- mSfxSlider->setActionEventId("sfx");
- mMusicSlider->setActionEventId("music");
+ new SetupItemLabel(_("Basic settings"), "", this);
- mSfxSlider->addActionListener(this);
- mMusicSlider->addActionListener(this);
+ new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent");
- mAudioCheckBox->setPosition(10, 10);
+ new SetupItemCheckBox(_("Enable music"), "",
+ "playMusic", this, "playMusicEvent");
- mSfxSlider->setValue(mSfxVolume);
- mMusicSlider->setValue(mMusicVolume);
+ new SetupItemCheckBox(_("Enable game sfx"), "",
+ "playBattleSound", this, "playBattleSoundEvent");
- mSfxSlider->setWidth(90);
- mMusicSlider->setWidth(90);
+ new SetupItemCheckBox(_("Enable gui sfx"), "",
+ "playGuiSound", this, "playGuiSoundEvent");
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
+ new SetupItemSlider(_("Sfx volume"), "", "sfxVolume",
+ this, "sfxVolumeEvent", 0, sound.getMaxVolume(), 150, true);
+
+ new SetupItemSlider(_("Music volume"), "", "musicVolume",
+ this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true);
+
+ new SetupItemLabel(_("Sound effects"), "", this);
+
+ new SetupItemSound(_("Information dialog sound"), "",
+ "soundinfo", this, "soundinfoEvent", mSoundModel);
+
+ new SetupItemSound(_("Request dialog sound"), "",
+ "soundrequest", this, "soundrequestEvent", mSoundModel);
+
+ new SetupItemSound(_("Whisper message sound"), "",
+ "soundwhisper", this, "soundwhisperEvent", mSoundModel);
+
+ new SetupItemSound(_("Guild / Party message sound"), "",
+ "soundguild", this, "soundguildEvent", mSoundModel);
+
+ new SetupItemSound(_("Highlight message sound"), "",
+ "soundhighlight", this, "soundhighlightEvent", mSoundModel);
+
+ new SetupItemSound(_("Global message sound"), "",
+ "soundglobal", this, "soundglobalEvent", mSoundModel);
+
+ new SetupItemSound(_("Error message sound"), "",
+ "sounderror", this, "sounderrorEvent", mSoundModel);
+
+ new SetupItemSound(_("Trade request sound"), "",
+ "soundtrade", this, "soundtradeEvent", mSoundModel);
+
+ new SetupItemLabel(_("Other"), "", this);
+
+ new SetupItemCheckBox(_("Enable mumble voice chat"), "",
+ "enableMumble", this, "enableMumbleEvent");
- place(0, 0, mAudioCheckBox);
- place(0, 1, mMusicCheckBox);
- place(0, 2, mGameSoundCheckBox);
- place(0, 3, mGuiSoundCheckBox);
- place(0, 4, mSfxSlider);
- place(1, 4, sfxLabel);
- place(0, 5, mMusicSlider);
- place(1, 5, musicLabel);
- place(0, 6, mMumbleCheckBox);
- place(0, 7, mDownloadMusicCheckBox);
-
- setDimension(gcn::Rectangle(0, 0, 365, 280));
+ new SetupItemCheckBox(_("Download music"), "",
+ "download-music", this, "download-musicEvent");
+
+ setDimension(gcn::Rectangle(0, 0, 550, 350));
}
-void Setup_Audio::apply()
+Setup_Audio::~Setup_Audio()
{
- mAudioEnabled = mAudioCheckBox->isSelected();
- mGameSoundEnabled = mGameSoundCheckBox->isSelected();
- mGuiSoundEnabled = mGuiSoundCheckBox->isSelected();
- mMusicEnabled = mMusicCheckBox->isSelected();
- mMumbleEnabled = mMumbleCheckBox->isSelected();
- mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
- mSfxVolume = config.getIntValue("sfxVolume");
- mMusicVolume = config.getIntValue("musicVolume");
-
- config.setValue("sound", mAudioEnabled);
- config.setValue("playBattleSound", mGameSoundEnabled);
- config.setValue("playGuiSound", mGuiSoundEnabled);
-
- config.setValue("enableMumble", mMumbleEnabled);
-
- // Display a message if user has selected to download music,
- // And if downloadmusic is not already enabled
- if (mDownloadEnabled && !config.getBoolValue("download-music"))
- {
- new OkDialog(_("Notice"), _("You may have to restart your client "
- "if you want to download new music"));
- }
- config.setValue("download-music", mDownloadEnabled);
+ delete mSoundModel;
+ mSoundModel = nullptr;
+}
- if (mAudioEnabled)
+void Setup_Audio::apply()
+{
+ SetupTabScroll::apply();
+ if (config.getBoolValue("sound"))
{
- try
- {
- sound.init();
- }
- catch (const char *err)
+ sound.init();
+ if (viewport && config.getBoolValue("playMusic"))
{
- new OkDialog(_("Sound Engine"), err);
- logger->log("Warning: %s", err);
+ Map *map = viewport->getMap();
+ if (map)
+ sound.playMusic(map->getMusicFile());
}
- if (mMusicEnabled)
- {
- if (viewport && !config.getBoolValue("playMusic"))
- {
- Map *map = viewport->getMap();
- if (map)
- {
- config.setValue("playMusic", mMusicEnabled);
- sound.playMusic(map->getMusicFile());
- }
- }
- }
- else if (config.getBoolValue("playMusic"))
+ else
{
sound.stopMusic();
}
-
}
else
{
sound.close();
}
-
- config.setValue("playMusic", mMusicEnabled);
-}
-
-void Setup_Audio::cancel()
-{
- mAudioCheckBox->setSelected(mAudioEnabled);
- mGameSoundCheckBox->setSelected(mGameSoundEnabled);
- mGuiSoundCheckBox->setSelected(mGuiSoundEnabled);
- mMusicCheckBox->setSelected(mMusicEnabled);
- mMumbleCheckBox->setSelected(mMumbleEnabled);
- mDownloadMusicCheckBox->setSelected(mDownloadEnabled);
-
- sound.setSfxVolume(mSfxVolume);
- mSfxSlider->setValue(mSfxVolume);
-
- sound.setMusicVolume(mMusicVolume);
- mMusicSlider->setValue(mMusicVolume);
-
- config.setValue("sound", mAudioEnabled);
- config.setValue("playBattleSound", mGameSoundEnabled);
- config.setValue("playGuiSound", mGuiSoundEnabled);
- config.setValue("enableMumble", mMumbleEnabled);
- config.setValue("download-music", mDownloadEnabled);
- config.setValue("sfxVolume", mSfxVolume);
- config.setValue("musicVolume", mMusicVolume);
- config.setValue("playMusic", mMusicEnabled);
-}
-
-void Setup_Audio::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "sfx")
- {
- config.setValueInt("sfxVolume",
- static_cast<int>(mSfxSlider->getValue()));
- sound.setSfxVolume(static_cast<int>(mSfxSlider->getValue()));
- }
- else if (event.getId() == "music")
- {
- config.setValueInt("musicVolume",
- static_cast<int>(mMusicSlider->getValue()));
- sound.setMusicVolume(static_cast<int>(mMusicSlider->getValue()));
- }
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 88869d730..21b661bcb 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -25,30 +25,21 @@
#include "guichanfwd.h"
-#include "gui/widgets/setuptab.h"
+#include "gui/widgets/setuptabscroll.h"
#include <guichan/actionlistener.hpp>
-class Setup_Audio : public SetupTab
+class Setup_Audio : public SetupTabScroll
{
public:
Setup_Audio();
- void apply();
- void cancel();
+ ~Setup_Audio();
- void action(const gcn::ActionEvent &event);
+ void apply();
private:
- int mMusicVolume, mSfxVolume;
- bool mAudioEnabled, mGameSoundEnabled, mGuiSoundEnabled;
- bool mMusicEnabled, mMumbleEnabled;
- bool mDownloadEnabled;
-
- gcn::CheckBox *mAudioCheckBox, *mGameSoundCheckBox, *mGuiSoundCheckBox;
- gcn::CheckBox *mMusicCheckBox, *mMumbleCheckBox;
- gcn::CheckBox *mDownloadMusicCheckBox;
- gcn::Slider *mSfxSlider, *mMusicSlider;
+ gcn::ListModel *mSoundModel;
};
#endif
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index a3240282a..cb3ff9341 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -31,6 +31,7 @@
#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/namesmodel.h"
#include "utils/gettext.h"
@@ -40,32 +41,6 @@
extern Joystick *joystick;
-class NamesModel : public gcn::ListModel
-{
- public:
- NamesModel()
- { }
-
- virtual ~NamesModel()
- { }
-
- virtual int getNumberOfElements()
- {
- return static_cast<int>(mNames.size());
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return _("???");
-
- return mNames[i];
- }
-
- std::vector<std::string> mNames;
-};
-
-
Setup_Joystick::Setup_Joystick():
mCalibrateLabel(new Label(_("Press the button to start calibration"))),
mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
@@ -77,7 +52,7 @@ Setup_Joystick::Setup_Joystick():
{
setName(_("Joystick"));
- Joystick::getNames(mNamesModel->mNames);
+ Joystick::getNames(mNamesModel->getNames());
mOriginalJoystickEnabled = config.getBoolValue("joystickEnabled");
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
@@ -95,7 +70,7 @@ Setup_Joystick::Setup_Joystick():
else
{
unsigned sel = config.getIntValue("selectedJoystick");
- if (sel >= mNamesModel->mNames.size())
+ if (sel >= mNamesModel->size())
sel = 0;
mNamesDropDown->setSelected(sel);
}
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index bdd7c2083..ef024c5d9 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -131,7 +131,7 @@ void Setup_Keyboard::apply()
if (keyboard.hasConflicts())
{
new OkDialog(_("Key Conflict(s) Detected."),
- keyboard.getBindError());
+ keyboard.getBindError(), DIALOG_ERROR);
}
keyboard.setEnabled(true);
keyboard.store();
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 3ea5f4e4a..148037732 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -183,6 +183,11 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Hide shield sprite"), "", "hideShield",
this, "hideShieldEvent");
+#if !defined(_WIN32)
+ new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
+ "", "usefbo", this, "usefboEvent");
+#endif
+
new SetupItemCheckBox(_("Show background"), "", "showBackground",
this, "showBackgroundEvent");
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
index 47d53620c..d9f7a362d 100644
--- a/src/gui/setup_relations.cpp
+++ b/src/gui/setup_relations.cpp
@@ -80,7 +80,8 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
class PlayerRelationListModel : public gcn::ListModel
{
public:
- virtual ~PlayerRelationListModel() { }
+ virtual ~PlayerRelationListModel()
+ { }
virtual int getNumberOfElements()
{
@@ -194,7 +195,7 @@ public:
std::string getPlayerAt(int index) const
{
- if (index < 0 || index >= (signed)mPlayers->size())
+ if (index < 0 || index >= static_cast<signed>(mPlayers->size()))
return "";
return (*mPlayers)[index];
}
@@ -211,7 +212,8 @@ protected:
class IgnoreChoicesListModel : public gcn::ListModel
{
public:
- virtual ~IgnoreChoicesListModel() { }
+ virtual ~IgnoreChoicesListModel()
+ { }
virtual int getNumberOfElements()
{
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index d4a1d5652..7386f496a 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -29,10 +29,11 @@
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/namesmodel.h"
#include "gui/widgets/textfield.h"
-#include "gui/widgets/dropdown.h"
#include "configuration.h"
#include "localplayer.h"
@@ -53,32 +54,6 @@ const char* ACTION_HELP_FONT = "help font";
const char* ACTION_SECURE_FONT = "secure font";
const char* ACTION_JAPAN_FONT = "japan font";
-class NamesModel : public gcn::ListModel
-{
-public:
- NamesModel()
- {
- }
-
- virtual ~NamesModel() { }
-
- virtual int getNumberOfElements()
- {
- return static_cast<int>(mNames.size());
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return _("???");
-
- return mNames[i];
- }
-
-protected:
- std::vector<std::string> mNames;
-};
-
class ThemesModel : public NamesModel
{
public:
@@ -374,8 +349,8 @@ void Setup_Theme::apply()
if (config.getValue("theme",
config.getValue("selectedSkin", "")) != mTheme)
{
- new OkDialog(_("Theme Changed"),
- _("Restart your client for the change to take effect."));
+ new OkDialog(_("Theme Changed"), _("Restart your client for "
+ "the change to take effect."));
}
config.setValue("selectedSkin", "");
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index cc3063a68..24d42c83d 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -28,7 +28,6 @@
#include "localplayer.h"
#include "logger.h"
#include "main.h"
-#include "particle.h"
#include "gui/gui.h"
#include "gui/okdialog.h"
@@ -40,6 +39,7 @@
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
+#include "gui/widgets/sliderlist.h"
#include "gui/widgets/textfield.h"
#include "gui/widgets/dropdown.h"
@@ -214,105 +214,26 @@ public:
}
};
-static const char *speechModeToString(Being::Speech mode)
-{
- switch (mode)
- {
- case Being::NO_SPEECH:
- default:
- return _("No text");
- case Being::TEXT_OVERHEAD:
- return _("Text");
- case Being::NO_NAME_IN_BUBBLE:
- return _("Bubbles, no names");
- case Being::NAME_IN_BUBBLE:
- return _("Bubbles with names");
- }
-}
-
-const char *Setup_Video::overlayDetailToString(int detail)
-{
- if (detail == -1)
- detail = config.getIntValue("OverlayDetail");
-
- switch (detail)
- {
- case 0:
- return _("off");
- case 1:
- return _("low");
- case 2:
- return _("high");
- default:
- return "";
- }
- return "";
-}
-
-const char *Setup_Video::particleDetailToString(int detail)
-{
- if (detail == -1)
- detail = 3 - config.getIntValue("particleEmitterSkip");
-
- switch (detail)
- {
- case 0:
- return _("low");
- case 1:
- return _("medium");
- case 2:
- return _("high");
- case 3:
- return _("max");
- default:
- return "";
- }
- return "";
-}
-
Setup_Video::Setup_Video():
mFullScreenEnabled(config.getBoolValue("screen")),
mOpenGLEnabled(config.getIntValue("opengl")),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
- mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
- mPickupChatEnabled(config.getBoolValue("showpickupchat")),
- mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
- mOpacity(config.getFloatValue("guialpha")),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
mEnableResize(config.getBoolValue("enableresize")),
mNoFrame(config.getBoolValue("noframe")),
- mSpeechMode(static_cast<Being::Speech>(
- config.getIntValue("speech"))),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
mCustomCursorCheckBox(new CheckBox(_("Custom cursor"),
mCustomCursorEnabled)),
- mParticleEffectsCheckBox(new CheckBox(_("Particle effects"),
- mParticleEffectsEnabled)),
- mPickupNotifyLabel(new Label(_("Show pickup notification"))),
- // TRANSLATORS: Refers to "Show own name"
- mPickupChatCheckBox(new CheckBox(_("in chat"), mPickupChatEnabled)),
- // TRANSLATORS: Refers to "Show own name"
- mPickupParticleCheckBox(new CheckBox(_("as particle"),
- mPickupParticleEnabled)),
mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)),
mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)),
- mSpeechSlider(new Slider(0, 3)),
- mSpeechLabel(new Label("")),
- mAlphaSlider(new Slider(0.1, 1.0)),
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(2, 160)),
mFpsLabel(new Label),
mAltFpsSlider(new Slider(2, 160)),
mAltFpsLabel(new Label(_("Alt FPS limit: "))),
- mOverlayDetail(config.getIntValue("OverlayDetail")),
- mOverlayDetailSlider(new Slider(0, 2)),
- mOverlayDetailField(new Label),
- mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
- mParticleDetailSlider(new Slider(0, 3)),
- mParticleDetailField(new Label),
mDialog(nullptr)
{
setName(_("Video"));
@@ -321,11 +242,6 @@ Setup_Video::Setup_Video():
scrollArea->setWidth(150);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- speechLabel = new Label(_("Overhead text"));
- alphaLabel = new Label(_("Gui opacity"));
- overlayDetailLabel = new Label(_("Ambient FX"));
- particleDetailLabel = new Label(_("Particle detail"));
-
mOpenGLListModel = new OpenGLListModel;
mOpenGLDropDown = new DropDown(mOpenGLListModel),
mOpenGLDropDown->setSelected(mOpenGLEnabled);
@@ -336,9 +252,6 @@ Setup_Video::Setup_Video():
mOpenGLDropDown->setSelected(0);
#endif
- mAlphaSlider->setValue(mOpacity);
- mAlphaSlider->setWidth(90);
-
mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None"));
mFpsLabel->setWidth(60);
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0
@@ -357,57 +270,28 @@ Setup_Video::Setup_Video():
mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
- mParticleEffectsCheckBox->setActionEventId("particleeffects");
- mPickupChatCheckBox->setActionEventId("pickupchat");
- mPickupParticleCheckBox->setActionEventId("pickupparticle");
- mAlphaSlider->setActionEventId("guialpha");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
- mSpeechSlider->setActionEventId("speech");
mFpsSlider->setActionEventId("fpslimitslider");
mAltFpsSlider->setActionEventId("altfpslimitslider");
- mOverlayDetailSlider->setActionEventId("overlaydetailslider");
- mOverlayDetailField->setActionEventId("overlaydetailfield");
- mParticleDetailSlider->setActionEventId("particledetailslider");
- mParticleDetailField->setActionEventId("particledetailfield");
mOpenGLDropDown->setActionEventId("opengl");
mEnableResizeCheckBox->setActionEventId("enableresize");
mNoFrameCheckBox->setActionEventId("noframe");
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
- mParticleEffectsCheckBox->addActionListener(this);
- mPickupChatCheckBox->addActionListener(this);
- mPickupParticleCheckBox->addActionListener(this);
- mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
- mSpeechSlider->addActionListener(this);
mFpsSlider->addActionListener(this);
mAltFpsSlider->addActionListener(this);
- mOverlayDetailSlider->addActionListener(this);
- mOverlayDetailField->addKeyListener(this);
- mParticleDetailSlider->addActionListener(this);
- mParticleDetailField->addKeyListener(this);
mOpenGLDropDown->addActionListener(this);
mEnableResizeCheckBox->addActionListener(this);
mNoFrameCheckBox->addActionListener(this);
- mSpeechLabel->setCaption(speechModeToString(mSpeechMode));
- mSpeechSlider->setValue(mSpeechMode);
-
- mOverlayDetailField->setCaption(overlayDetailToString(mOverlayDetail));
- mOverlayDetailSlider->setValue(mOverlayDetail);
-
- mParticleDetailField->setCaption(particleDetailToString(mParticleDetail));
- mParticleDetailSlider->setValue(mParticleDetail);
-
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, scrollArea, 1, 6).setPadding(2);
- place(0, 6, mOpenGLDropDown, 1);
-
-// place(0, 6, mHwAccelCheckBox, 6);
+ place(0, 0, scrollArea, 1, 5).setPadding(2);
+ place(0, 5, mOpenGLDropDown, 1);
place(1, 0, mFsCheckBox, 2);
@@ -416,33 +300,34 @@ Setup_Video::Setup_Video():
place(1, 2, mEnableResizeCheckBox, 2);
place(1, 3, mNoFrameCheckBox, 2);
- place(1, 4, mParticleEffectsCheckBox, 2);
- place(1, 5, mPickupNotifyLabel, 4);
- place(1, 6, mPickupChatCheckBox, 1);
- place(2, 6, mPickupParticleCheckBox, 2);
+// place(1, 5, mPickupNotifyLabel, 4);
+// place(1, 6, mPickupChatCheckBox, 1);
+// place(2, 6, mPickupParticleCheckBox, 2);
- place(0, 7, mAlphaSlider);
- place(1, 7, alphaLabel, 3);
+// place(0, 7, mAlphaSlider);
+// place(1, 7, alphaLabel, 3);
- place(0, 9, mFpsSlider);
- place(1, 9, mFpsCheckBox).setPadding(3);
- place(2, 9, mFpsLabel).setPadding(1);
+ place(0, 6, mFpsSlider);
+ place(1, 6, mFpsCheckBox).setPadding(3);
+ place(2, 6, mFpsLabel).setPadding(1);
- place(0, 10, mAltFpsSlider);
- place(1, 10, mAltFpsLabel).setPadding(3);
+ place(0, 7, mAltFpsSlider);
+ place(1, 7, mAltFpsLabel).setPadding(3);
- place(0, 11, mSpeechSlider);
- place(1, 11, speechLabel);
- place(2, 11, mSpeechLabel, 3).setPadding(2);
+// place(0, 11, mSpeechSlider);
+// place(1, 11, speechLabel);
+// place(2, 11, mSpeechLabel, 3).setPadding(2);
- place(0, 12, mOverlayDetailSlider);
- place(1, 12, overlayDetailLabel);
- place(2, 12, mOverlayDetailField, 3).setPadding(2);
+// place(0, 12, mOverlayDetailSlider);
+// place(1, 12, overlayDetailLabel);
+// place(2, 12, mOverlayDetailField, 3).setPadding(2);
- place(0, 13, mParticleDetailSlider);
- place(1, 13, particleDetailLabel);
- place(2, 13, mParticleDetailField, 3).setPadding(2);
+// place(0, 13, mParticleEffectsCheckBox, 5);
+
+// place(0, 14, mParticleDetailSlider);
+// place(1, 14, particleDetailLabel);
+// place(2, 14, mParticleDetailField, 3).setPadding(2);
int width = 600;
@@ -500,7 +385,7 @@ void Setup_Video::apply()
" and restoration of old mode also "
"failed!") << std::endl;
}
- logger->error(errorMsg.str());
+ logger->safeError(errorMsg.str());
}
}
#if defined(WIN32) || defined(__APPLE__)
@@ -508,7 +393,7 @@ void Setup_Video::apply()
else
{
new OkDialog(_("Switching to Full Screen"),
- _("Restart needed for changes to take effect."));
+ _("Restart needed for changes to take effect."));
}
#endif
config.setValue("screen", fullscreen);
@@ -521,7 +406,7 @@ void Setup_Video::apply()
// OpenGL can currently only be changed by restarting, notify user.
new OkDialog(_("Changing to OpenGL"),
- _("Applying change to OpenGL requires restart."));
+ _("Applying change to OpenGL requires restart."));
}
mFps = mFpsCheckBox->isSelected() ?
@@ -540,15 +425,8 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
- mParticleEffectsEnabled = config.getBoolValue("particleeffects");
- mSpeechMode = static_cast<Being::Speech>(
- config.getIntValue("speech"));
- mOpacity = config.getFloatValue("guialpha");
- mOverlayDetail = config.getIntValue("OverlayDetail");
mOpenGLEnabled = config.getIntValue("opengl");
- mPickupChatEnabled = config.getBoolValue("showpickupchat");
- mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
mEnableResize = config.getBoolValue("enableresize");
mNoFrame = config.getBoolValue("noframe");
}
@@ -559,15 +437,10 @@ void Setup_Video::cancel()
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLDropDown->setSelected(mOpenGLEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
- mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
mAltFpsSlider->setValue(mAltFps);
mAltFpsSlider->setEnabled(mAltFps > 0);
- mSpeechSlider->setValue(mSpeechMode);
- mAlphaSlider->setValue(mOpacity);
- mOverlayDetailSlider->setValue(mOverlayDetail);
- mParticleDetailSlider->setValue(mParticleDetail);
mFpsLabel->setCaption(mFpsCheckBox->isSelected()
? toString(mFps) : _("None"));
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
@@ -584,13 +457,7 @@ void Setup_Video::cancel()
config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("particleeffects", mParticleEffectsEnabled);
- config.setValue("speech", static_cast<int>(mSpeechMode));
- config.setValue("guialpha", mOpacity);
- Image::setEnableAlpha(mOpacity != 1.0f);
config.setValue("opengl", mOpenGLEnabled);
- config.setValue("showpickupchat", mPickupChatEnabled);
- config.setValue("showpickupparticle", mPickupParticleEnabled);
config.setValue("enableresize", mEnableResize);
config.setValue("noframe", mNoFrame);
}
@@ -631,13 +498,17 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
#if defined(_WIN32)
if (width < mainGraphics->mWidth || height < mainGraphics->mHeight)
+ {
new OkDialog(_("Screen Resolution Changed"),
- _("Restart your client for the change to take effect.")
- + std::string("\n") +
- _("Some windows may be moved to fit the lowered resolution."));
+ _("Restart your client for the change to take effect.")
+ + std::string("\n") + _("Some windows may be moved to "
+ "fit the lowered resolution."));
+ }
else
+ {
new OkDialog(_("Screen Resolution Changed"),
- _("Restart your client for the change to take effect."));
+ _("Restart your client for the change to take effect."));
+ }
#else
Client::resize(width, height);
#endif
@@ -653,57 +524,10 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
mDialog = nullptr;
}
- else if (id == "guialpha")
- {
- config.setValue("guialpha", mAlphaSlider->getValue());
- Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
- }
else if (id == "customcursor")
{
config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
}
- else if (id == "particleeffects")
- {
- config.setValue("particleeffects",
- mParticleEffectsCheckBox->isSelected());
- Particle::enabled = mParticleEffectsCheckBox->isSelected();
-
- if (Game::instance())
- {
- new OkDialog(_("Particle Effect Settings Changed."),
- _("Changes will take effect on map change."));
- }
- }
- else if (id == "pickupchat")
- {
- config.setValue("showpickupchat", mPickupChatCheckBox->isSelected());
- }
- else if (id == "pickupparticle")
- {
- config.setValue("showpickupparticle",
- mPickupParticleCheckBox->isSelected());
- }
- else if (id == "speech")
- {
- Being::Speech val = static_cast<Being::Speech>(
- mSpeechSlider->getValue());
- mSpeechLabel->setCaption(speechModeToString(val));
- mSpeechSlider->setValue(val);
- config.setValue("speech", static_cast<int>(val));
- }
- else if (id == "overlaydetailslider")
- {
- int val = static_cast<int>(mOverlayDetailSlider->getValue());
- mOverlayDetailField->setCaption(overlayDetailToString(val));
- config.setValue("OverlayDetail", val);
- }
- else if (id == "particledetailslider")
- {
- int val = static_cast<int>(mParticleDetailSlider->getValue());
- mParticleDetailField->setCaption(particleDetailToString(val));
- config.setValue("particleEmitterSkip", 3 - val);
- Particle::emitterSkip = 4 - val;
- }
else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
{
int tempFps = static_cast<int>(mFpsSlider->getValue());
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 31d45d93d..0e7bc0f21 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -46,68 +46,38 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
void action(const gcn::ActionEvent &event);
- static const char *overlayDetailToString(int detail = -1);
-
- static const char *particleDetailToString(int detail = -1);
-
virtual void externalUpdated();
private:
bool mFullScreenEnabled;
int mOpenGLEnabled;
bool mCustomCursorEnabled;
- bool mParticleEffectsEnabled;
- bool mPickupChatEnabled;
- bool mPickupParticleEnabled;
- float mOpacity;
int mFps;
int mAltFps;
bool mEnableResize;
bool mNoFrame;
- Being::Speech mSpeechMode;
ModeListModel *mModeListModel;
OpenGLListModel *mOpenGLListModel;
- gcn::Label *speechLabel;
- gcn::Label *alphaLabel;
gcn::Label *scrollRadiusLabel;
gcn::Label *scrollLazinessLabel;
- gcn::Label *overlayDetailLabel;
- gcn::Label *particleDetailLabel;
gcn::ListBox *mModeList;
gcn::CheckBox *mFsCheckBox;
gcn::DropDown *mOpenGLDropDown;
gcn::CheckBox *mCustomCursorCheckBox;
- gcn::CheckBox *mParticleEffectsCheckBox;
-
- gcn::Label *mPickupNotifyLabel;
- gcn::CheckBox *mPickupChatCheckBox;
- gcn::CheckBox *mPickupParticleCheckBox;
gcn::CheckBox *mEnableResizeCheckBox;
gcn::CheckBox *mNoFrameCheckBox;
- gcn::Slider *mSpeechSlider;
- gcn::Label *mSpeechLabel;
- gcn::Slider *mAlphaSlider;
gcn::CheckBox *mFpsCheckBox;
gcn::Slider *mFpsSlider;
gcn::Label *mFpsLabel;
-// gcn::CheckBox *mAltFpsCheckBox;
gcn::Slider *mAltFpsSlider;
gcn::Label *mAltFpsLabel;
- int mOverlayDetail;
- gcn::Slider *mOverlayDetailSlider;
- gcn::Label *mOverlayDetailField;
-
- int mParticleDetail;
- gcn::Slider *mParticleDetailSlider;
- gcn::Label *mParticleDetailField;
-
TextDialog *mDialog;
};
diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp
new file mode 100644
index 000000000..68704956a
--- /dev/null
+++ b/src/gui/setup_visual.cpp
@@ -0,0 +1,118 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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
+ */
+
+#include "gui/setup_visual.h"
+
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/scrollarea.h"
+
+#include "client.h"
+
+#include "utils/gettext.h"
+
+#include "debug.h"
+
+Setup_Visual::Setup_Visual()
+{
+ setName(_("Visual"));
+ // Do the layout
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+ place(0, 0, mScroll, 10, 10);
+
+ mPreferredFirstItemSize = 150;
+
+ new SetupItemLabel(_("Notifications"), "", this);
+
+ new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
+ "showpickupchat", this, "showpickupchatEvent");
+
+ new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
+ "", "showpickupparticle", this, "showpickupparticleEvent");
+
+ new SetupItemLabel(_("Effects"), "", this);
+
+ new SetupItemCheckBox(_("Grab mouse and keyboard input"),
+ "", "grabinput", this, "grabinputEvent");
+
+ new SetupItemSlider(_("Gui opacity"), "", "guialpha",
+ this, "guialphaEvent", 0.1, 1.0, 150, true);
+
+ mSpeachList = new SetupItemNames();
+ mSpeachList->push_back(_("No text"));
+ mSpeachList->push_back(_("Text"));
+ mSpeachList->push_back(_("Bubbles, no names"));
+ mSpeachList->push_back(_("Bubbles with names"));
+ new SetupItemSlider2(_("Overhead text"), "", "speech", this,
+ "speechEvent", 0, 3, mSpeachList);
+
+ mAmbientFxList = new SetupItemNames();
+ mAmbientFxList->push_back(_("off"));
+ mAmbientFxList->push_back(_("low"));
+ mAmbientFxList->push_back(_("high"));
+ new SetupItemSlider2(_("Ambient FX"), "", "OverlayDetail", this,
+ "OverlayDetailEvent", 0, 2, mAmbientFxList);
+
+ new SetupItemCheckBox(_("Particle effects"), "",
+ "particleeffects", this, "particleeffectsEvent");
+
+ mParticleList = new SetupItemNames();
+ mParticleList->push_back(_("low"));
+ mParticleList->push_back(_("medium"));
+ mParticleList->push_back(_("high"));
+ mParticleList->push_back(_("max"));
+ (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip",
+ this, "particleEmitterSkipEvent", 0, 3,
+ mParticleList, true))->setInvertValue(3);
+
+ new SetupItemLabel(_("Other"), "", this);
+
+ new SetupItemSlider(_("Gamma"), "", "gamma",
+ this, "gammeEvent", 1, 20, 350, true);
+
+ mVSyncList = new SetupItemNames();
+ mVSyncList->push_back(_("default"));
+ mVSyncList->push_back(_("off"));
+ mVSyncList->push_back(_("on"));
+ new SetupItemSlider2(_("Vsync"), "", "vsync", this,
+ "vsyncEvent", 0, 2, mVSyncList);
+
+ setDimension(gcn::Rectangle(0, 0, 550, 350));
+}
+
+Setup_Visual::~Setup_Visual()
+{
+ delete mSpeachList;
+ mSpeachList = nullptr;
+ delete mAmbientFxList;
+ mAmbientFxList = nullptr;
+ delete mParticleList;
+ mParticleList = nullptr;
+ delete mVSyncList;
+ mVSyncList = nullptr;
+}
+
+void Setup_Visual::apply()
+{
+ SetupTabScroll::apply();
+ Client::applyGrabMode();
+}
diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h
new file mode 100644
index 000000000..028f366b8
--- /dev/null
+++ b/src/gui/setup_visual.h
@@ -0,0 +1,50 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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 GUI_SETUP_VISUAL_H
+#define GUI_SETUP_VISUAL_H
+
+#include "guichanfwd.h"
+
+#include "gui/widgets/setupitem.h"
+#include "gui/widgets/setuptabscroll.h"
+
+class Setup_Visual : public SetupTabScroll
+{
+ public:
+ Setup_Visual();
+
+ ~Setup_Visual();
+
+ void apply();
+
+ private:
+ SetupItemNames *mSpeachList;
+
+ SetupItemNames *mAmbientFxList;
+
+ SetupItemNames *mParticleList;
+
+ SetupItemNames *mVSyncList;
+};
+
+#endif
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 1a27b8b0c..01b589ab6 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -753,7 +753,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
if (config.getBoolValue("autoShop"))
{
- sound.playGuiSfx("system/newmessage.ogg");
+ sound.playGuiSound(SOUND_TRADE);
startTrade();
}
else
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 287089790..f0ac9e128 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -1630,13 +1630,13 @@ void SocialWindow::showPartyCreate()
if (player_node->getParty())
{
new OkDialog(_("Create Party"),
- _("Cannot create party. You are already in a party"),
- this);
+ _("Cannot create party. You are already in a party"),
+ DIALOG_ERROR, true, true, this);
return;
}
mPartyCreateDialog = new TextDialog(_("Party Name"),
- _("Choose your party's name."), this);
+ _("Choose your party's name."), this);
mPartyCreateDialog->setActionEventId("create party");
mPartyCreateDialog->addActionListener(this);
}
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 7b9442318..3f98b4ea3 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -127,7 +127,8 @@ const char *MAGIC_SCHOOL_TEXT[6] =
class TargetTypeModel : public gcn::ListModel
{
public:
- virtual ~TargetTypeModel() { }
+ virtual ~TargetTypeModel()
+ { }
virtual int getNumberOfElements()
{
@@ -146,7 +147,8 @@ public:
class MagicSchoolModel : public gcn::ListModel
{
public:
- virtual ~MagicSchoolModel() { }
+ virtual ~MagicSchoolModel()
+ { }
virtual int getNumberOfElements()
{
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 85fd215ac..3a09810d0 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -569,6 +569,25 @@ void Theme::fillFontsList(std::vector<std::string> &list)
PHYSFS_permitSymbolicLinks(0);
}
+void Theme::fillSoundsList(std::vector<std::string> &list)
+{
+ char **skins = PHYSFS_enumerateFiles(
+ branding.getStringValue("systemsounds").c_str());
+
+ for (char **i = skins; *i; i++)
+ {
+ if (!PHYSFS_isDirectory((
+ branding.getStringValue("systemsounds") + *i).c_str()))
+ {
+ std::string str = *i;
+ if (findCutLast(str, ".ogg"))
+ list.push_back(str);
+ }
+ }
+
+ PHYSFS_freeList(skins);
+}
+
void Theme::selectSkin()
{
prepareThemePath();
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 9cb8f6180..c30044dc7 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -131,6 +131,8 @@ class Theme : public Palette, public ConfigListener
static void fillFontsList(std::vector<std::string> &list);
+ static void fillSoundsList(std::vector<std::string> &list);
+
/**
* Returns the patch to the given gui resource relative to the theme
* or, if it isn't in the theme, relative to 'graphics/gui'.
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index ca21263f1..9ba895ec8 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -134,7 +134,8 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
{
mWrongDataNoticeListener->setTarget(this->mPasswordField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
+ OkDialog *dlg = new OkDialog(_("Error"),
+ errorMsg.str(), DIALOG_ERROR);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 3aaf93557..9bac5e311 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -298,9 +298,26 @@ void UpdaterWindow::loadNews()
// Tokenize and add each line separately
char *line = strtok(mMemoryBuffer, "\n");
+ bool firstLine(true);
while (line)
{
- mBrowserBox->addRow(line);
+ if (firstLine)
+ {
+ firstLine = false;
+ std::string str = line;
+ unsigned i = str.find("##9 Latest client version: ##6");
+ if (!i)
+ {
+ line = strtok(nullptr, "\n");
+ continue;
+ }
+
+ mBrowserBox->addRow(str);
+ }
+ else
+ {
+ mBrowserBox->addRow(line);
+ }
line = strtok(nullptr, "\n");
}
@@ -332,6 +349,15 @@ void UpdaterWindow::loadPatch()
if (line)
{
version = line;
+ if (serverVersion < 1)
+ {
+ line = strtok(nullptr, "\n");
+ if (line)
+ {
+ mBrowserBox->addRow("##9 Latest client version: ##6ManaPlus "
+ + std::string(line), true);
+ }
+ }
if (version > CHECK_VERSION)
{
mBrowserBox->addRow("", true);
@@ -554,8 +580,8 @@ void UpdaterWindow::logic()
if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size())
{
mProgressBar->setText(strprintf("%d/%d", mUpdateIndex
- + mUpdateIndexOffset + 1, (int)mUpdateFiles.size()
- + (int)mTempUpdateFiles.size() + 1));
+ + mUpdateIndexOffset + 1, static_cast<int>(mUpdateFiles.size())
+ + static_cast<int>(mTempUpdateFiles.size()) + 1));
}
else
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index d4c188bfb..5c50836f6 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -98,11 +98,7 @@ Viewport::Viewport():
Viewport::~Viewport()
{
- config.removeListener("ScrollLaziness", this);
- config.removeListener("ScrollRadius", this);
- config.removeListener("showBeingPopup", this);
- config.removeListener("selfMouseHeal", this);
- config.removeListener("enableLazyScrolling", this);
+ config.removeListeners(this);
delete mPopupMenu;
mPopupMenu = nullptr;
@@ -199,7 +195,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
// if (debugChatTab)
// debugChatTab->chatLog("incorrect player position!");
logger->log("incorrect player position: %d, %d, %d, %d",
- player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
+ player_x, player_y, static_cast<int>(mPixelViewX),
+ static_cast<int>(mPixelViewY));
if (player_node)
{
logger->log("tile position: %d, %d",
@@ -412,7 +409,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
return;
// Check if we are alive and kickin'
-// if (!mMap || !player_node || !player_node->isAlive())
if (!mMap || !player_node)
return;
@@ -421,7 +417,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (Being::isTalking())
return;
-
const int pixelX = event.getX() + static_cast<int>(mPixelViewX);
const int pixelY = event.getY() + static_cast<int>(mPixelViewY);
@@ -460,6 +455,13 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
mPopupMenu->showPopup(event.getX(), event.getY(), mHoverSign);
return;
}
+ else if (mCameraMode)
+ {
+ mPopupMenu->showMapPopup(event.getX(), event.getY(),
+ (getMouseX() + getCameraX()) / mMap->getTileWidth(),
+ (getMouseY() + getCameraY()) / mMap->getTileHeight());
+ return;
+ }
}
// If a popup is active, just remove it
@@ -705,6 +707,11 @@ void Viewport::showUndressPopup(int x, int y, Being *being, Item *item)
mPopupMenu->showUndressPopup(x, y, being, item);
}
+void Viewport::showMapPopup(int x, int y)
+{
+ mPopupMenu->showMapPopup(getMouseX(), getMouseY(), x, y);
+}
+
void Viewport::closePopupMenu()
{
if (mPopupMenu)
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index ccb8124ba..ae6ff3d49 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -173,6 +173,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void showUndressPopup(int x, int y, Being *being, Item *item);
+ void showMapPopup(int x, int y);
+
/**
* Closes the popup menu. Needed for when the player dies or switching
* maps.
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 15c8a42c4..734daa7a6 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -131,8 +131,7 @@ WhoIsOnline::WhoIsOnline():
WhoIsOnline::~WhoIsOnline()
{
- config.removeListener("updateOnlineList", this);
- config.removeListener("groupFriends", this);
+ config.removeListeners(this);
if (mThread && SDL_GetThreadID(mThread))
SDL_WaitThread(mThread, nullptr);
@@ -738,7 +737,12 @@ void OnlinePlayer::setText(std::string color)
Being *being = actorSpriteManager->findBeingByName(
mNick, Being::PLAYER);
if (being)
+ {
being->setState(mStatus);
+ // for now highlight versions > 3
+ if (mVersion > 3)
+ being->setAdvanced(true);
+ }
}
if (mLevel > 0)
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 822e71805..749837f7d 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -74,8 +74,7 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
AvatarListBox::~AvatarListBox()
{
- config.removeListener("showgender", this);
- config.removeListener("showlevel", this);
+ config.removeListeners(this);
instances--;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 5856a91b1..47c5616b6 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -232,15 +232,17 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
tempRow.substr(nextChar,
(nextSpacePos - nextChar)));
- if ((x + nextWordWidth + 10) > (unsigned)getWidth())
+ if ((x + nextWordWidth + 10)
+ > static_cast<unsigned>(getWidth()))
{
x = 15; // Ident in new line
y += 1;
- j++;
+ j ++;
}
}
// Wrapping looong lines (brutal force)
- else if ((x + 2 * hyphenWidth) > (unsigned)getWidth())
+ else if ((x + 2 * hyphenWidth)
+ > static_cast<unsigned>(getWidth()))
{
x = 15; // Ident in new line
y += 1;
@@ -249,7 +251,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
}
setHeight(font->getHeight() * (static_cast<int>(
- mTextRows.size()) + y));
+ mTextRows.size()) + y));
}
else
{
@@ -423,7 +425,7 @@ int BrowserBox::calcHeight()
if (row.find("---", 0) == 0)
{
const int dashWidth = fontWidthMinus;
- for (x = 0; x < (unsigned)getWidth(); x++)
+ for (x = 0; x < static_cast<unsigned>(getWidth()); x ++)
{
mLineParts.push_back(LinePart(x, y, selColor, "-", false));
x += dashWidth - 2;
@@ -557,9 +559,8 @@ int BrowserBox::calcHeight()
width = font->getWidth(part);
// Auto wrap mode
- if (mMode == AUTO_WRAP && getWidth() > 0
- && width > 0
- && (x + width + 10) > (unsigned)getWidth())
+ if (mMode == AUTO_WRAP && getWidth() > 0 && width > 0
+ && (x + width + 10) > static_cast<unsigned>(getWidth()))
{
bool forced = false;
@@ -592,9 +593,8 @@ int BrowserBox::calcHeight()
else
width = font->getWidth(part);
}
- while (end > start && width > 0
- && (x + width + 10)
- > (unsigned)getWidth());
+ while (end > start && width > 0 && (x + width + 10)
+ > static_cast<unsigned>(getWidth()));
if (forced)
{
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index d82ebd758..b1582e077 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -104,7 +104,8 @@ class BrowserBox : public gcn::Widget,
/**
* Sets the maximum numbers of rows in the browser box. 0 = no limit.
*/
- void setMaxRow(unsigned max) {mMaxRows = max; };
+ void setMaxRow(unsigned max)
+ { mMaxRows = max; };
/**
* Disable links & user defined colors to be used in chat input.
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 2867e3d39..c99f46149 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -32,6 +32,7 @@
#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/imageset.h"
#include "utils/dtor.h"
@@ -69,30 +70,92 @@ static ButtonData const data[BUTTON_COUNT] =
ImageRect Button::button[BUTTON_COUNT];
-Button::Button():
+Button::Button() :
mDescription(""), mClickCount(0),
mTag(0),
mVertexes(new GraphicsVertexes()),
mRedraw(true),
mMode(0),
mXOffset(0),
- mYOffset(0)
+ mYOffset(0),
+ mImages(nullptr),
+ mImageSet(nullptr)
{
init();
+ adjustSize();
}
Button::Button(const std::string &caption, const std::string &actionEventId,
- gcn::ActionListener *listener):
+ gcn::ActionListener *listener) :
gcn::Button(caption),
- mDescription(""), mClickCount(0),
+ mDescription(""),
+ mClickCount(0),
+ mTag(0),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mMode(0),
+ mXOffset(0),
+ mYOffset(0),
+ mImages(nullptr),
+ mImageSet(nullptr),
+ mImageWidth(0),
+ mImageHeight(0)
+{
+ init();
+ adjustSize();
+ setActionEventId(actionEventId);
+
+ if (listener)
+ addActionListener(listener);
+}
+
+Button::Button(const std::string &caption, const std::string &imageName,
+ int imageWidth, int imageHeight,
+ const std::string &actionEventId,
+ gcn::ActionListener *listener) :
+ gcn::Button(caption),
+ mDescription(""),
+ mClickCount(0),
+ mTag(0),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mMode(0),
+ mXOffset(0),
+ mYOffset(0),
+ mImages(nullptr),
+ mImageSet(nullptr),
+ mImageWidth(imageWidth),
+ mImageHeight(imageHeight)
+{
+ init();
+ loadImage(imageName);
+ adjustSize();
+ setActionEventId(actionEventId);
+
+ if (listener)
+ addActionListener(listener);
+}
+
+Button::Button(const std::string &imageName, int imageWidth, int imageHeight,
+ const std::string &actionEventId,
+ gcn::ActionListener *listener) :
+ gcn::Button(""),
+ mDescription(""),
+ mClickCount(0),
mTag(0),
mVertexes(new GraphicsVertexes()),
mRedraw(true),
mMode(0),
mXOffset(0),
- mYOffset(0)
+ mYOffset(0),
+ mImages(nullptr),
+ mImageSet(nullptr),
+ mImageWidth(imageWidth),
+ mImageHeight(imageHeight)
{
init();
+ loadImage(imageName);
+ adjustSize();
setActionEventId(actionEventId);
if (listener)
@@ -158,6 +221,41 @@ Button::~Button()
}
}
}
+ if (mImageSet)
+ {
+ mImageSet->decRef();
+ mImageSet = nullptr;
+ }
+ if (mImages)
+ {
+ for (int f = 0; f < BUTTON_COUNT; f ++)
+ mImages[f] = nullptr;
+ delete [] mImages;
+ mImages = nullptr;
+ }
+}
+
+void Button::loadImage(const std::string &imageName)
+{
+ if (mImageSet)
+ {
+ mImageSet->decRef();
+ mImageSet = nullptr;
+ }
+ mImageSet = Theme::getImageSetFromTheme(imageName,
+ mImageWidth, mImageHeight);
+ if (!mImageSet)
+ return;
+ mImages = new Image*[BUTTON_COUNT];
+ mImages[0] = nullptr;
+ for (int f = 0; f < BUTTON_COUNT; f ++)
+ {
+ Image *img = mImageSet->get(f);
+ if (img)
+ mImages[f] = img;
+ else
+ mImages[f] = mImages[0];
+ }
}
void Button::updateAlpha()
@@ -197,6 +295,7 @@ void Button::draw(gcn::Graphics *graphics)
updateAlpha();
+ Graphics *g2 = static_cast<Graphics*>(graphics);
bool recalc = false;
if (mRedraw)
@@ -207,8 +306,7 @@ void Button::draw(gcn::Graphics *graphics)
{
// because we don't know where parent windows was moved,
// need recalc vertexes
- gcn::ClipRectangle &rect = static_cast<Graphics*>(
- graphics)->getTopClip();
+ gcn::ClipRectangle &rect = g2->getTopClip();
if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
{
recalc = true;
@@ -220,7 +318,7 @@ void Button::draw(gcn::Graphics *graphics)
recalc = true;
mMode = mode;
}
- else if (static_cast<Graphics*>(graphics)->getRedraw())
+ else if (g2->getRedraw())
{
recalc = true;
}
@@ -230,45 +328,73 @@ void Button::draw(gcn::Graphics *graphics)
{
mRedraw = false;
mMode = mode;
- static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0,
- getWidth(), getHeight(), button[mode]);
+ g2->calcWindow(mVertexes, 0, 0, getWidth(), getHeight(), button[mode]);
}
- static_cast<Graphics*>(graphics)->drawImageRect2(
- mVertexes, button[mode]);
+ g2->drawImageRect2(mVertexes, button[mode]);
-// static_cast<Graphics*>(graphics)->
-// drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
+// g2->drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
if (mode == BUTTON_DISABLED)
graphics->setColor(mDisabledColor);
else
graphics->setColor(mEnabledColor);
- int textX;
+ int textX = 0;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
+ int imageX = 0;
+ int imageY = 0;
+ if (mImages)
+ imageY = getHeight() / 2 - mImageHeight / 2;
+
+// need move calculation from draw!!!
switch (getAlignment())
{
default:
case gcn::Graphics::LEFT:
- textX = 4;
+ if (mImages)
+ {
+ imageX = 4;
+ textX = 4 + mImageWidth + 2;
+ }
+ else
+ {
+ textX = 4;
+ }
break;
case gcn::Graphics::CENTER:
- textX = getWidth() / 2;
+ if (mImages)
+ {
+ int width = getFont()->getWidth(mCaption) + mImageWidth + 2;
+ imageX = getWidth() / 2 - width / 2;
+ textX = imageX + mImageWidth + 2;
+ }
+ else
+ {
+ textX = getWidth() / 2;
+ }
break;
case gcn::Graphics::RIGHT:
textX = getWidth() - 4;
+ imageX = textX - getFont()->getWidth(mCaption) - 2;
break;
-// throw GCN_EXCEPTION("Button::draw. Unknown alignment.");
}
graphics->setFont(getFont());
if (isPressed())
- graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
+ {
+ if (mImages)
+ g2->drawImage(mImages[mode], imageX + 1, imageY + 1);
+ g2->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
+ }
else
- graphics->drawText(getCaption(), textX, textY, getAlignment());
+ {
+ if (mImages)
+ g2->drawImage(mImages[mode], imageX, imageY);
+ g2->drawText(getCaption(), textX, textY, getAlignment());
+ }
}
void Button::mouseReleased(gcn::MouseEvent& mouseEvent)
@@ -298,3 +424,27 @@ void Button::widgetMoved(const gcn::Event &event A_UNUSED)
{
mRedraw = true;
}
+
+void Button::adjustSize()
+{
+ if (mImages)
+ {
+ setWidth(getFont()->getWidth(mCaption)
+ + mImageWidth + 2 + 2 * mSpacing);
+ int height = getFont()->getHeight();
+ if (height < mImageHeight)
+ height = mImageHeight;
+ setHeight(height + 2 * mSpacing);
+ }
+ else
+ {
+ setWidth(getFont()->getWidth(mCaption) + 2 * mSpacing);
+ setHeight(getFont()->getHeight() + 2 * mSpacing);
+ }
+}
+
+void Button::setCaption(const std::string& caption)
+{
+ mCaption = caption;
+// adjustSize();
+}
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index 560e46377..6585d9850 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -28,8 +28,12 @@
#include <guichan/widgetlistener.hpp>
class GraphicsVertexes;
+class Image;
+class ImageSet;
class ImageRect;
+const std::string BUTTON_PLAY = "buttonplay.png";
+
/**
* Button widget. Same as the Guichan button but with custom look.
*
@@ -51,6 +55,23 @@ class Button : public gcn::Button, public gcn::WidgetListener
gcn::ActionListener *listener);
/**
+ * Constructor, sets the caption of the button to the given string and
+ * adds the given action listener.
+ */
+ Button(const std::string &caption, const std::string &imageName,
+ int imageWidth, int imageHeight,
+ const std::string &actionEventId,
+ gcn::ActionListener *listener);
+
+ /**
+ * Constructor, sets the caption of the button to the given string and
+ * adds the given action listener.
+ */
+ Button(const std::string &imageName, int imageWidth, int imageHeight,
+ const std::string &actionEventId,
+ gcn::ActionListener *listener);
+
+ /**
* Destructor.
*/
~Button();
@@ -86,6 +107,12 @@ class Button : public gcn::Button, public gcn::WidgetListener
void widgetMoved(const gcn::Event &event);
+ void loadImage(const std::string &imageName);
+
+ void adjustSize();
+
+ void setCaption(const std::string& caption);
+
private:
void init();
@@ -103,6 +130,10 @@ class Button : public gcn::Button, public gcn::WidgetListener
int mYOffset;
gcn::Color mEnabledColor;
gcn::Color mDisabledColor;
+ Image **mImages;
+ ImageSet *mImageSet;
+ int mImageWidth;
+ int mImageHeight;
};
#endif
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 018e35030..be6a31164 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -289,9 +289,19 @@ void ChatTab::chatLog(std::string line, Own own,
if (getFlash() == 0)
{
if (chatWindow && chatWindow->findHighlight(tmp.text))
+ {
setFlash(2);
+ sound.playGuiSound(SOUND_HIGHLIGHT);
+ }
else
+ {
setFlash(1);
+ }
+ }
+ else if (getFlash() == 2)
+ {
+ if (chatWindow && chatWindow->findHighlight(tmp.text))
+ sound.playGuiSound(SOUND_HIGHLIGHT);
}
}
@@ -300,8 +310,10 @@ void ChatTab::chatLog(std::string line, Own own,
|| (Client::getIsMinimized() || (!Client::getMouseFocused()
&& !Client::getInputFocused()))))
{
- if (own != BY_SERVER)
- sound.playGuiSfx("system/newmessage.ogg");
+ if (own == BY_GM)
+ sound.playGuiSound(SOUND_GLOBAL);
+ else if (own != BY_SERVER)
+ playNewMessageSound();
}
}
}
@@ -468,3 +480,8 @@ void ChatTab::addNewRow(std::string &line)
}
mScrollArea->logic();
}
+
+void ChatTab::playNewMessageSound()
+{
+ sound.playGuiSound(SOUND_WHISPER);
+}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 912305a63..d67f56b54 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -162,6 +162,8 @@ class ChatTab : public Tab
void addNewRow(std::string &line);
+ virtual void playNewMessageSound();
+
protected:
friend class ChatWindow;
friend class WhisperWindow;
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index 677dd3661..e5eeebdcb 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -43,7 +43,8 @@ class FlowContainer : public Container,
/**
* Destructor.
*/
- ~FlowContainer() {}
+ ~FlowContainer()
+ { }
/**
* Invoked when a widget changes its size. This is used to determine
diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp
index a95fca3cf..bad34cfb3 100644
--- a/src/gui/widgets/guildchattab.cpp
+++ b/src/gui/widgets/guildchattab.cpp
@@ -27,6 +27,7 @@
#include "guild.h"
#include "guildmanager.h"
#include "localplayer.h"
+#include "sound.h"
#include "gui/theme.h"
@@ -126,3 +127,8 @@ void GuildChatTab::saveToLogFile(std::string &msg)
if (chatLogger)
chatLogger->log("#Guild", msg);
}
+
+void GuildChatTab::playNewMessageSound()
+{
+ sound.playGuiSound(SOUND_GUILD);
+}
diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h
index be6f4d034..e729844f4 100644
--- a/src/gui/widgets/guildchattab.h
+++ b/src/gui/widgets/guildchattab.h
@@ -44,6 +44,8 @@ class GuildChatTab : public ChatTab
int getType() const
{ return ChatTab::TAB_GUILD; }
+ void playNewMessageSound();
+
protected:
void handleInput(const std::string &msg);
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index d620cbb8d..6434f5453 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -348,14 +348,15 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mSelectedRow > 0)
{
- if (mLinewiseMode && r == (unsigned)mSelectedRow && c == 0)
+ if (mLinewiseMode && r == static_cast<unsigned>(
+ mSelectedRow) && c == 0)
{
graphics->fillRectangle(gcn::Rectangle(0, y_offset,
- getWidth(), height));
+ getWidth(), height));
}
else if (!mLinewiseMode && mSelectedColumn > 0
- && c == (unsigned)mSelectedColumn
- && r == (unsigned)mSelectedRow)
+ && c == static_cast<unsigned>(mSelectedColumn)
+ && r == static_cast<unsigned>(mSelectedRow))
{
graphics->fillRectangle(gcn::Rectangle(
x_offset, y_offset, width, height));
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index c128ea550..5bf81c5d8 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -34,11 +34,16 @@ HorizontContainer::HorizontContainer(int height, int spacing):
void HorizontContainer::add(gcn::Widget *widget)
{
+ add(widget, mSpacing);
+}
+
+void HorizontContainer::add(gcn::Widget *widget, int spacing)
+{
if (!widget)
return;
Container::add(widget);
- widget->setPosition(mLastX, mSpacing);
+ widget->setPosition(mLastX, spacing);
mCount++;
mLastX += widget->getWidth() + 2 * mSpacing;
}
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 7439672dc..8e1d082ac 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -38,6 +38,8 @@ class HorizontContainer : public Container, public gcn::WidgetListener
virtual void add(gcn::Widget *widget);
+ virtual void add(gcn::Widget *widget, int spacing);
+
virtual void clear();
void widgetResized(const gcn::Event &event);
diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h
index 366899ffc..703f593f2 100644
--- a/src/gui/widgets/linkhandler.h
+++ b/src/gui/widgets/linkhandler.h
@@ -34,7 +34,8 @@
class LinkHandler
{
public:
- virtual ~LinkHandler() { }
+ virtual ~LinkHandler()
+ { }
virtual void handleLink(const std::string &link,
gcn::MouseEvent *event) = 0;
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 28fe9daa1..2944c5be6 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -29,6 +29,7 @@
#include "gui/sdlinput.h"
#include "gui/theme.h"
+#include <guichan/focushandler.hpp>
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
#include <guichan/key.hpp>
@@ -149,3 +150,12 @@ void ListBox::mouseDragged(gcn::MouseEvent &event)
if (getRowHeight())
setSelected(y / getRowHeight());
}
+
+void ListBox::refocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ if (isFocusable())
+ mFocusHandler->requestFocus(this);
+}
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index e4b6dd54e..1df07f19d 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -66,6 +66,8 @@ class ListBox : public gcn::ListBox
void mouseDragged(gcn::MouseEvent &event);
+ void refocus();
+
protected:
gcn::Color mHighlightColor;
static float mAlpha;
diff --git a/src/gui/widgets/namesmodel.cpp b/src/gui/widgets/namesmodel.cpp
new file mode 100644
index 000000000..abfcd6def
--- /dev/null
+++ b/src/gui/widgets/namesmodel.cpp
@@ -0,0 +1,51 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/namesmodel.h"
+
+#include "logger.h"
+
+#include "utils/gettext.h"
+
+#include <guichan/exception.hpp>
+#include <guichan/font.hpp>
+
+#include "debug.h"
+
+NamesModel::NamesModel()
+{
+}
+
+NamesModel::~NamesModel()
+{
+}
+
+int NamesModel::getNumberOfElements()
+{
+ return static_cast<int>(mNames.size());
+}
+
+std::string NamesModel::getElementAt(int i)
+{
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return mNames[i];
+}
diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h
new file mode 100644
index 000000000..dc694fc46
--- /dev/null
+++ b/src/gui/widgets/namesmodel.h
@@ -0,0 +1,51 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WIDGETS_NAMESMODEL_H
+#define GUI_WIDGETS_NAMESMODEL_H
+
+//#include "guichanfwd.h"
+
+#include <guichan/listmodel.hpp>
+
+#include <vector>
+
+class NamesModel : public gcn::ListModel
+{
+ public:
+ NamesModel();
+
+ virtual ~NamesModel();
+
+ virtual int getNumberOfElements();
+
+ virtual std::string getElementAt(int i);
+
+ std::vector<std::string> &getNames()
+ { return mNames; }
+
+ size_t size()
+ { return mNames.size(); }
+
+ protected:
+ std::vector<std::string> mNames;
+};
+
+#endif
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 56ce0a25a..93854e823 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -23,8 +23,10 @@
#include "configuration.h"
#include "main.h"
#include "logger.h"
+#include "sound.h"
#include "gui/editdialog.h"
+#include "gui/gui.h"
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
@@ -33,13 +35,19 @@
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/slider.h"
+#include "gui/widgets/sliderlist.h"
#include "gui/widgets/tabbedarea.h"
#include "gui/widgets/textfield.h"
#include "gui/widgets/vertcontainer.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
+#include "utils/mathutils.h"
+#include <guichan/font.hpp>
+
+#include "debug.h"
SetupItem::SetupItem(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
@@ -163,6 +171,12 @@ void SetupItem::externalUpdated(std::string eventName A_UNUSED)
toWidget();
}
+void SetupItem::fixFirstItemSize(gcn::Widget *widget)
+{
+ if (widget->getWidth() < mParent->getPreferredFirstItemSize())
+ widget->setWidth(mParent->getPreferredFirstItemSize());
+}
+
SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
std::string keyName,
SetupTabScroll *parent,
@@ -271,6 +285,7 @@ void SetupItemTextField::createControls()
mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent);
mWidget = mTextField;
mTextField->setWidth(200);
+ fixFirstItemSize(mLabel);
mHorizont->add(mLabel);
mHorizont->add(mTextField);
mHorizont->add(mButton);
@@ -394,6 +409,7 @@ void SetupItemIntTextField::createControls()
mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent);
mWidget = mTextField;
mTextField->setWidth(50);
+ fixFirstItemSize(mLabel);
mHorizont->add(mLabel);
mHorizont->add(mTextField);
mHorizont->add(mButton);
@@ -564,6 +580,7 @@ void SetupItemDropDown::createControls()
mWidget = mDropDown;
// mTextField->setWidth(50);
+ fixFirstItemSize(mLabel);
mHorizont->add(mLabel);
mHorizont->add(mDropDown);
@@ -588,3 +605,402 @@ void SetupItemDropDown::toWidget()
mDropDown->setSelectedString(mValue);
}
+
+
+SetupItemSlider::SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ int width, bool onTheFly, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider::SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ std::string def, int width, bool onTheFly,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider::~SetupItemSlider()
+{
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mSlider = nullptr;
+ mLabel = nullptr;
+}
+
+void SetupItemSlider::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mSlider = new Slider(mMin, mMax);
+ mSlider->setActionEventId(mEventName);
+ mSlider->addActionListener(mParent);
+ mSlider->setValue(atof(mValue.c_str()));
+ mSlider->setHeight(30);
+
+ mWidget = mSlider;
+ mSlider->setWidth(mWidth);
+ mSlider->setHeight(40);
+ fixFirstItemSize(mLabel);
+ mHorizont->add(mLabel);
+ mHorizont->add(mSlider, -10);
+
+ mParent->getContainer()->add2(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemSlider::fromWidget()
+{
+ if (!mSlider)
+ return;
+
+ mValue = toString(mSlider->getValue());
+}
+
+void SetupItemSlider::toWidget()
+{
+ if (!mSlider)
+ return;
+
+ mSlider->setValue(atof(mValue.c_str()));
+}
+
+void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED)
+{
+ fromWidget();
+ if (mOnTheFly)
+ save();
+}
+
+void SetupItemSlider::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
+
+
+SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ SetupItemNames *values, bool onTheFly,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mLabel2(nullptr),
+ mSlider(nullptr),
+ mValues(values),
+ mMin(min),
+ mMax(max),
+ mInvert(false),
+ mInvertValue(0),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ SetupItemNames *values, std::string def,
+ bool onTheFly, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mLabel2(nullptr),
+ mSlider(nullptr),
+ mValues(values),
+ mMin(min),
+ mMax(max),
+ mInvert(false),
+ mInvertValue(0),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider2::~SetupItemSlider2()
+{
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mSlider = nullptr;
+ mLabel = nullptr;
+}
+
+void SetupItemSlider2::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ int width = getMaxWidth();
+
+ mLabel = new Label(mText);
+ mLabel2 = new Label("");
+ mLabel2->setWidth(width);
+ mSlider = new Slider(mMin, mMax);
+ mSlider->setActionEventId(mEventName);
+ mSlider->addActionListener(mParent);
+ mSlider->setValue(atof(mValue.c_str()));
+ mSlider->setHeight(30);
+
+ mWidget = mSlider;
+ mSlider->setWidth(150);
+ mSlider->setHeight(40);
+ fixFirstItemSize(mLabel);
+ mHorizont->add(mLabel);
+ mHorizont->add(mSlider, -10);
+ mHorizont->add(mLabel2);
+
+ mParent->getContainer()->add2(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+ updateLabel();
+}
+
+int SetupItemSlider2::getMaxWidth()
+{
+ if (!mValues || !gui)
+ return 1;
+
+ int maxWidth = 0;
+ SetupItemNamesConstIter it = mValues->begin();
+ SetupItemNamesConstIter it_end = mValues->end();
+ gcn::Font *font = gui->getFont();
+
+ while (it != it_end)
+ {
+ int w = font->getWidth(*it);
+ if (w > maxWidth)
+ maxWidth = w;
+
+ ++ it;
+ }
+ return maxWidth;
+}
+
+void SetupItemSlider2::fromWidget()
+{
+ if (!mSlider)
+ return;
+
+ int val = roundDouble(mSlider->getValue());
+ if (mInvert)
+ val = mInvertValue - val;
+ mValue = toString(val);
+}
+
+void SetupItemSlider2::toWidget()
+{
+ if (!mSlider)
+ return;
+
+ int val = roundDouble(atof(mValue.c_str()));
+ if (mInvert)
+ val = mInvertValue - val;
+ mSlider->setValue(val);
+ updateLabel();
+}
+
+void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED)
+{
+ fromWidget();
+ updateLabel();
+ if (mOnTheFly)
+ save();
+}
+
+void SetupItemSlider2::updateLabel()
+{
+ int val = mSlider->getValue() - mMin;
+ if (val < 0)
+ val = 0;
+ else if (val >= static_cast<signed>(mValues->size()))
+ val = static_cast<signed>(mValues->size()) - 1;
+ std::string str = mValues->at(val);
+ mLabel2->setCaption(str);
+}
+
+void SetupItemSlider2::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
+
+void SetupItemSlider2::setInvertValue(int v)
+{
+ mInvert = true;
+ mInvertValue = v;
+ toWidget();
+}
+
+
+SetupItemSliderList::SetupItemSliderList(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ int width, bool onTheFly,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mModel(model),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+// createControls();
+}
+
+SetupItemSliderList::SetupItemSliderList(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ std::string def, int width,
+ bool onTheFly, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mModel(model),
+ mWidth(width),
+ mOnTheFly(onTheFly)
+{
+ mValueType = VSTR;
+// createControls();
+}
+
+SetupItemSliderList::~SetupItemSliderList()
+{
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mSlider = nullptr;
+ mLabel = nullptr;
+}
+
+void SetupItemSliderList::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mSlider = new SliderList(mModel, mParent, mEventName);
+ mSlider->setSelectedString(mValue);
+ mSlider->adjustSize();
+
+ mWidget = mSlider;
+ fixFirstItemSize(mLabel);
+ mHorizont->add(mLabel, 5);
+ mHorizont->add(mSlider);
+
+ addMoreControls();
+
+ mParent->getContainer()->add2(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemSliderList::fromWidget()
+{
+ if (!mSlider)
+ return;
+
+ mValue = mSlider->getSelectedString();
+}
+
+void SetupItemSliderList::toWidget()
+{
+ if (!mSlider)
+ return;
+
+ mSlider->setSelectedString(mValue);
+}
+
+void SetupItemSliderList::action(const gcn::ActionEvent &event A_UNUSED)
+{
+ fromWidget();
+ if (mOnTheFly)
+ save();
+}
+
+void SetupItemSliderList::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
+
+SetupItemSound::SetupItemSound(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ int width, bool onTheFly, bool mainConfig) :
+ SetupItemSliderList(text, description, keyName, parent, eventName,
+ model, width, onTheFly, mainConfig),
+ mButton(nullptr)
+{
+ createControls();
+}
+
+void SetupItemSound::addMoreControls()
+{
+ mButton = new Button(BUTTON_PLAY, 16, 16, mEventName + "_PLAY", this);
+ mHorizont->add(mButton);
+}
+
+void SetupItemSound::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == mEventName + "_PLAY")
+ {
+ if (mSlider->getSelected())
+ {
+ sound.playGuiSfx(branding.getStringValue("systemsounds")
+ + mSlider->getSelectedString() + ".ogg");
+ }
+ }
+ else
+ {
+ SetupItemSliderList::action(event);
+ }
+}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 71856d6e2..86fdf95f9 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -41,6 +41,8 @@ class EditDialog;
class HorizontContainer;
class IntTextField;
class Label;
+class Slider;
+class SliderList;
class TextField;
class SetupItem : public gcn::ActionListener
@@ -91,11 +93,12 @@ class SetupItem : public gcn::ActionListener
virtual void cancel(std::string eventName);
virtual void externalUpdated(std::string eventName);
-// virtual int add(ContainerPlacer &place, int x, int y, int width);
bool isMainConfig() const
{ return mMainConfig; }
+ void fixFirstItemSize(gcn::Widget *widget);
+
protected:
std::string mText;
@@ -264,4 +267,148 @@ class SetupItemDropDown : public SetupItem
DropDown *mDropDown;
};
+class SetupItemSlider : public SetupItem
+{
+ public:
+ SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ int width = 150, bool onTheFly = false,
+ bool mainConfig = true);
+
+ SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ std::string def, int width = 150,
+ bool onTheFly = false, bool mainConfig = true);
+
+ ~SetupItemSlider();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ void updateLabel();
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ Slider *mSlider;
+ double mMin;
+ double mMax;
+ int mWidth;
+ bool mOnTheFly;
+};
+
+typedef std::vector<std::string> SetupItemNames;
+typedef SetupItemNames::iterator SetupItemNamesIter;
+typedef SetupItemNames::const_iterator SetupItemNamesConstIter;
+
+class SetupItemSlider2 : public SetupItem
+{
+ public:
+ SetupItemSlider2(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ SetupItemNames *values, bool onTheFly = false,
+ bool mainConfig = true);
+
+ SetupItemSlider2(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ SetupItemNames *values, std::string def,
+ bool onTheFly = false, bool mainConfig = true);
+
+ ~SetupItemSlider2();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ void setInvertValue(int v);
+
+ protected:
+ void updateLabel();
+
+ int getMaxWidth();
+
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ Label *mLabel2;
+ Slider *mSlider;
+ SetupItemNames *mValues;
+ int mMin;
+ int mMax;
+ bool mInvert;
+ int mInvertValue;
+ bool mOnTheFly;
+};
+
+class SetupItemSliderList : public SetupItem
+{
+ public:
+ SetupItemSliderList(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ int width = 150, bool onTheFly = false,
+ bool mainConfig = true);
+
+ SetupItemSliderList(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ std::string def, int width = 150,
+ bool onTheFly = false, bool mainConfig = true);
+
+ ~SetupItemSliderList();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ virtual void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ virtual void addMoreControls() = 0;
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ SliderList *mSlider;
+ gcn::ListModel *mModel;
+ int mWidth;
+ bool mOnTheFly;
+};
+
+class SetupItemSound : public SetupItemSliderList
+{
+ public:
+ SetupItemSound(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ int width = 150, bool onTheFly = false,
+ bool mainConfig = true);
+
+ void action(const gcn::ActionEvent &event);
+
+ void addMoreControls();
+
+ protected:
+ Button *mButton;
+};
+
#endif
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index ab8f61a40..f3f8b1526 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -28,17 +28,14 @@
#include "debug.h"
SetupTabScroll::SetupTabScroll() :
- SetupTab()
+ SetupTab(),
+ mPreferredFirstItemSize(200)
{
- mContainer = new VertContainer(32, false, 8);
+ mContainer = new VertContainer(25, false, 8);
mScroll = new ScrollArea(mContainer);
mScroll->setOpaque(false);
mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
-
-// LayoutHelper h(this);
-// ContainerPlacer place = h.getPlacer(0, 0);
-// place(0, 0, mScroll, 10, 10);
}
SetupTabScroll::~SetupTabScroll()
diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h
index d471ecfbc..e7151769e 100644
--- a/src/gui/widgets/setuptabscroll.h
+++ b/src/gui/widgets/setuptabscroll.h
@@ -55,11 +55,15 @@ class SetupTabScroll : public SetupTab
virtual void action(const gcn::ActionEvent &event A_UNUSED)
{ }
+ int getPreferredFirstItemSize()
+ { return mPreferredFirstItemSize; }
+
protected:
VertContainer *mContainer;
ScrollArea *mScroll;
std::map<std::string, SetupItem*> mItems;
std::set<SetupItem*> mAllItems;
+ int mPreferredFirstItemSize;
};
#endif
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
new file mode 100644
index 000000000..bc30bbe38
--- /dev/null
+++ b/src/gui/widgets/sliderlist.cpp
@@ -0,0 +1,216 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/sliderlist.h"
+
+#include "client.h"
+#include "logger.h"
+
+#include "gui/gui.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/label.h"
+
+#include "utils/dtor.h"
+
+#include <guichan/font.hpp>
+
+#include "debug.h"
+
+static const int buttonWidth = 27;
+static const int buttonSpace = 30;
+static const int sliderHeight = 30;
+
+SliderList::SliderList(gcn::ListModel *listModel,
+ gcn::ActionListener* listener,
+ std::string eventId) :
+ mListModel(listModel),
+ mOldWidth(0),
+ mSelectedIndex(0)
+{
+ mPrevEventId = eventId + "_prev";
+ mNextEventId = eventId + "_next";
+
+ setHeight(sliderHeight);
+
+ mButtons[0] = new Button("<", mPrevEventId, this);
+ mButtons[1] = new Button(">", mNextEventId, this);
+ mLabel = new Label("");
+ add(mButtons[0]);
+ add(mLabel);
+ add(mButtons[1]);
+
+ if (!eventId.empty())
+ setActionEventId(eventId);
+
+ if (listener)
+ addActionListener(listener);
+
+ updateLabel();
+ addMouseListener(this);
+}
+
+SliderList::~SliderList()
+{
+}
+
+void SliderList::updateAlpha()
+{
+ mButtons[0]->updateAlpha();
+ mButtons[1]->updateAlpha();
+}
+
+void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+{
+ logger->log("SliderList::mouseWheelMovedUp");
+ setSelected(mSelectedIndex - 1);
+ mouseEvent.consume();
+}
+
+void SliderList::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+{
+ setSelected(mSelectedIndex + 1);
+ mouseEvent.consume();
+}
+
+void SliderList::resize()
+{
+ const int width = getWidth();
+
+ mButtons[0]->setWidth(buttonWidth);
+// mLabel->setPosition(buttonSpace, 0);
+ mLabel->setWidth(width - buttonSpace * 2);
+ mButtons[1]->setPosition(width - buttonSpace + 3, 0);
+ mButtons[1]->setWidth(buttonWidth);
+ updateLabel();
+}
+
+void SliderList::draw(gcn::Graphics *graphics)
+{
+ if (mOldWidth != getWidth())
+ {
+ resize();
+ mOldWidth = getWidth();
+ }
+ Container::draw(graphics);
+}
+
+void SliderList::updateLabel()
+{
+ if (!mListModel || mSelectedIndex < 0
+ || mSelectedIndex >= mListModel->getNumberOfElements())
+ {
+ return;
+ }
+
+ mLabel->setCaption(mListModel->getElementAt(mSelectedIndex));
+ mLabel->adjustSize();
+ const int space = getWidth() - buttonSpace * 2;
+ const int labelWidth = mLabel->getWidth();
+ int labelY = (getHeight() - mLabel->getHeight()) / 2;
+ if (labelY < 0)
+ labelY = 0;
+
+ if (space < 0 || space < labelWidth)
+ mLabel->setPosition(buttonSpace, labelY);
+ else
+ mLabel->setPosition(buttonSpace + (space - labelWidth) / 2, labelY);
+}
+
+void SliderList::action(const gcn::ActionEvent &event)
+{
+ if (!mListModel)
+ return;
+
+ if (event.getId() == mPrevEventId)
+ {
+ mSelectedIndex --;
+ if (mSelectedIndex < 0)
+ mSelectedIndex = mListModel->getNumberOfElements() - 1;
+ }
+ else if (event.getId() == mNextEventId)
+ {
+ mSelectedIndex ++;
+ if (mSelectedIndex >= mListModel->getNumberOfElements())
+ mSelectedIndex = 0;
+ }
+ updateLabel();
+ distributeActionEvent();
+}
+
+void SliderList::setSelectedString(std::string str)
+{
+ if (!mListModel)
+ return;
+
+ for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
+ {
+ if (mListModel->getElementAt(f) == str)
+ {
+ setSelected(f);
+ break;
+ }
+ }
+}
+
+std::string SliderList::getSelectedString() const
+{
+ if (!mListModel)
+ return "";
+
+ return mListModel->getElementAt(mSelectedIndex);
+}
+
+void SliderList::setSelected(int idx)
+{
+ if (!mListModel)
+ return;
+
+ mSelectedIndex = idx;
+ if (mSelectedIndex >= mListModel->getNumberOfElements())
+ mSelectedIndex = 0;
+ if (mSelectedIndex < 0)
+ mSelectedIndex = mListModel->getNumberOfElements() - 1;
+ updateLabel();
+}
+
+void SliderList::adjustSize()
+{
+ setWidth(getMaxLabelWidth() + 60);
+ updateLabel();
+}
+
+int SliderList::getMaxLabelWidth()
+{
+ if (!mListModel || !gui)
+ return 1;
+
+ int maxWidth = 0;
+ gcn::Font *font = gui->getFont();
+
+ for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
+ {
+ int w = font->getWidth(mListModel->getElementAt(f));
+ if (w > maxWidth)
+ maxWidth = w;
+ }
+
+ return maxWidth;
+}
diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h
new file mode 100644
index 000000000..b2239834d
--- /dev/null
+++ b/src/gui/widgets/sliderlist.h
@@ -0,0 +1,83 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2012 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WIDGETS_SLIDERLIST_H
+#define GUI_WIDGETS_SLIDERLIST_H
+
+#include <guichan/actionlistener.hpp>
+#include <guichan/listmodel.hpp>
+#include <guichan/mouselistener.hpp>
+
+#include "gui/widgets/container.h"
+
+#include "localconsts.h"
+
+class Button;
+class Label;
+
+class SliderList : public Container,
+ public gcn::ActionListener,
+ public gcn::MouseListener
+{
+ public:
+ SliderList(gcn::ListModel *listModel = nullptr,
+ gcn::ActionListener* listener = nullptr,
+ std::string eventId = "");
+
+ ~SliderList();
+
+ void updateAlpha();
+
+ void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent);
+
+ void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent);
+
+ void resize();
+
+ void draw(gcn::Graphics *graphics);
+
+ void action(const gcn::ActionEvent &event);
+
+ void setSelectedString(std::string str);
+
+ std::string getSelectedString() const;
+
+ void setSelected(int idx);
+
+ void adjustSize();
+
+ int getSelected()
+ { return mSelectedIndex; }
+
+ protected:
+ void updateLabel();
+
+ int getMaxLabelWidth();
+
+ Button *mButtons[2];
+ Label *mLabel;
+ gcn::ListModel *mListModel;
+ std::string mPrevEventId;
+ std::string mNextEventId;
+ int mOldWidth;
+ int mSelectedIndex;
+};
+
+#endif // end GUI_WIDGETS_SLIDERLIST_H
diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h
index 40a350163..e931888e4 100644
--- a/src/gui/widgets/tablemodel.h
+++ b/src/gui/widgets/tablemodel.h
@@ -42,7 +42,8 @@ public:
*/
virtual void modelUpdated(bool completed) = 0;
- virtual ~TableModelListener() {}
+ virtual ~TableModelListener()
+ { }
};
/**
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index e207b0613..a90712340 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -183,7 +183,7 @@ int TextField::getValue() const
if (value < mMinimum)
return mMinimum;
- if (value > (signed)mMaximum)
+ if (value > static_cast<signed>(mMaximum))
return mMaximum;
return value;
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index 917605281..19e6b81f7 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -54,7 +54,8 @@ class WorldListModel : public gcn::ListModel
{
}
- virtual ~WorldListModel() {}
+ virtual ~WorldListModel()
+ { }
int getNumberOfElements()
{