summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charcreatedialog.cpp1
-rw-r--r--src/gui/charselectdialog.cpp1
-rw-r--r--src/gui/customserverdialog.cpp11
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/equipmentwindow.h2
-rw-r--r--src/gui/gui.cpp3
-rw-r--r--src/gui/serverdialog.cpp16
-rw-r--r--src/gui/setup_audio.cpp32
-rw-r--r--src/gui/setup_audio.h18
-rw-r--r--src/gui/socialwindow.cpp5
-rw-r--r--src/gui/specialswindow.cpp41
-rw-r--r--src/gui/truetypefont.cpp4
-rw-r--r--src/gui/widgets/chattab.cpp23
-rw-r--r--src/gui/widgets/chattab.h9
-rw-r--r--src/gui/widgets/whispertab.h3
15 files changed, 106 insertions, 65 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 84bce434..8fee148b 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -39,7 +39,6 @@
#include "gui/widgets/textfield.h"
#include "net/charhandler.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "resources/hairdb.h"
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index a806fa96..1850eb9d 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -46,7 +46,6 @@
#include "net/charhandler.h"
#include "net/logindata.h"
#include "net/loginhandler.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "resources/hairdb.h"
diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp
index 9d56a3ce..e0d25928 100644
--- a/src/gui/customserverdialog.cpp
+++ b/src/gui/customserverdialog.cpp
@@ -161,12 +161,10 @@ void CustomServerDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "addServer")
{
// Check the given information
- if (mServerAddressField->getText().empty()
- || mPortField->getText().empty())
+ if (mServerAddressField->getText().empty())
{
OkDialog *dlg = new OkDialog(_("Error"),
- _("Please at least type both the address and the port "
- "of the server."));
+ _("Please type in at least the address of the server."));
dlg->addActionListener(this);
}
else
@@ -178,7 +176,6 @@ void CustomServerDialog::action(const gcn::ActionEvent &event)
serverInfo.name = mNameField->getText();
serverInfo.description = mDescriptionField->getText();
serverInfo.hostname = mServerAddressField->getText();
- serverInfo.port = (short) atoi(mPortField->getText().c_str());
#ifdef MANASERV_SUPPORT
switch (mTypeField->getSelected())
{
@@ -194,6 +191,10 @@ void CustomServerDialog::action(const gcn::ActionEvent &event)
#else
serverInfo.type = ServerInfo::TMWATHENA;
#endif
+ if (mPortField->getText().empty())
+ serverInfo.port = ServerInfo::defaultPortForServerType(serverInfo.type);
+ else
+ serverInfo.port = (short) atoi(mPortField->getText().c_str());
// Tell the server has to be saved
serverInfo.save = true;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 4aa76c2f..85a4c766 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -197,7 +197,7 @@ Item *EquipmentWindow::getItem(int x, int y) const
return 0;
}
-const std::string EquipmentWindow::getSlotName(int x, int y) const
+std::string EquipmentWindow::getSlotName(int x, int y) const
{
for (int i = 0; i < mBoxesNumber; ++i)
{
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0f1d19fa..29814dc5 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -93,7 +93,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mouseMoved(gcn::MouseEvent &event);
Item *getItem(int x, int y) const;
- const std::string getSlotName(int x, int y) const;
+ std::string getSlotName(int x, int y) const;
void setSelected(int index);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 2f24d009..78fc42fb 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/window.h"
#include "gui/widgets/windowcontainer.h"
+#include "client.h"
#include "configuration.h"
#include "eventlistener.h"
#include "graphics.h"
@@ -204,7 +205,7 @@ void Gui::draw()
int mouseX, mouseY;
Uint8 button = SDL_GetMouseState(&mouseX, &mouseY);
- if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1))
+ if ((Client::hasMouseFocus() || button & SDL_BUTTON(1))
&& mCustomCursor
&& mMouseCursorAlpha > 0.0f)
{
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 49de7f38..9802224b 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -69,18 +69,6 @@ static std::string serverTypeToString(ServerInfo::Type type)
}
}
-static unsigned short defaultPortForServerType(ServerInfo::Type type)
-{
- switch (type)
- {
- default:
- case ServerInfo::TMWATHENA:
- return 6901;
- case ServerInfo::MANASERV:
- return 9601;
- }
-}
-
ServersListModel::ServersListModel(ServerInfos *servers, ServerDialog *parent):
mServers(servers),
mVersionStrings(servers->size(), VersionString(0, "")),
@@ -510,7 +498,7 @@ void ServerDialog::loadServers()
if (server.port == 0)
{
// If no port is given, use the default for the given type
- server.port = defaultPortForServerType(server.type);
+ server.port = ServerInfo::defaultPortForServerType(server.type);
}
}
else if (xmlStrEqual(subNode->name, BAD_CAST "description"))
@@ -563,7 +551,7 @@ void ServerDialog::loadCustomServers()
server.hostname = config.getValue(hostNameKey, "");
server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
- const int defaultPort = defaultPortForServerType(server.type);
+ const int defaultPort = ServerInfo::defaultPortForServerType(server.type);
server.port = (unsigned short) config.getValue(portKey, defaultPort);
server.description = config.getValue(descriptionKey, "");
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index c43210d0..69ee3dc3 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -37,31 +37,38 @@
Setup_Audio::Setup_Audio():
mMusicVolume(config.getIntValue("musicVolume")),
mSfxVolume(config.getIntValue("sfxVolume")),
+ mNotificationsVolume(config.getIntValue("notificationsVolume")),
mSoundEnabled(config.getBoolValue("sound")),
mDownloadEnabled(config.getBoolValue("download-music")),
mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)),
mSfxSlider(new Slider(0, sound.getMaxVolume())),
+ mNotificationsSlider(new Slider(0, sound.getMaxVolume())),
mMusicSlider(new Slider(0, sound.getMaxVolume()))
{
setName(_("Audio"));
setDimension(gcn::Rectangle(0, 0, 250, 200));
gcn::Label *sfxLabel = new Label(_("Sfx volume"));
+ gcn::Label *notificationsLabel = new Label(_("Notifications volume"));
gcn::Label *musicLabel = new Label(_("Music volume"));
mSfxSlider->setActionEventId("sfx");
+ mNotificationsSlider->setActionEventId("notifications");
mMusicSlider->setActionEventId("music");
mSfxSlider->addActionListener(this);
+ mNotificationsSlider->addActionListener(this);
mMusicSlider->addActionListener(this);
mSoundCheckBox->setPosition(10, 10);
mSfxSlider->setValue(mSfxVolume);
+ mNotificationsSlider->setValue(mNotificationsVolume);
mMusicSlider->setValue(mMusicVolume);
mSfxSlider->setWidth(90);
+ mNotificationsSlider->setWidth(90);
mMusicSlider->setWidth(90);
// Do the layout
@@ -71,9 +78,11 @@ Setup_Audio::Setup_Audio():
place(0, 0, mSoundCheckBox);
place(0, 1, mSfxSlider);
place(1, 1, sfxLabel);
- place(0, 2, mMusicSlider);
- place(1, 2, musicLabel);
- place(0, 3, mDownloadMusicCheckBox);
+ place(0, 2, mNotificationsSlider);
+ place(1, 2, notificationsLabel);
+ place(0, 3, mMusicSlider);
+ place(1, 3, musicLabel);
+ place(0, 4, mDownloadMusicCheckBox);
setDimension(gcn::Rectangle(0, 0, 370, 280));
}
@@ -83,6 +92,7 @@ void Setup_Audio::apply()
mSoundEnabled = mSoundCheckBox->isSelected();
mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
mSfxVolume = config.getIntValue("sfxVolume");
+ mNotificationsVolume = config.getIntValue("sfxVolume");
mMusicVolume = config.getIntValue("musicVolume");
config.setValue("sound", mSoundEnabled);
@@ -134,12 +144,20 @@ void Setup_Audio::action(const gcn::ActionEvent &event)
{
if (event.getId() == "sfx")
{
- config.setValue("sfxVolume", (int) mSfxSlider->getValue());
- sound.setSfxVolume((int) mSfxSlider->getValue());
+ int volume = (int) mSfxSlider->getValue();
+ config.setValue("sfxVolume", volume);
+ sound.setSfxVolume(volume);
+ }
+ else if (event.getId() == "notifications")
+ {
+ int volume = (int) mNotificationsSlider->getValue();
+ config.setValue("notificationsVolume", volume);
+ sound.setNotificationsVolume(volume);
}
else if (event.getId() == "music")
{
- config.setValue("musicVolume", (int) mMusicSlider->getValue());
- sound.setMusicVolume((int) mMusicSlider->getValue());
+ int volume = (int) mMusicSlider->getValue();
+ config.setValue("musicVolume", volume);
+ sound.setMusicVolume(volume);
}
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 5477eaad..ac81bdb7 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -39,11 +39,17 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener
void action(const gcn::ActionEvent &event);
private:
- int mMusicVolume, mSfxVolume;
- bool mSoundEnabled, mDownloadEnabled;
-
- gcn::CheckBox *mSoundCheckBox, *mDownloadMusicCheckBox;
- gcn::Slider *mSfxSlider, *mMusicSlider;
+ int mMusicVolume;
+ int mSfxVolume;
+ int mNotificationsVolume;
+ bool mSoundEnabled;
+ bool mDownloadEnabled;
+
+ gcn::CheckBox *mSoundCheckBox;
+ gcn::CheckBox *mDownloadMusicCheckBox;
+ gcn::Slider *mSfxSlider;
+ gcn::Slider *mNotificationsSlider;
+ gcn::Slider *mMusicSlider;
};
-#endif
+#endif // GUI_SETUP_AUDIO_H
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 421d639d..4203a137 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -123,9 +123,10 @@ public:
if (!name.empty())
{
+ Net::getGuildHandler()->invite(mGuild->getId(), name);
SERVER_NOTICE(strprintf(_("Invited user %s to guild %s."),
- name.c_str(),
- mGuild->getName().c_str()))
+ name.c_str(),
+ mGuild->getName().c_str()))
}
mInviteDialog = NULL;
}
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 8097eb05..7db5952a 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -48,6 +48,8 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include "localplayer.h"
+
#include <string>
#define SPECIALS_WIDTH 200
@@ -106,12 +108,20 @@ void SpecialsWindow::action(const gcn::ActionEvent &event)
if (disp)
{
- /*Being *target = local_player->getTarget();
-
- if (target)
- Net::getSpecialHandler()->use(disp->mInfo->id, 1, target->getId());
- else*/
- Net::getSpecialHandler()->use(disp->mInfo->id);
+ if (disp->mInfo->targetMode == SpecialInfo::TARGET_BEING)
+ {
+ Being *target = local_player->getTarget();
+
+ if (target)
+ Net::getSpecialHandler()->use(disp->mInfo->id, 1, target->getId());
+ else
+ Net::getSpecialHandler()->use(disp->mInfo->id);
+ }
+ else
+ {
+ // TODO: Allow the player to aim at a position on the map and
+ // Use special on the map position.
+ }
}
}
else if (event.getId() == "close")
@@ -202,22 +212,11 @@ SpecialEntry::SpecialEntry(SpecialInfo *info) :
mNameLabel->setPosition(35, 0);
add(mNameLabel);
- if (info->hasLevel)
- {
- mLevelLabel = new Label(toString(info->level));
- mLevelLabel->setPosition(getWidth() - mLevelLabel->getWidth(), 0);
- add(mLevelLabel);
- }
-
-
- if (info->isActive)
- {
- mUse = new Button("Use", "use", specialsWindow);
- mUse->setPosition(getWidth() - mUse->getWidth(), 13);
- add(mUse);
- }
+ mUse = new Button("Use", "use", specialsWindow);
+ mUse->setPosition(getWidth() - mUse->getWidth(), 13);
+ add(mUse);
- if (info->hasRechargeBar)
+ if (info->rechargeable)
{
float progress = (float)info->rechargeCurrent / (float)info->rechargeNeeded;
mRechargeBar = new ProgressBar(progress, 100, 10, Theme::PROG_MP);
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp
index 5f85ea68..620ba191 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/truetypefont.cpp
@@ -57,7 +57,7 @@ class TextChunk
sdlCol.r = color.r;
sdlCol.g = color.g;
- const char* str = getSafeUtf8String(text);
+ const char *str = getSafeUtf8String(text);
SDL_Surface *surface = TTF_RenderUTF8_Blended(
font, str, sdlCol);
delete[] str;
@@ -179,7 +179,7 @@ int TrueTypeFont::getWidth(const std::string &text) const
}
int w, h;
- const char* str = getSafeUtf8String(text);
+ const char *str = getSafeUtf8String(text);
TTF_SizeUTF8(mFont, str, &w, &h);
delete[] str;
return w;
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 8642be69..1979ecbd 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -23,9 +23,11 @@
#include "actorspritemanager.h"
#include "chatlogger.h"
+#include "client.h"
#include "commandhandler.h"
#include "configuration.h"
#include "localplayer.h"
+#include "sound.h"
#include "gui/gui.h"
#include "gui/recorder.h"
@@ -237,10 +239,20 @@ void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
}
mScrollArea->logic();
+
chatWindow->mRecorder->record(line.substr(3));
- if (this != getTabbedArea()->getSelectedTab() &&
- own != BY_PLAYER)
- setFlash(true);
+
+ if (own != BY_PLAYER)
+ {
+ bool currentTab = getTabbedArea()->getSelectedTab() == this;
+
+ if (!currentTab)
+ setFlash(true);
+
+ if (!(currentTab && Client::hasInputFocus()) && own != BY_SERVER)
+ if (checkNotify(own))
+ sound.playNotification("system/newmessage.ogg");
+ }
}
void ChatTab::chatLog(const std::string &nick, const std::string &msg)
@@ -318,6 +330,11 @@ void ChatTab::handleCommand(const std::string &msg)
commandHandler->handleCommand(msg, this);
}
+bool ChatTab::checkNotify(Own own) const
+{
+ return own == ACT_WHISPER;
+}
+
void ChatTab::getAutoCompleteList(std::vector<std::string> &names) const
{
actorSpriteManager->getPlayerNPCNameLister()->getAutoCompleteList(names);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 3796c37b..200ad55a 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -115,6 +115,15 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener
virtual void handleCommand(const std::string &msg);
/**
+ * Returns whether a notify sound may be played for the given type of
+ * message. By default, only returns true for inline whispers.
+ *
+ * Is never called for server-messages or when the window has focus
+ * and this is the current tab.
+ */
+ virtual bool checkNotify(Own own) const;
+
+ /**
* Adapts the text format to the current gui opacity,
* for better readability.
*/
diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h
index e88d084b..a0dcfc14 100644
--- a/src/gui/widgets/whispertab.h
+++ b/src/gui/widgets/whispertab.h
@@ -57,6 +57,9 @@ class WhisperTab : public ChatTab
void handleCommand(const std::string &msg);
+ bool checkNotify(Own) const
+ { return true; }
+
private:
std::string mNick;
};