summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-02-09 23:47:02 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-02-09 23:47:02 +0100
commitfa2f3ac593a792c32095c2e885665ec91bb4019d (patch)
treef44aee845f0229dfcc6b2ad3c74613e0352f36c2 /src
parent07f7d52f661a74e6d0c780ca53e724651e3dcc48 (diff)
parent40edf4e91558cffd83d9015a2cf4a16360e27855 (diff)
downloadmana-client-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.gz
mana-client-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.bz2
mana-client-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.xz
mana-client-fa2f3ac593a792c32095c2e885665ec91bb4019d.zip
Merged with Aethyra master as of 2009-02-09
Conflicts: A lot of files...
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt41
-rw-r--r--src/Makefile.am11
-rw-r--r--src/being.cpp33
-rw-r--r--src/being.h43
-rw-r--r--src/configlistener.h2
-rw-r--r--src/configuration.cpp2
-rw-r--r--src/configuration.h3
-rw-r--r--src/effectmanager.cpp3
-rw-r--r--src/effectmanager.h7
-rw-r--r--src/engine.cpp10
-rw-r--r--src/engine.h2
-rw-r--r--src/equipment.cpp2
-rw-r--r--src/extensions.h34
-rw-r--r--src/floor_item.cpp16
-rw-r--r--src/floor_item.h22
-rw-r--r--src/game.cpp182
-rw-r--r--src/game.h4
-rw-r--r--src/graphics.h8
-rw-r--r--src/gui/browserbox.cpp30
-rw-r--r--src/gui/browserbox.h7
-rw-r--r--src/gui/button.cpp43
-rw-r--r--src/gui/button.h5
-rw-r--r--src/gui/buttonbox.cpp43
-rw-r--r--src/gui/buttonbox.h67
-rw-r--r--src/gui/buy.h6
-rw-r--r--src/gui/buysell.h2
-rw-r--r--src/gui/char_select.cpp3
-rw-r--r--src/gui/char_select.h9
-rw-r--r--src/gui/char_server.cpp17
-rw-r--r--src/gui/char_server.h2
-rw-r--r--src/gui/chat.cpp92
-rw-r--r--src/gui/chat.h5
-rw-r--r--src/gui/chatinput.h2
-rw-r--r--src/gui/checkbox.cpp31
-rw-r--r--src/gui/checkbox.h8
-rw-r--r--src/gui/colour.cpp17
-rw-r--r--src/gui/colour.h9
-rw-r--r--src/gui/confirm_dialog.cpp9
-rw-r--r--src/gui/confirm_dialog.h9
-rw-r--r--src/gui/connection.cpp7
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/debugwindow.h4
-rw-r--r--src/gui/emotecontainer.h2
-rw-r--r--src/gui/emoteshortcutcontainer.cpp13
-rw-r--r--src/gui/emoteshortcutcontainer.h4
-rw-r--r--src/gui/emotewindow.cpp5
-rw-r--r--src/gui/emotewindow.h2
-rw-r--r--src/gui/equipmentwindow.cpp94
-rw-r--r--src/gui/equipmentwindow.h11
-rw-r--r--src/gui/focushandler.h2
-rw-r--r--src/gui/gccontainer.h2
-rw-r--r--src/gui/gui.cpp25
-rw-r--r--src/gui/gui.h1
-rw-r--r--src/gui/help.cpp2
-rw-r--r--src/gui/help.h2
-rw-r--r--src/gui/inttextfield.h2
-rw-r--r--src/gui/inventorywindow.cpp26
-rw-r--r--src/gui/inventorywindow.h6
-rw-r--r--src/gui/item_amount.cpp3
-rw-r--r--src/gui/item_amount.h4
-rw-r--r--src/gui/itemcontainer.cpp3
-rw-r--r--src/gui/itemcontainer.h2
-rw-r--r--src/gui/itemlinkhandler.cpp6
-rw-r--r--src/gui/itempopup.cpp102
-rw-r--r--src/gui/itempopup.h9
-rw-r--r--src/gui/itemshortcutcontainer.cpp10
-rw-r--r--src/gui/itemshortcutcontainer.h2
-rw-r--r--src/gui/listbox.cpp27
-rw-r--r--src/gui/listbox.h5
-rw-r--r--src/gui/login.cpp9
-rw-r--r--src/gui/login.h11
-rw-r--r--src/gui/menuwindow.h2
-rw-r--r--src/gui/minimap.cpp28
-rw-r--r--src/gui/minimap.h2
-rw-r--r--src/gui/ministatus.cpp1
-rw-r--r--src/gui/ministatus.h7
-rw-r--r--src/gui/npc_text.cpp34
-rw-r--r--src/gui/npc_text.h16
-rw-r--r--src/gui/npcintegerdialog.cpp27
-rw-r--r--src/gui/npcintegerdialog.h19
-rw-r--r--src/gui/npclistdialog.cpp3
-rw-r--r--src/gui/npclistdialog.h5
-rw-r--r--src/gui/npcstringdialog.cpp13
-rw-r--r--src/gui/npcstringdialog.h11
-rw-r--r--src/gui/ok_dialog.cpp10
-rw-r--r--src/gui/ok_dialog.h6
-rw-r--r--src/gui/passwordfield.cpp2
-rw-r--r--src/gui/passwordfield.h4
-rw-r--r--src/gui/playerbox.cpp11
-rw-r--r--src/gui/playerbox.h3
-rw-r--r--src/gui/popupmenu.cpp25
-rw-r--r--src/gui/progressbar.cpp35
-rw-r--r--src/gui/progressbar.h6
-rw-r--r--src/gui/radiobutton.cpp39
-rw-r--r--src/gui/radiobutton.h6
-rw-r--r--src/gui/recorder.cpp115
-rw-r--r--src/gui/recorder.h (renamed from src/recorder.h)51
-rw-r--r--src/gui/register.cpp8
-rw-r--r--src/gui/register.h4
-rw-r--r--src/gui/scrollarea.cpp28
-rw-r--r--src/gui/scrollarea.h7
-rw-r--r--src/gui/sell.cpp8
-rw-r--r--src/gui/sell.h4
-rw-r--r--src/gui/setup.cpp3
-rw-r--r--src/gui/setup_audio.cpp4
-rw-r--r--src/gui/setup_audio.h2
-rw-r--r--src/gui/setup_colours.cpp66
-rw-r--r--src/gui/setup_colours.h18
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_joystick.h2
-rw-r--r--src/gui/setup_keyboard.cpp12
-rw-r--r--src/gui/setup_keyboard.h1
-rw-r--r--src/gui/setup_players.cpp26
-rw-r--r--src/gui/setup_players.h13
-rw-r--r--src/gui/setup_video.cpp69
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/gui/shop.h3
-rw-r--r--src/gui/shoplistbox.cpp24
-rw-r--r--src/gui/shoplistbox.h5
-rw-r--r--src/gui/shortcutcontainer.cpp11
-rw-r--r--src/gui/shortcutcontainer.h10
-rw-r--r--src/gui/shortcutwindow.cpp15
-rw-r--r--src/gui/shortcutwindow.h6
-rw-r--r--src/gui/skill.cpp35
-rw-r--r--src/gui/skill.h9
-rw-r--r--src/gui/slider.cpp16
-rw-r--r--src/gui/slider.h3
-rw-r--r--src/gui/speechbubble.cpp47
-rw-r--r--src/gui/speechbubble.h6
-rw-r--r--src/gui/status.cpp227
-rw-r--r--src/gui/status.h10
-rw-r--r--src/gui/table.cpp263
-rw-r--r--src/gui/table.h58
-rw-r--r--src/gui/table_model.cpp31
-rw-r--r--src/gui/table_model.h38
-rw-r--r--src/gui/textbox.cpp29
-rw-r--r--src/gui/textbox.h12
-rw-r--r--src/gui/textfield.cpp15
-rw-r--r--src/gui/textfield.h3
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/truetypefont.h1
-rw-r--r--src/gui/updatewindow.cpp6
-rw-r--r--src/gui/updatewindow.h2
-rw-r--r--src/gui/viewport.cpp8
-rw-r--r--src/gui/viewport.h9
-rw-r--r--src/gui/widgets/dropdown.cpp60
-rw-r--r--src/gui/widgets/dropdown.h29
-rw-r--r--src/gui/widgets/resizegrip.cpp9
-rw-r--r--src/gui/widgets/resizegrip.h3
-rw-r--r--src/gui/widgets/tab.cpp39
-rw-r--r--src/gui/widgets/tab.h8
-rw-r--r--src/gui/window.cpp16
-rw-r--r--src/gui/windowcontainer.h5
-rw-r--r--src/guichanfwd.h3
-rw-r--r--src/inventory.cpp42
-rw-r--r--src/itemshortcut.cpp17
-rw-r--r--src/joystick.cpp2
-rw-r--r--src/joystick.h6
-rw-r--r--src/keyboardconfig.cpp124
-rw-r--r--src/keyboardconfig.h20
-rw-r--r--src/localplayer.cpp9
-rw-r--r--src/localplayer.h10
-rw-r--r--src/log.cpp2
-rw-r--r--src/log.h1
-rw-r--r--src/main.cpp5
-rw-r--r--src/map.cpp5
-rw-r--r--src/map.h3
-rw-r--r--src/monster.cpp3
-rw-r--r--src/net/beinghandler.cpp1
-rw-r--r--src/net/buysellhandler.cpp12
-rw-r--r--src/net/charserverhandler.cpp45
-rw-r--r--src/net/chathandler.cpp5
-rw-r--r--src/net/equipmenthandler.cpp7
-rw-r--r--src/net/inventoryhandler.cpp10
-rw-r--r--src/net/loginhandler.cpp35
-rw-r--r--src/net/loginhandler.h1
-rw-r--r--src/net/maploginhandler.cpp8
-rw-r--r--src/net/network.cpp14
-rw-r--r--src/net/network.h3
-rw-r--r--src/net/npchandler.cpp2
-rw-r--r--src/net/partyhandler.cpp1
-rw-r--r--src/npc.cpp1
-rw-r--r--src/openglgraphics.cpp5
-rw-r--r--src/particle.cpp2
-rw-r--r--src/particle.h2
-rw-r--r--src/particlecontainer.cpp4
-rw-r--r--src/particlecontainer.h6
-rw-r--r--src/particleemitter.cpp5
-rw-r--r--src/particleemitter.h4
-rw-r--r--src/particleemitterprop.h1
-rw-r--r--src/party.cpp8
-rw-r--r--src/party.h1
-rw-r--r--src/player.cpp7
-rw-r--r--src/player.h2
-rw-r--r--src/player_relations.cpp7
-rw-r--r--src/player_relations.h5
-rw-r--r--src/recorder.cpp114
-rw-r--r--src/resources/animation.cpp2
-rw-r--r--src/resources/buddylist.h3
-rw-r--r--src/resources/colordb.cpp2
-rw-r--r--src/resources/dye.cpp1
-rw-r--r--src/resources/emotedb.cpp2
-rw-r--r--src/resources/image.cpp43
-rw-r--r--src/resources/image.h16
-rw-r--r--src/resources/imageloader.cpp1
-rw-r--r--src/resources/imagewriter.h2
-rw-r--r--src/resources/itemdb.cpp16
-rw-r--r--src/resources/itemdb.h2
-rw-r--r--src/resources/iteminfo.h12
-rw-r--r--src/resources/mapreader.cpp1
-rw-r--r--src/resources/mapreader.h2
-rw-r--r--src/resources/monsterdb.cpp2
-rw-r--r--src/resources/monsterdb.h2
-rw-r--r--src/resources/npcdb.cpp2
-rw-r--r--src/resources/resource.h3
-rw-r--r--src/resources/soundeffect.h3
-rw-r--r--src/simpleanimation.cpp10
-rw-r--r--src/simpleanimation.h11
-rw-r--r--src/text.cpp6
-rw-r--r--src/text.h8
-rw-r--r--src/textmanager.cpp14
-rw-r--r--src/textmanager.h5
-rw-r--r--src/textparticle.cpp2
-rw-r--r--src/textparticle.h2
-rw-r--r--src/utils/tostring.h15
225 files changed, 2048 insertions, 1791 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fc98ae64..513456aa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -81,12 +81,20 @@ SET(SRCS
gui/chatinput.h
gui/checkbox.cpp
gui/checkbox.h
+ gui/colour.cpp
+ gui/colour.h
gui/confirm_dialog.cpp
gui/confirm_dialog.h
gui/connection.cpp
gui/connection.h
gui/debugwindow.cpp
gui/debugwindow.h
+ gui/emotecontainer.cpp
+ gui/emotecontainer.h
+ gui/emoteshortcutcontainer.cpp
+ gui/emoteshortcutcontainer.h
+ gui/emotewindow.cpp
+ gui/emotewindow.h
gui/equipmentwindow.cpp
gui/equipmentwindow.h
gui/focushandler.cpp
@@ -108,9 +116,7 @@ SET(SRCS
gui/itempopup.cpp
gui/itempopup.h
gui/itemshortcutcontainer.cpp
- gui/itemshortcutcontainer.h
- gui/itemshortcutwindow.cpp
- gui/itemshortcutwindow.h
+ gui/itemshortcutcontainer.h\
gui/item_amount.cpp
gui/item_amount.h
gui/linkhandler.h
@@ -144,6 +150,8 @@ SET(SRCS
gui/progressbar.h
gui/radiobutton.cpp
gui/radiobutton.h
+ gui/recorder.cpp
+ gui/recorder.h
gui/register.cpp
gui/register.h
gui/scrollarea.cpp
@@ -152,10 +160,12 @@ SET(SRCS
gui/sdlinput.h
gui/sell.cpp
gui/sell.h
- gui/setup_audio.cpp
- gui/setup_audio.h
gui/setup.cpp
gui/setup.h
+ gui/setup_audio.cpp
+ gui/setup_audio.h
+ gui/setup_colours.cpp
+ gui/setup_colours.h
gui/setup_joystick.cpp
gui/setup_joystick.h
gui/setup_keyboard.cpp
@@ -169,6 +179,10 @@ SET(SRCS
gui/shop.h
gui/shoplistbox.cpp
gui/shoplistbox.h
+ gui/shortcutwindow.cpp
+ gui/shortcutwindow.h
+ gui/shortcutcontainer.cpp
+ gui/shortcutcontainer.h
gui/skill.cpp
gui/skill.h
gui/slider.cpp
@@ -187,6 +201,8 @@ SET(SRCS
gui/textfield.h
gui/trade.cpp
gui/trade.h
+ gui/truetypefont.cpp
+ gui/truetypefont.h
gui/updatewindow.h
gui/updatewindow.cpp
gui/viewport.cpp
@@ -223,6 +239,8 @@ SET(SRCS
net/network.h
net/npchandler.cpp
net/npchandler.h
+ net/partyhandler.cpp
+ net/partyhandler.h
net/playerhandler.cpp
net/playerhandler.h
net/protocol.cpp
@@ -299,11 +317,12 @@ SET(SRCS
configuration.h
effectmanager.cpp
effectmanager.h
+ emoteshortcut.cpp
+ emoteshortcut.h
engine.cpp
engine.h
equipment.cpp
equipment.h
- extensions.h
floor_item.cpp
floor_item.h
flooritemmanager.cpp
@@ -343,9 +362,13 @@ SET(SRCS
openglgraphics.h
particle.cpp
particle.h
+ particlecontainer.cpp
+ particlecontainer.h
particleemitter.cpp
particleemitter.h
particleemitterprop.h
+ party.cpp
+ party.h
player.cpp
player.h
player_relations.cpp
@@ -353,8 +376,6 @@ SET(SRCS
position.cpp
position.h
properties.h
- sdltruetypefont.cpp
- sdltruetypefont.hpp
serverinfo.h
shopitem.cpp
shopitem.h
@@ -363,6 +384,10 @@ SET(SRCS
sound.cpp
sound.h
sprite.h
+ text.cpp
+ text.h
+ textmanager.cpp
+ textmanager.h
textparticle.cpp
textparticle.h
tileset.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 84f33daf..ecf45945 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,8 +17,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
gui/browserbox.h \
gui/button.cpp \
gui/button.h \
- gui/buttonbox.cpp \
- gui/buttonbox.h \
gui/buy.cpp \
gui/buy.h \
gui/buysell.cpp \
@@ -92,8 +90,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
gui/npc_text.h \
gui/ok_dialog.cpp \
gui/ok_dialog.h \
- gui/truetypefont.cpp \
- gui/truetypefont.h \
gui/passwordfield.cpp \
gui/passwordfield.h \
gui/playerbox.cpp \
@@ -104,6 +100,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
gui/progressbar.h \
gui/radiobutton.cpp \
gui/radiobutton.h \
+ gui/recorder.cpp \
+ gui/recorder.h \
gui/register.cpp \
gui/register.h \
gui/scrollarea.cpp \
@@ -153,6 +151,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
gui/textfield.h \
gui/trade.cpp \
gui/trade.h \
+ gui/truetypefont.cpp \
+ gui/truetypefont.h \
gui/updatewindow.h \
gui/updatewindow.cpp \
gui/viewport.cpp \
@@ -274,7 +274,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
engine.h \
equipment.cpp \
equipment.h \
- extensions.h \
floor_item.cpp \
floor_item.h \
flooritemmanager.cpp \
@@ -328,8 +327,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
position.cpp \
position.h \
properties.h \
- recorder.cpp \
- recorder.h \
serverinfo.h \
shopitem.cpp \
shopitem.h \
diff --git a/src/being.cpp b/src/being.cpp
index dadc7357..e1ff5591 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -23,7 +23,7 @@
#include "animatedsprite.h"
#include "configuration.h"
-#include "equipment.h"
+#include "effectmanager.h"
#include "game.h"
#include "graphics.h"
#include "localplayer.h"
@@ -34,7 +34,12 @@
#include "text.h"
#include "statuseffect.h"
+#include "gui/speechbubble.h"
+
+#include "resources/colordb.h"
+
#include "resources/emotedb.h"
+#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
@@ -44,8 +49,9 @@
#include "gui/speechbubble.h"
#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/tostring.h"
+#include "utils/gettext.h"
+#include "utils/tostring.h"
+#include "utils/trim.h"
#include "utils/xml.h"
#include <cassert>
@@ -71,7 +77,6 @@ Being::Being(int id, int job, Map *map):
mWalkTime(0),
mEmotion(0), mEmotionTime(0),
mAttackSpeed(350),
- mEquipment(new Equipment()),
mId(id),
mWalkSpeed(150),
mDirection(DOWN),
@@ -183,14 +188,7 @@ void Being::setSpeech(const std::string &text, Uint32 time)
mSpeech = text;
// Trim whitespace
- while (mSpeech[0] == ' ')
- {
- mSpeech = mSpeech.substr(1, mSpeech.size());
- }
- while (mSpeech[mSpeech.size()] == ' ')
- {
- mSpeech = mSpeech.substr(0, mSpeech.size() - 1);
- }
+ trim(mSpeech);
// check for links
std::string::size_type start = mSpeech.find('[');
@@ -206,8 +204,11 @@ void Being::setSpeech(const std::string &text, Uint32 time)
}
std::string::size_type position = mSpeech.find('|');
- mSpeech.erase(end, 1);
- mSpeech.erase(start, (position - start) + 1);
+ if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@')
+ {
+ mSpeech.erase(end, 1);
+ mSpeech.erase(start, (position - start) + 1);
+ }
position = mSpeech.find('@');
while (position != std::string::npos)
@@ -221,7 +222,7 @@ void Being::setSpeech(const std::string &text, Uint32 time)
}
if (mSpeech != "")
- mSpeechTime = 500;
+ mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME;
}
void Being::takeDamage(int amount)
@@ -519,7 +520,7 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
emotionSet[emotionIndex]->draw(graphics, px, py);
}
-void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY)
+void Being::drawSpeech(int offsetX, int offsetY)
{
int px = mPx + offsetX;
int py = mPy + offsetY;
diff --git a/src/being.h b/src/being.h
index e8badaed..3c3a9b73 100644
--- a/src/being.h
+++ b/src/being.h
@@ -22,41 +22,44 @@
#ifndef BEING_H
#define BEING_H
-#include <list>
-#include <memory>
+#include <guichan/color.hpp>
+
#include <SDL_types.h>
+
#include <set>
#include <string>
#include <vector>
-#include <bitset>
-#include "animatedsprite.h"
-#include "effectmanager.h"
-#include "map.h"
#include "particlecontainer.h"
#include "position.h"
#include "sprite.h"
-#include "gui/speechbubble.h"
-
-#include "resources/colordb.h"
+#include "resources/spritedef.h"
#define FIRST_IGNORE_EMOTE 14
#define STATUS_EFFECTS 32
+#define SPEECH_TIME 500
+#define SPEECH_MAX_TIME 1000
+
class AnimatedSprite;
-class Equipment;
+class Image;
class ItemInfo;
class Item;
class Map;
class Graphics;
class Particle;
+class Position;
class SpeechBubble;
class Text;
class StatusEffect;
-enum Gender {
+typedef std::list<Sprite*> Sprites;
+typedef Sprites::iterator SpriteIterator;
+
+enum Gender
+{
GENDER_MALE = 0,
GENDER_FEMALE = 1,
GENDER_UNSPECIFIED = 2
@@ -65,7 +68,8 @@ enum Gender {
class Being : public Sprite
{
public:
- enum Type {
+ enum Type
+ {
UNKNOWN,
PLAYER,
NPC,
@@ -75,7 +79,8 @@ class Being : public Sprite
/**
* Action the being is currently performing.
*/
- enum Action {
+ enum Action
+ {
STAND,
WALK,
ATTACK,
@@ -84,7 +89,8 @@ class Being : public Sprite
HURT
};
- enum Sprite {
+ enum Sprite
+ {
BASE_SPRITE = 0,
SHOE_SPRITE,
BOTTOMCLOTHES_SPRITE,
@@ -100,7 +106,8 @@ class Being : public Sprite
VECTOREND_SPRITE
};
- enum TargetCursorSize {
+ enum TargetCursorSize
+ {
TC_SMALL = 0,
TC_MEDIUM,
TC_LARGE,
@@ -149,7 +156,7 @@ class Being : public Sprite
* @param text The text that should appear.
* @param time The amount of time the text should stay in milliseconds.
*/
- void setSpeech(const std::string &text, Uint32 time);
+ void setSpeech(const std::string &text, Uint32 time = 500);
/**
* Puts a damage bubble above this being.
@@ -243,7 +250,7 @@ class Being : public Sprite
/**
* Draws the speech text above the being.
*/
- void drawSpeech(Graphics *graphics, int offsetX, int offsetY);
+ void drawSpeech(int offsetX, int offsetY);
/**
* Draws the emotion picture above the being.
@@ -401,8 +408,6 @@ class Being : public Sprite
// Target cursor being used by the being
Image *mTargetCursor;
- const std::auto_ptr<Equipment> mEquipment;
-
static int getHairColorsNr();
static int getHairStylesNr();
diff --git a/src/configlistener.h b/src/configlistener.h
index 51d58144..ec7d6a2c 100644
--- a/src/configlistener.h
+++ b/src/configlistener.h
@@ -22,7 +22,7 @@
#ifndef CONFIGLISTENER_H
#define CONFIGLISTENER_H
-#include <iosfwd>
+#include <string>
/**
* The listener interface for receiving notifications about changes to
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 31c18c1d..6815ea03 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <libxml/xmlwriter.h>
-
#include "configlistener.h"
#include "configuration.h"
#include "log.h"
diff --git a/src/configuration.h b/src/configuration.h
index 91ae536b..4d28008d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -22,8 +22,9 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
-#include <cassert>
#include <libxml/xmlwriter.h>
+
+#include <cassert>
#include <list>
#include <map>
#include <string>
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 8e029cf0..f004a450 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -20,6 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "being.h"
#include "effectmanager.h"
#include "log.h"
#include "particle.h"
@@ -69,7 +70,6 @@ bool EffectManager::trigger(int id, Being* being)
{
if ((*i).id == id)
{
- printf("Found effect, playing it");
rValue = true;
if (!(*i).GFX.empty())
{
@@ -92,7 +92,6 @@ bool EffectManager::trigger(int id, int x, int y)
{
if ((*i).id == id)
{
- printf("Found effect, playing it");
rValue = true;
if (!(*i).GFX.empty())
particleEngine->addEffect((*i).GFX, x, y);
diff --git a/src/effectmanager.h b/src/effectmanager.h
index 90fbce34..12fe3133 100644
--- a/src/effectmanager.h
+++ b/src/effectmanager.h
@@ -26,15 +26,14 @@
#include <list>
#include <string>
-#include "being.h"
-
class Being;
class EffectManager
{
- public:
- struct EffectDescription {
+ public:
+ struct EffectDescription
+ {
int id;
std::string GFX;
std::string SFX;
diff --git a/src/engine.cpp b/src/engine.cpp
index 50158c24..39b9b3ec 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -19,18 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <list>
-
-#include "being.h"
#include "beingmanager.h"
-#include "configuration.h"
#include "engine.h"
#include "flooritemmanager.h"
#include "game.h"
-#include "graphics.h"
#include "localplayer.h"
#include "log.h"
-#include "main.h"
#include "map.h"
#include "particle.h"
#include "sound.h"
@@ -43,14 +37,10 @@
#include "net/protocol.h"
#include "resources/mapreader.h"
-#include "resources/monsterdb.h"
#include "resources/resourcemanager.h"
-#include "utils/dtor.h"
#include "utils/tostring.h"
-extern Minimap *minimap;
-
char itemCurrenyQ[10] = "0";
Engine::Engine(Network *network):
diff --git a/src/engine.h b/src/engine.h
index f2852351..7ad6d894 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -22,7 +22,6 @@
#ifndef _ENGINE_H
#define _ENGINE_H
-#include <iosfwd>
#include <string>
class Map;
@@ -52,7 +51,6 @@ class Engine
const std::string &getCurrentMapName() { return mMapName; }
-
/**
* Sets the currently active map.
*/
diff --git a/src/equipment.cpp b/src/equipment.cpp
index 743c0a90..cb7acd44 100644
--- a/src/equipment.cpp
+++ b/src/equipment.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "equipment.h"
#include "item.h"
#include "inventory.h"
diff --git a/src/extensions.h b/src/extensions.h
deleted file mode 100644
index dad00cfb..00000000
--- a/src/extensions.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * eAthena extension handling
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef EXTENSIONS_H
-#define EXTENSIONS_H
-
-struct EXTENSIONS
-{
- bool aethyra_inventory;
- bool aethyra_spells;
- bool aethyra_misc;
-};
-
-extern struct EXTENSIONS extensions;
-
-#endif
diff --git a/src/floor_item.cpp b/src/floor_item.cpp
index 0c4c1c10..fbe606b4 100644
--- a/src/floor_item.cpp
+++ b/src/floor_item.cpp
@@ -20,8 +20,12 @@
*/
#include "floor_item.h"
+#include "graphics.h"
+#include "item.h"
#include "map.h"
+#include "resources/image.h"
+
FloorItem::FloorItem(unsigned int id,
unsigned int itemId,
unsigned short x,
@@ -46,3 +50,15 @@ FloorItem::~FloorItem()
delete mItem;
}
+
+unsigned int FloorItem::getItemId() const
+{
+ return mItem->getId();
+}
+
+void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
+{
+ graphics->drawImage(mItem->getImage(),
+ mX * 32 + offsetX,
+ mY * 32 + offsetY);
+}
diff --git a/src/floor_item.h b/src/floor_item.h
index a7299bfb..444c756a 100644
--- a/src/floor_item.h
+++ b/src/floor_item.h
@@ -22,11 +22,16 @@
#ifndef FLOORITEM_H
#define FLOORITEM_H
-#include "graphics.h"
-#include "item.h"
-#include "map.h"
+#include <list>
+
#include "sprite.h"
-#include "resources/image.h"
+
+class Graphics;
+class Image;
+class Item;
+class Map;
+
+typedef std::list<Sprite*> Sprites;
/**
* An item lying on the floor.
@@ -56,7 +61,7 @@ class FloorItem : public Sprite
/**
* Returns the item id.
*/
- unsigned int getItemId() const { return mItem->getId(); }
+ unsigned int getItemId() const;
/**
* Returns the x coordinate.
@@ -80,12 +85,7 @@ class FloorItem : public Sprite
*
* @see Sprite::draw(Graphics, int, int)
*/
- void draw(Graphics *graphics, int offsetX, int offsetY) const
- {
- graphics->drawImage(mItem->getImage(),
- mX * 32 + offsetX,
- mY * 32 + offsetY);
- }
+ void draw(Graphics *graphics, int offsetX, int offsetY) const;
private:
unsigned int mId;
diff --git a/src/game.cpp b/src/game.cpp
index 0477c4f1..48ca1c73 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -25,9 +25,9 @@
#include <string>
#include <guichan/exception.hpp>
-#include <guichan/sdl/sdlinput.hpp>
#include "beingmanager.h"
+#include "configuration.h"
#include "effectmanager.h"
#include "emoteshortcut.h"
#include "engine.h"
@@ -55,7 +55,6 @@
#include "gui/help.h"
#include "gui/inventorywindow.h"
#include "gui/shortcutwindow.h"
-#include "gui/shortcutcontainer.h"
#include "gui/itemshortcutcontainer.h"
#include "gui/menuwindow.h"
#include "gui/minimap.h"
@@ -73,7 +72,6 @@
#include "gui/trade.h"
#include "gui/viewport.h"
-#include "net/protocol.h"
#include "net/beinghandler.h"
#include "net/buysellhandler.h"
#include "net/chathandler.h"
@@ -87,14 +85,11 @@
#include "net/protocol.h"
#include "net/skillhandler.h"
#include "net/tradehandler.h"
-#include "net/messageout.h"
#include "resources/imagewriter.h"
#include "utils/gettext.h"
-extern Graphics *graphics;
-
class Map;
std::string map_path;
@@ -213,7 +208,7 @@ void createGuiWindows(Network *network)
skillDialog = new SkillDialog();
setupWindow = new Setup();
minimap = new Minimap();
- equipmentWindow = new EquipmentWindow(player_node->mEquipment.get());
+ equipmentWindow = new EquipmentWindow();
tradeWindow = new TradeWindow(network);
helpWindow = new HelpWindow();
debugWindow = new DebugWindow();
@@ -504,55 +499,6 @@ void Game::handleInput()
keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE);
return;
}
- // Keys pressed together with Alt/Meta
- // Emotions and some internal gui windows
-#ifndef __APPLE__
- if (event.key.keysym.mod & KMOD_LALT)
-#else
- if (event.key.keysym.mod & KMOD_LMETA)
-#endif
- {
- switch (event.key.keysym.sym)
- {
- case SDLK_p:
- // Screenshot (picture, hence the p)
- saveScreenshot();
- used = true;
- break;
-
- default:
- break;
-
- case SDLK_f:
- // Find path to mouse (debug purpose)
- viewport->toggleDebugPath();
- used = true;
- break;
-
- case SDLK_t:
- // Toggle accepting of incoming trade requests
- unsigned int deflt = player_relations.getDefault();
- if (deflt & PlayerRelation::TRADE)
- {
- chatWindow->chatLog(
- _("Ignoring incoming trade requests"),
- BY_SERVER);
- deflt &= ~PlayerRelation::TRADE;
- }
- else
- {
- chatWindow->chatLog(
- _("Accepting incoming trade requests"),
- BY_SERVER);
- deflt |= PlayerRelation::TRADE;
- }
-
- player_relations.setDefault(deflt);
-
- used = true;
- break;
- }
- }
// Mode switch to emotes
if (keyboard.isKeyActive(keyboard.KEY_EMOTE))
@@ -566,16 +512,69 @@ void Game::handleInput()
return;
}
}
- switch (event.key.keysym.sym)
+
+ if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT) ||
+ keyboard.isKeyActive(keyboard.KEY_OK))
+ {
+ // Input chat window
+ if (!(chatWindow->isInputFocused() ||
+ deathNotice != NULL ||
+ weightNotice != NULL))
+ {
+ // Quit by pressing Enter if the exit confirm is there
+ if (exitConfirm &&
+ keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
+ done = true;
+ // Close the Browser if opened
+ else if (helpWindow->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
+ helpWindow->setVisible(false);
+ // Close the config window, cancelling changes if opened
+ else if (setupWindow->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
+ setupWindow->action(gcn::ActionEvent(NULL, "cancel"));
+ // Submits the text and proceeds to the next dialog
+ else if (npcStringDialog->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_OK))
+ npcStringDialog->action(gcn::ActionEvent(NULL, "ok"));
+ // Proceed to the next dialog option, or close the window
+ else if (npcTextDialog->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_OK))
+ npcTextDialog->action(gcn::ActionEvent(NULL, "ok"));
+ // Choose the currently highlighted dialogue option
+ else if (npcListDialog->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_OK))
+ npcListDialog->action(gcn::ActionEvent(NULL, "ok"));
+ // Submits the text and proceeds to the next dialog
+ else if (npcIntegerDialog->isVisible() &&
+ keyboard.isKeyActive(keyboard.KEY_OK))
+ npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok"));
+ else if (!(keyboard.getKeyValue(
+ KeyboardConfig::KEY_TOGGLE_CHAT) ==
+ keyboard.getKeyValue(
+ KeyboardConfig::KEY_OK) &&
+ (npcStringDialog->isVisible() ||
+ npcTextDialog->isVisible() ||
+ npcListDialog->isVisible() ||
+ npcIntegerDialog->isVisible())))
+ {
+ chatWindow->requestChatFocus();
+ used = true;
+ }
+ }
+ }
+
+ const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
+ switch (tKey)
{
- case SDLK_PAGEUP:
+ case KeyboardConfig::KEY_SCROLL_CHAT_UP:
if (chatWindow->isVisible())
{
chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL);
used = true;
}
break;
- case SDLK_PAGEDOWN:
+ case KeyboardConfig::KEY_SCROLL_CHAT_DOWN:
if (chatWindow->isVisible())
{
chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL);
@@ -583,7 +582,7 @@ void Game::handleInput()
return;
}
break;
- case SDLK_F1:
+ case KeyboardConfig::KEY_WINDOW_HELP:
// In-game Help
if (helpWindow->isVisible())
helpWindow->setVisible(false);
@@ -594,35 +593,9 @@ void Game::handleInput()
}
used = true;
break;
-
- case SDLK_RETURN:
- // Input chat window
- if (chatWindow->isInputFocused() ||
- deathNotice != NULL ||
- weightNotice != NULL)
- {
- break;
- }
-
- // Quit by pressing Enter if the exit confirm is there
- if (exitConfirm)
- done = true;
- // Close the Browser if opened
- else if (helpWindow->isVisible())
- helpWindow->setVisible(false);
- // Close the config window, cancelling changes if opened
- else if (setupWindow->isVisible())
- setupWindow->action(gcn::ActionEvent(NULL, "cancel"));
- // Else, open the chat edit box
- else
- {
- chatWindow->requestChatFocus();
- used = true;
- }
- break;
// Quitting confirmation dialog
- case SDLK_ESCAPE:
- if (!exitConfirm)
+ case KeyboardConfig::KEY_QUIT:
+ if (!exitConfirm)
{
exitConfirm = new ConfirmDialog( _("Quit"),
_("Are you sure you "
@@ -635,7 +608,6 @@ void Game::handleInput()
exitConfirm->action(gcn::ActionEvent(NULL, _("no")));
}
break;
-
default:
break;
}
@@ -747,6 +719,38 @@ void Game::handleInput()
case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT:
requestedWindow = emoteShortcutWindow;
break;
+ case KeyboardConfig::KEY_SCREENSHOT:
+ // Screenshot (picture, hence the p)
+ saveScreenshot();
+ used = true;
+ break;
+ case KeyboardConfig::KEY_PATHFIND:
+ // Find path to mouse (debug purpose)
+ viewport->toggleDebugPath();
+ used = true;
+ break;
+ case KeyboardConfig::KEY_TRADE:
+ // Toggle accepting of incoming trade requests
+ unsigned int deflt = player_relations.getDefault();
+ if (deflt & PlayerRelation::TRADE)
+ {
+ chatWindow->chatLog(
+ _("Ignoring incoming trade requests"),
+ BY_SERVER);
+ deflt &= ~PlayerRelation::TRADE;
+ }
+ else
+ {
+ chatWindow->chatLog(
+ _("Accepting incoming trade requests"),
+ BY_SERVER);
+ deflt |= PlayerRelation::TRADE;
+ }
+
+ player_relations.setDefault(deflt);
+
+ used = true;
+ break;
}
}
diff --git a/src/game.h b/src/game.h
index 26ccc90b..d7d2a562 100644
--- a/src/game.h
+++ b/src/game.h
@@ -22,14 +22,10 @@
#ifndef GAME_H
#define GAME_H
-#include <iosfwd>
#include <memory>
#include "configlistener.h"
-#define SPEECH_TIME 80
-#define SPEECH_MAX_TIME 100
-
class MessageHandler;
class Network;
diff --git a/src/graphics.h b/src/graphics.h
index 8009ceda..172032dc 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -46,14 +46,16 @@ struct SDL_Surface;
* Sections 0, 2, 6 and 8 will remain as is. 1, 3, 4, 5 and 7 will be
* repeated to fit the size of the widget.
*/
-struct ImageRect {
+struct ImageRect
+{
Image *grid[9];
};
/**
* A central point of control for graphics.
*/
-class Graphics : public gcn::SDLGraphics {
+class Graphics : public gcn::SDLGraphics
+{
public:
/**
* Constructor.
@@ -151,4 +153,6 @@ class Graphics : public gcn::SDLGraphics {
bool mFullscreen, mHWAccel;
};
+extern Graphics *graphics;
+
#endif
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index dbecf72b..65659df6 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -21,15 +21,17 @@
#include <algorithm>
+#include <guichan/graphics.hpp>
+
#include "browserbox.h"
#include "colour.h"
#include "linkhandler.h"
#include "truetypefont.h"
-BrowserBox::BrowserBox(unsigned int mode):
+BrowserBox::BrowserBox(unsigned int mode, bool opaque):
gcn::Widget(),
mMode(mode), mHighMode(UNDERLINE | BACKGROUND),
- mOpaque(true),
+ mOpaque(opaque),
mUseLinksAndUserColors(true),
mSelectedLink(-1),
mMaxRows(0)
@@ -122,7 +124,18 @@ void BrowserBox::addRow(const std::string &row)
//discard older rows when a row limit has been set
if (mMaxRows > 0)
{
- while (mTextRows.size() > mMaxRows) mTextRows.pop_front();
+ while (mTextRows.size() > mMaxRows)
+ {
+ mTextRows.pop_front();
+ for (unsigned int i = 0; i < mLinks.size(); i++)
+ {
+ mLinks[i].y1 -= font->getHeight();
+ mLinks[i].y2 -= font->getHeight();
+
+ if (mLinks[i].y1 < 0)
+ mLinks.erase(mLinks.begin() + i);
+ }
+ }
}
// Auto size mode
@@ -238,9 +251,10 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mSelectedLink >= 0)
{
+ bool valid;
if ((mHighMode & BACKGROUND))
{
- graphics->setColor(gcn::Color(HIGHLIGHT));
+ graphics->setColor(gcn::Color(textColour->getColour('H', valid)));
graphics->fillRectangle(gcn::Rectangle(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y1,
@@ -251,7 +265,6 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & UNDERLINE))
{
- bool valid;
graphics->setColor(gcn::Color(textColour->getColour('<', valid)));
graphics->drawLine(
mLinks[mSelectedLink].x1,
@@ -263,6 +276,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
int x = 0, y = 0;
int wrappedLines = 0;
+ int link = 0;
TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont());
graphics->setColor(BLACK);
@@ -320,6 +334,12 @@ void BrowserBox::draw(gcn::Graphics *graphics)
int rgb = textColour->getColour(c, valid);
if (c == '<')
{
+ const int size = mLinks[link].x2 - mLinks[link].x1;
+ mLinks[link].x1 = x;
+ mLinks[link].y1 = y;
+ mLinks[link].x2 = mLinks[link].x1 + size;
+ mLinks[link].y2 = y + font->getHeight();
+ link++;
prevColor = selColor;
}
if (valid)
diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h
index 4bdf224b..5dde402e 100644
--- a/src/gui/browserbox.h
+++ b/src/gui/browserbox.h
@@ -22,15 +22,12 @@
#ifndef BROWSERBOX_H
#define BROWSERBOX_H
-#include <iosfwd>
+#include <list>
#include <vector>
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
-#include "../guichanfwd.h"
-#include "../main.h"
-
class LinkHandler;
struct BROWSER_LINK {
@@ -49,7 +46,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
/**
* Constructor.
*/
- BrowserBox(unsigned int mode = AUTO_SIZE);
+ BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true);
/**
* Destructor.
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 9b624015..1d3a04e4 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -19,8 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/exception.hpp>
+#include <guichan/font.hpp>
+
#include "button.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -28,13 +32,8 @@
#include "../utils/dtor.h"
-#include <guichan/exception.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/font.hpp>
-
-#include <algorithm>
-
int Button::mInstances = 0;
+float Button::mAlpha = config.getValue("guialpha", 0.8);
enum{
BUTTON_STANDARD, // 0
@@ -100,6 +99,7 @@ void Button::init()
data[x].gridX, data[y].gridY,
data[x + 1].gridX - data[x].gridX + 1,
data[y + 1].gridY - data[y].gridY + 1);
+ button[mode].grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -126,17 +126,25 @@ void Button::draw(gcn::Graphics *graphics)
{
int mode;
- if (!isEnabled()) {
+ if (!isEnabled())
mode = BUTTON_DISABLED;
- }
- else if (isPressed() || mIsLogged) {
+ else if (isPressed() || mIsLogged)
mode = BUTTON_PRESSED;
- }
- else if (mHasMouse || isFocused()) {
+ else if (mHasMouse || isFocused())
mode = BUTTON_HIGHLIGHTED;
- }
- else {
+ else
mode = BUTTON_STANDARD;
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ button[BUTTON_DISABLED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_PRESSED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_HIGHLIGHTED].grid[a]->setAlpha(mAlpha);
+ button[BUTTON_STANDARD].grid[a]->setAlpha(mAlpha);
+ }
}
static_cast<Graphics*>(graphics)->
@@ -147,7 +155,8 @@ void Button::draw(gcn::Graphics *graphics)
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
- switch (getAlignment()) {
+ switch (getAlignment())
+ {
case gcn::Graphics::LEFT:
textX = 4;
break;
@@ -163,10 +172,8 @@ void Button::draw(gcn::Graphics *graphics)
graphics->setFont(getFont());
- if (isPressed()) {
+ if (isPressed())
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
- }
- else {
+ else
graphics->drawText(getCaption(), textX, textY, getAlignment());
- }
}
diff --git a/src/gui/button.h b/src/gui/button.h
index d8ed9fa7..abaf5c43 100644
--- a/src/gui/button.h
+++ b/src/gui/button.h
@@ -22,12 +22,8 @@
#ifndef BUTTON_H
#define BUTTON_H
-#include <iosfwd>
-
#include <guichan/widgets/button.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
/**
@@ -71,6 +67,7 @@ class Button : public gcn::Button
static ImageRect button[4]; /**< Button state graphics */
static int mInstances; /**< Number of button instances */
+ static float mAlpha;
bool mIsLogged; /**< Makes the button appear pressed all the time */
};
diff --git a/src/gui/buttonbox.cpp b/src/gui/buttonbox.cpp
deleted file mode 100644
index 44d65f58..00000000
--- a/src/gui/buttonbox.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "button.h"
-#include "buttonbox.h"
-
-ButtonBox::ButtonBox(const std::string &title, const std::string &buttonTxt,
- ButtonBoxListener *listener) :
- Window(title),
- mListener(listener)
-{
- Button *button = new Button(buttonTxt, "activate", this);
- setContentSize(button->getWidth() + 10,
- button->getHeight() + 10);
- button->setPosition(5, 5);
- add(button);
-}
-
-void ButtonBox::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "activate")
- {
- mListener->buttonBoxRespond();
- }
-}
diff --git a/src/gui/buttonbox.h b/src/gui/buttonbox.h
deleted file mode 100644
index 91dfad34..00000000
--- a/src/gui/buttonbox.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef BUTTONBOX_H
-#define BUTTONBOX_H
-
-#include <string>
-
-#include <guichan/actionlistener.hpp>
-
-#include "window.h"
-
-#include "../guichanfwd.h"
-
-class ButtonBoxListener
-{
- public:
- /*
- * function that ButtonBox calls when the button has been pressed
- */
- virtual void buttonBoxRespond() = 0;
-};
-
-class ButtonBox : public Window, public gcn::ActionListener
-{
- public:
- /*
- * Constructor.
- *
- * @param title is the text that appears at the top of the box
- * @param buttonTxt is the text that appears on the button
- * @param listener points to the class that should respond to the
- * button press
- */
- ButtonBox(const std::string &title, const std::string &buttonTxt,
- ButtonBoxListener *listener);
-
- /*
- * called when the button is pressed
- *
- * @param event is the event that is generated
- */
- void action(const gcn::ActionEvent &event);
-
- private:
- ButtonBoxListener *mListener;
-};
-
-#endif
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 423918ce..0f1cfede 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -25,9 +25,9 @@
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
-#include "window.h"
+#include <SDL_types.h>
-#include "../guichanfwd.h"
+#include "window.h"
class Network;
class ShopItems;
@@ -40,7 +40,7 @@ class ListBox;
* \ingroup Interface
*/
class BuyDialog : public Window, public gcn::ActionListener,
- gcn::SelectionListener
+ public gcn::SelectionListener
{
public:
/**
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index 60a6398d..e3cdc52a 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -26,8 +26,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* A dialog to choose between buying or selling at a shop.
*
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index dcb05aa1..8de4f5a7 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -22,6 +22,7 @@
#include <string>
#include <guichan/font.hpp>
+
#include <guichan/widgets/label.hpp>
#include "button.h"
@@ -40,6 +41,8 @@
#include "../net/charserverhandler.h"
#include "../net/messageout.h"
+#include "../resources/colordb.h"
+
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
#include "../utils/trim.h"
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 5d4ecfa8..23de061d 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -26,9 +26,8 @@
#include "window.h"
-#include "../guichanfwd.h"
-#include "../lockedarray.h"
#include "../being.h"
+#include "../lockedarray.h"
class LocalPlayer;
class Network;
@@ -109,14 +108,12 @@ class CharCreateDialog : public Window, public gcn::ActionListener
*/
~CharCreateDialog();
- void
- action(const gcn::ActionEvent &event);
+ void action(const gcn::ActionEvent &event);
/**
* Unlocks the dialog, enabling the create character button again.
*/
- void
- unlock();
+ void unlock();
private:
/**
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 2e823b60..bc096379 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -28,10 +28,7 @@
#include "../main.h"
#include "../serverinfo.h"
-#include "../net/network.h" // TODO this is just for iptostring, move that?
-
#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
#include "../utils/tostring.h"
extern SERVER_INFO **server_info;
@@ -39,7 +36,8 @@ extern SERVER_INFO **server_info;
/**
* The list model for the server list.
*/
-class ServerListModel : public gcn::ListModel {
+class ServerListModel : public gcn::ListModel
+{
public:
virtual ~ServerListModel() {};
@@ -80,13 +78,12 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState):
add(mOkButton);
add(mCancelButton);
- if (n_server == 0) {
+ if (n_server == 0)
// Disable Ok button
mOkButton->setEnabled(false);
- } else {
+ else
// Select first server
mServerList->setSelected(1);
- }
setLocationRelativeTo(getParent());
setVisible(true);
@@ -100,7 +97,8 @@ ServerSelectDialog::~ServerSelectDialog()
void ServerSelectDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "ok") {
+ if (event.getId() == "ok")
+ {
mOkButton->setEnabled(false);
const SERVER_INFO *si = server_info[mServerList->getSelected()];
mLoginData->hostname = iptostring(si->address);
@@ -108,9 +106,8 @@ void ServerSelectDialog::action(const gcn::ActionEvent &event)
mLoginData->updateHost = si->updateHost;
state = mNextState;
}
- else if (event.getId() == "cancel") {
+ else if (event.getId() == "cancel")
state = LOGIN_STATE;
- }
}
int ServerListModel::getNumberOfElements()
diff --git a/src/gui/char_server.h b/src/gui/char_server.h
index 9419c92d..49a5b47b 100644
--- a/src/gui/char_server.h
+++ b/src/gui/char_server.h
@@ -27,8 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class LoginData;
class ServerListModel;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 4fb92ac5..1c0cea13 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -19,15 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-#include <fstream>
-
#include <guichan/focushandler.hpp>
#include "browserbox.h"
#include "chat.h"
#include "chatinput.h"
#include "itemlinkhandler.h"
+#include "recorder.h"
#include "scrollarea.h"
#include "sdlinput.h"
#include "windowcontainer.h"
@@ -36,11 +34,9 @@
#include "../beingmanager.h"
#include "../configuration.h"
-#include "../extensions.h"
#include "../game.h"
#include "../localplayer.h"
#include "../party.h"
-#include "../recorder.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -75,8 +71,6 @@ Window(""), mNetwork(network), mTmpVisible(false)
mTextOutput->setLinkHandler(mItemLinkHandler);
mScrollArea = new ScrollArea(mTextOutput);
- mScrollArea->setPosition(mScrollArea->getFrameSize(),
- mScrollArea->getFrameSize());
mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
@@ -344,6 +338,11 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
* require server handling by proper packet. Probably
* those if elses should be replaced by protocol calls */
+ trim(msg);
+
+ if (msg.compare("") == 0)
+ return;
+
// Send party message
if (msg.at(0) == mPartyPrefix)
{
@@ -379,14 +378,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
std::string temp = msg.substr(start+1, end - start - 1);
- while (temp[0] == ' ')
- {
- temp = temp.substr(1, temp.size());
- }
- while (temp[temp.size()] == ' ')
- {
- temp = temp.substr(0, temp.size() - 1);
- }
+ trim(temp);
for (unsigned int i = 0; i < temp.size(); i++)
{
@@ -394,10 +386,13 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
}
const ItemInfo itemInfo = ItemDB::get(temp);
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
+ if (itemInfo.getName() != _("Unknown item"))
+ {
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+ }
}
start = msg.find('[', start + 1);
}
@@ -440,7 +435,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
}
else if (command == "help")
{
- msg.erase(0, 6);
trim(msg);
std::size_t space = msg.find(" ");
std::string msg1;
@@ -480,7 +474,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
else if (command == "whisper" || command == "msg" || command == "w")
whisper(nick, msg);
else if (command == "record")
- mRecorder->respond(msg);
+ mRecorder->changeRecordingStatus(msg);
else if (command == "toggle")
{
if (msg == "")
@@ -540,32 +534,27 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
* This will eventually be replaced by a GUI, so
* we don't need to get too sophisticated
*/
- if (extensions.aethyra_spells)
+ MessageOut outMsg(mNetwork);
+ if (msg == "heal")
{
- MessageOut outMsg(mNetwork);
- if (msg == "heal")
- {
- outMsg.writeInt16(0x03f3);
- outMsg.writeInt16(0x01);
- outMsg.writeInt32(0);
- outMsg.writeInt8(0);
- outMsg.writeInt8(0);
- outMsg.writeString("", 24);
- }
- else if (msg == "gather")
- {
- outMsg.writeInt16(0x03f3);
- outMsg.writeInt16(0x02);
- outMsg.writeInt32(0);
- outMsg.writeInt8(0);
- outMsg.writeInt8(0);
- outMsg.writeString("", 24);
- }
- else
- chatLog(_("No such spell!"), BY_SERVER);
+ outMsg.writeInt16(0x03f3);
+ outMsg.writeInt16(0x01);
+ outMsg.writeInt32(0);
+ outMsg.writeInt8(0);
+ outMsg.writeInt8(0);
+ outMsg.writeString("", 24);
+ }
+ else if (msg == "gather")
+ {
+ outMsg.writeInt16(0x03f3);
+ outMsg.writeInt16(0x02);
+ outMsg.writeInt32(0);
+ outMsg.writeInt8(0);
+ outMsg.writeInt8(0);
+ outMsg.writeString("", 24);
}
else
- chatLog(_("The current server doesn't support spells"), BY_SERVER);
+ chatLog(_("No such spell!"), BY_SERVER);
}
else if (command == "present")
{
@@ -745,10 +734,10 @@ void ChatWindow::setInputText(std::string input_str)
requestChatFocus();
}
-void ChatWindow::addItemText(int itemId, const std::string &item)
+void ChatWindow::addItemText(const std::string &item)
{
std::ostringstream text;
- text << "[@@" << itemId << "|" << item << "@@] ";
+ text << "[" << item << "] ";
mChatInput->setText(mChatInput->getText() + text.str());
requestChatFocus();
}
@@ -805,10 +794,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2)
chatLog(_("/announce: Global announcement (GM only)"), BY_SERVER);
chatLog(_("/clear: Clears this window"), BY_SERVER);
chatLog(_("/help: Display this help"), BY_SERVER);
- mParty->help();
+ chatLog(_("/party <command> <params>: Party commands."), BY_SERVER);
chatLog(_("/msg <nick> <message>: Alternate form for /whisper"), BY_SERVER);
chatLog(_("/present: Get list of players present"), BY_SERVER);
- mRecorder->help();
+ chatLog(_("/record <filename>: Start recording the chat to an"
+ " external file."), BY_SERVER);
chatLog(_("/toggle: Determine whether <return> toggles the chat log."),
BY_SERVER);
chatLog(_("/where: Display map name"), BY_SERVER);
@@ -852,7 +842,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2)
}
else if (msg1 == "record")
{
- mRecorder->help(msg2);
+ chatLog(_("Command: /record <filename>"), BY_SERVER);
+ chatLog(_("This command starts recording the chat log to the file "
+ "<filename>."), BY_SERVER);
+ chatLog(_("Command: /record"), BY_SERVER);
+ chatLog(_("This command finishes a recording session."), BY_SERVER);
}
else if (msg1 == "toggle")
{
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 176fccb7..2fadb014 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -22,7 +22,6 @@
#ifndef CHAT_H
#define CHAT_H
-#include <fstream>
#include <list>
#include <string>
@@ -31,8 +30,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class BrowserBox;
class Network;
class Recorder;
@@ -182,7 +179,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
void setInputText(std::string input_str);
/** Called to add item to chat */
- void addItemText(int itemid, const std::string &item);
+ void addItemText(const std::string &item);
/** Override to reset mTmpVisible */
void setVisible(bool visible);
diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h
index d98e120b..a4a50502 100644
--- a/src/gui/chatinput.h
+++ b/src/gui/chatinput.h
@@ -26,8 +26,6 @@
#include "textfield.h"
-#include "../guichanfwd.h"
-
/**
* The chat input hides when it loses focus. It is also invisible by default.
*/
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index b8fca2b8..511ed34c 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -21,12 +21,14 @@
#include "checkbox.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
int CheckBox::instances = 0;
+float CheckBox::mAlpha = config.getValue("guialpha", 0.8);
Image *CheckBox::checkBoxNormal;
Image *CheckBox::checkBoxChecked;
Image *CheckBox::checkBoxDisabled;
@@ -43,6 +45,13 @@ CheckBox::CheckBox(const std::string& caption, bool selected):
checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10);
checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10);
+ if (config.getValue("opengl", 0))
+ {
+ checkBoxNormal->setAlpha(mAlpha);
+ checkBoxChecked->setAlpha(mAlpha);
+ checkBoxDisabled->setAlpha(mAlpha);
+ checkBoxDisabledChecked->setAlpha(mAlpha);
+ }
checkBox->decRef();
}
@@ -66,16 +75,26 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
{
Image *box;
- if (isSelected()) {
- if (isEnabled()) {
+ if (isSelected())
+ {
+ if (isEnabled())
box = checkBoxChecked;
- } else {
+ else
box = checkBoxDisabledChecked;
- }
- } else if (isEnabled()) {
+ }
+ else if (isEnabled())
box = checkBoxNormal;
- } else {
+ else
box = checkBoxDisabled;
+
+ if (config.getValue("guialpha", 0.8) != mAlpha &&
+ config.getValue("opengl", 0))
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ checkBoxNormal->setAlpha(mAlpha);
+ checkBoxChecked->setAlpha(mAlpha);
+ checkBoxDisabled->setAlpha(mAlpha);
+ checkBoxDisabledChecked->setAlpha(mAlpha);
}
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h
index d92fc822..20adb43c 100644
--- a/src/gui/checkbox.h
+++ b/src/gui/checkbox.h
@@ -22,12 +22,8 @@
#ifndef CHECKBOX_H
#define CHECKBOX_H
-#include <iosfwd>
-
#include <guichan/widgets/checkbox.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
@@ -35,7 +31,8 @@ class Image;
*
* \ingroup GUI
*/
-class CheckBox : public gcn::CheckBox {
+class CheckBox : public gcn::CheckBox
+{
public:
/**
* Constructor.
@@ -54,6 +51,7 @@ class CheckBox : public gcn::CheckBox {
private:
static int instances;
+ static float mAlpha;
static Image *checkBoxNormal;
static Image *checkBoxChecked;
static Image *checkBoxDisabled;
diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp
index 78e35e97..cdb5a3fd 100644
--- a/src/gui/colour.cpp
+++ b/src/gui/colour.cpp
@@ -19,18 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstdio>
-
#include "colour.h"
#include "../configuration.h"
#include "../utils/gettext.h"
+#include "../utils/tostring.h"
Colour::Colour()
{
addColour('C', 0x000000, _("Chat"));
addColour('G', 0xff0000, _("GM"));
+ addColour('H', 0xebc873, _("Highlight"));
addColour('Y', 0x1fa052, _("Player"));
addColour('W', 0x0000ff, _("Whisper"));
addColour('I', 0xf1dc27, _("Is"));
@@ -48,9 +48,7 @@ Colour::~Colour()
col != colEnd;
++col)
{
- char buffer[20];
- std::sprintf(buffer, "0x%06x", col->rgb);
- config.setValue("Colour" + col->text, buffer);
+ config.setValue("Colour" + col->text, toString(col->rgb));
}
}
@@ -95,6 +93,15 @@ std::string Colour::getElementAt(int i)
return mColVector[i].text;
}
+char Colour::getColourCharAt(int i)
+{
+ if (i < 0 || i >= getNumberOfElements())
+ {
+ return 'C';
+ }
+ return mColVector[i].ch;
+}
+
void Colour::addColour(const char c, const int rgb, const std::string &text)
{
int trueRgb = config.getValue("Colour" + text, rgb);
diff --git a/src/gui/colour.h b/src/gui/colour.h
index 1ffe6e30..6ea02840 100644
--- a/src/gui/colour.h
+++ b/src/gui/colour.h
@@ -22,14 +22,11 @@
#ifndef COLOUR_H
#define COLOUR_H
-#include <cstdio>
#include <string>
#include <vector>
#include <guichan/listmodel.hpp>
-#include "../guichanfwd.h"
-
class Colour : public gcn::ListModel
{
public:
@@ -91,6 +88,12 @@ class Colour : public gcn::ListModel
int getColourAt(int i);
/**
+ * Get the character used by the colour for the element at index i in
+ * the current colour model
+ */
+ char getColourCharAt(int i);
+
+ /**
* Set the colour for the element at index i
*/
void setColourAt(int i, int rgb);
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index ce0a8a68..38697f3a 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -21,7 +21,10 @@
#include <guichan/font.hpp>
+#include "button.h"
#include "confirm_dialog.h"
+#include "scrollarea.h"
+#include "textbox.h"
#include "../utils/gettext.h"
@@ -41,8 +44,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setOpaque(false);
- mTextBox->setMinWidth(260);
- mTextBox->setTextWrapped(msg);
+ mTextBox->setTextWrapped(msg, 260);
int numRows = mTextBox->getNumberOfRows();
int width = getFont()->getWidth(title);
@@ -77,7 +79,8 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
add(yesButton);
add(noButton);
- if (getParent()) {
+ if (getParent())
+ {
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h
index fb8290c8..3fa2b90d 100644
--- a/src/gui/confirm_dialog.h
+++ b/src/gui/confirm_dialog.h
@@ -24,19 +24,18 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../guichanfwd.h"
+class ScrollArea;
+class TextBox;
/**
* An option dialog.
*
* \ingroup GUI
*/
-class ConfirmDialog : public Window, public gcn::ActionListener {
+class ConfirmDialog : public Window, public gcn::ActionListener
+{
public:
/**
* Constructor.
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 15d85bbc..a69698e9 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -31,7 +31,8 @@
#include "../utils/gettext.h"
-namespace {
+namespace
+{
struct ConnectionActionListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event) { state = EXIT_STATE; }
@@ -62,10 +63,10 @@ ConnectionDialog::ConnectionDialog():
void ConnectionDialog::logic()
{
mProgress += 0.005f;
+
if (mProgress > 1.0f)
- {
mProgress = 0.0f;
- }
+
mProgressBar->setProgress(mProgress);
Window::logic();
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 223b7fbd..5a5acfad 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -23,9 +23,7 @@
#include <guichan/widgets/label.hpp>
-#include "button.h"
#include "debugwindow.h"
-#include "gui.h"
#include "viewport.h"
#include "widgets/layout.h"
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index 00119d15..e089de27 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -22,14 +22,10 @@
#ifndef DEBUGWINDOW_H
#define DEBUGWINDOW_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The debug window.
*
diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h
index ca7b533a..fefce793 100644
--- a/src/gui/emotecontainer.h
+++ b/src/gui/emotecontainer.h
@@ -29,8 +29,6 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class AnimatedSprite;
class Image;
diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp
index a0142663..b66592c1 100644
--- a/src/gui/emoteshortcutcontainer.cpp
+++ b/src/gui/emoteshortcutcontainer.cpp
@@ -22,6 +22,7 @@
#include "emoteshortcutcontainer.h"
#include "../animatedsprite.h"
+#include "../configuration.h"
#include "../emoteshortcut.h"
#include "../graphics.h"
#include "../inventory.h"
@@ -42,11 +43,10 @@
static const int MAX_ITEMS = 12;
EmoteShortcutContainer::EmoteShortcutContainer():
+ ShortcutContainer(),
mEmoteClicked(false),
mEmoteMoved(0)
{
- mGridWidth = 1,
- mGridHeight = 1,
addMouseListener(this);
addWidgetListener(this);
@@ -54,6 +54,8 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
+ mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
@@ -96,6 +98,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
}
}
+
if (mEmoteMoved)
{
// Draw the emote image being dragged by the cursor.
@@ -108,6 +111,12 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
sprite->draw(g, tPosX, tPosY);
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ mBackgroundImg->setAlpha(mAlpha);
+ }
}
void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event)
diff --git a/src/gui/emoteshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h
index 54ca1714..d32a9f79 100644
--- a/src/gui/emoteshortcutcontainer.h
+++ b/src/gui/emoteshortcutcontainer.h
@@ -24,12 +24,8 @@
#include <vector>
-#include <guichan/mouselistener.hpp>
-
#include "shortcutcontainer.h"
-#include "../guichanfwd.h"
-
class AnimatedSprite;
class Image;
diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp
index 95f73933..f4a8999a 100644
--- a/src/gui/emotewindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -19,16 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-
-#include <guichan/mouseinput.hpp>
-
#include "button.h"
#include "gui.h"
#include "emotewindow.h"
#include "emotecontainer.h"
#include "scrollarea.h"
-#include "textbox.h"
#include "widgets/layout.h"
diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h
index 0e938bc9..8af24a7b 100644
--- a/src/gui/emotewindow.h
+++ b/src/gui/emotewindow.h
@@ -27,8 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class EmoteContainer;
class TextBox;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 40496381..a2be6b00 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -26,7 +26,9 @@
#include "button.h"
#include "equipmentwindow.h"
+#include "itempopup.h"
#include "playerbox.h"
+#include "viewport.h"
#include "../equipment.h"
#include "../graphics.h"
@@ -55,12 +57,12 @@ static const int boxPosition[][2] = {
{129, 78} // EQUIP_AMMO_SLOT
};
-EquipmentWindow::EquipmentWindow(Equipment *equipment):
+EquipmentWindow::EquipmentWindow():
Window(_("Equipment")),
- mEquipment(equipment),
mSelected(-1)
-
{
+ mItemPopup = new ItemPopup();
+
// Control that shows the Player
mPlayerBox = new PlayerBox;
mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 123));
@@ -85,12 +87,15 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
}
+ mEquipment = player_node->mEquipment.get();
mInventory = player_node->getInventory();
}
EquipmentWindow::~EquipmentWindow()
{
delete mUnequip;
+ delete mItemPopup;
+ delete mPlayerBox;
}
void EquipmentWindow::draw(gcn::Graphics *graphics)
@@ -153,6 +158,23 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
}
}
+Item* EquipmentWindow::getItem(const int &x, const int &y)
+{
+ for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
+ {
+ gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT);
+
+ if (tRect.isPointInRect(x, y))
+ {
+ return (i != EQUIP_AMMO_SLOT) ?
+ mInventory->getItem(mEquipment->getEquipment(i)) :
+ mInventory->getItem(mEquipment->getArrows());
+ }
+ }
+ return NULL;
+}
+
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
@@ -162,21 +184,67 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
Item* item;
- // Checks if any of the presses were in the equip boxes.
- for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
+ if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
- item = (i != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(i)) :
- mInventory->getItem(mEquipment->getArrows());
- gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT);
- if (tRect.isPointInRect(x, y))
+ // Checks if any of the presses were in the equip boxes.
+ for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++)
{
- if (item)
+ item = (i != EQUIP_AMMO_SLOT) ?
+ mInventory->getItem(mEquipment->getEquipment(i)) :
+ mInventory->getItem(mEquipment->getArrows());
+ gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT);
+
+ if (tRect.isPointInRect(x, y))
{
- mSelected = i;
+ if (item)
+ {
+ mSelected = i;
+ }
}
}
}
+ else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ item = getItem(x, y);
+
+ if (!item)
+ return;
+
+ /* Convert relative to the window coordinates to absolute screen
+ * coordinates.
+ */
+ const int mx = x + getX();
+ const int my = y + getY();
+ viewport->showPopup(mx, my, item);
+ }
}
+// Show ItemTooltip
+void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
+{
+ const int x = event.getX();
+ const int y = event.getY();
+
+ Item* item = getItem(x, y);
+
+ if (item)
+ {
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
+
+ mItemPopup->setItem(item->getInfo());
+ mItemPopup->setOpaque(false);
+ mItemPopup->view(x + getX(), y + getY());
+ }
+ else
+ {
+ mItemPopup->setVisible(false);
+ }
+}
+
+// Hide ItemTooltip
+void EquipmentWindow::mouseExited(gcn::MouseEvent &event)
+{
+ mItemPopup->setVisible(false);
+}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0b3aede0..c491062a 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -28,6 +28,8 @@
class Equipment;
class Inventory;
+class Item;
+class ItemPopup;
class PlayerBox;
/**
@@ -50,7 +52,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
/**
* Constructor.
*/
- EquipmentWindow(Equipment *equipment);
+ EquipmentWindow();
/**
* Destructor.
@@ -84,11 +86,18 @@ class EquipmentWindow : public Window, public gcn::ActionListener
private:
+ void mouseExited(gcn::MouseEvent &event);
+ void mouseMoved(gcn::MouseEvent &event);
+
+ Item* getItem(const int &x, const int &y);
+
Equipment *mEquipment;
Inventory *mInventory;
gcn::Button *mUnequip; /**< Button for unequipping. */
EquipBox mEquipBox[EQUIP_VECTOREND]; /**< Equipment Boxes. */
+ ItemPopup *mItemPopup;
+
PlayerBox *mPlayerBox;
int mSelected; /**< Index of selected item. */
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
index 124b5472..b0639bd8 100644
--- a/src/gui/focushandler.h
+++ b/src/gui/focushandler.h
@@ -26,8 +26,6 @@
#include <guichan/focushandler.hpp>
-#include "../guichanfwd.h"
-
/**
* The focus handler. This focus handler does exactly the same as the Guichan
* focus handler, but keeps a stack of modal widgets to be able to handle
diff --git a/src/gui/gccontainer.h b/src/gui/gccontainer.h
index 0a573645..da584a42 100644
--- a/src/gui/gccontainer.h
+++ b/src/gui/gccontainer.h
@@ -26,8 +26,6 @@
#include <guichan/widgets/container.hpp>
-#include "../guichanfwd.h"
-
/**
* A garbage collecting container. Childs added to this container are
* automatically deleted when the container is deleted.
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 642e916b..7779a503 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -63,7 +63,8 @@ class GuiConfigListener : public ConfigListener
void optionChanged(const std::string &name)
{
- if (name == "customcursor") {
+ if (name == "customcursor")
+ {
bool bCustomCursor = config.getValue("customcursor", 1) == 1;
mGui->setUseCustomCursor(bCustomCursor);
}
@@ -107,7 +108,8 @@ Gui::Gui(Graphics *graphics):
// Set global font
std::string path = resman->getPath("fonts/dejavusans.ttf");
- try {
+ try
+ {
const int fontSize = config.getValue("fontSize", 11);
mGuiFont = new TrueTypeFont(path, fontSize);
}
@@ -119,7 +121,8 @@ Gui::Gui(Graphics *graphics):
// Set bold font
path = resman->getPath("fonts/dejavusans-bold.ttf");
- try {
+ try
+ {
const int fontSize = config.getValue("fontSize", 11);
boldFont = new TrueTypeFont(path, fontSize);
}
@@ -132,7 +135,8 @@ Gui::Gui(Graphics *graphics):
gcn::Widget::setGlobalFont(mGuiFont);
// Load hits' colourful fonts
- try {
+ try
+ {
hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png",
"0123456789crit! ");
hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png",
@@ -182,12 +186,13 @@ Gui::~Gui()
void Gui::logic()
{
// Fade out mouse cursor after extended inactivity
- if (mMouseInactivityTimer < 100 * 15) {
+ if (mMouseInactivityTimer < 100 * 15)
+ {
++mMouseInactivityTimer;
mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f);
- } else {
- mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f);
}
+ else
+ mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f);
gcn::Gui::logic();
}
@@ -232,9 +237,8 @@ void Gui::setUseCustomCursor(bool customCursor)
mMouseCursors =
resman->getImageSet("graphics/gui/mouse.png", 40, 40);
- if (!mMouseCursors) {
+ if (!mMouseCursors)
logger->error("Unable to load mouse cursors.");
- }
}
else
{
@@ -242,7 +246,8 @@ void Gui::setUseCustomCursor(bool customCursor)
SDL_ShowCursor(SDL_ENABLE);
// Unload the mouse cursor
- if (mMouseCursors) {
+ if (mMouseCursors)
+ {
mMouseCursors->decRef();
mMouseCursors = NULL;
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 9681d44a..5c0c24f7 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -115,7 +115,6 @@ class Gui : public gcn::Gui
};
extern Gui *gui; /**< The GUI system */
-extern Viewport *viewport; /**< The viewport */
extern SDLInput *guiInput; /**< GUI input */
/**
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 6b14f6d8..ece2dce4 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -33,6 +33,8 @@
HelpWindow::HelpWindow():
Window(_("Help"))
{
+ setMinWidth(300);
+ setMinHeight(250);
setContentSize(455, 350);
setWindowName(_("Help"));
setResizable(true);
diff --git a/src/gui/help.h b/src/gui/help.h
index 2ba74c0a..98e3aa67 100644
--- a/src/gui/help.h
+++ b/src/gui/help.h
@@ -27,8 +27,6 @@
#include "linkhandler.h"
#include "window.h"
-#include "../guichanfwd.h"
-
class BrowserBox;
/**
diff --git a/src/gui/inttextfield.h b/src/gui/inttextfield.h
index 2a913ef6..add78084 100644
--- a/src/gui/inttextfield.h
+++ b/src/gui/inttextfield.h
@@ -24,8 +24,6 @@
#include "textfield.h"
-#include "../guichanfwd.h"
-
/**
* TextBox which only accepts numbers as input.
*/
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 3b868610..b9fe1c90 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -27,13 +27,11 @@
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "gui.h"
#include "inventorywindow.h"
#include "item_amount.h"
#include "itemcontainer.h"
#include "progressbar.h"
#include "scrollarea.h"
-#include "textbox.h"
#include "viewport.h"
#include "widgets/layout.h"
@@ -91,21 +89,33 @@ InventoryWindow::InventoryWindow(int invSize):
setMinHeight(130);
setMinWidth(mWeightLabel->getWidth() + mSlotsLabel->getWidth() + 310);
- place(0, 0, mInvenScroll, 7, 4);
- place(0, 4, mWeightLabel).setPadding(3);
- place(1, 4, mWeightBar, 2);
- place(3, 4, mSlotsLabel).setPadding(3);
- place(4, 4, mSlotsBar, 2);
+ place(0, 0, mWeightLabel).setPadding(3);
+ place(1, 0, mWeightBar, 2);
+ place(3, 0, mSlotsLabel).setPadding(3);
+ place(4, 0, mSlotsBar, 2);
+ place(0, 1, mInvenScroll, 7, 4);
place(5, 5, mDropButton);
place(6, 5, mUseButton);
Layout &layout = getLayout();
- layout.setRowHeight(0, Layout::AUTO_SET);
+ layout.setRowHeight(0, mDropButton->getHeight());
loadWindowState();
setLocationRelativeTo(getParent());
}
+InventoryWindow::~InventoryWindow()
+{
+ delete mWeightBar;
+ delete mSlotsBar;
+ delete mUseButton;
+ delete mDropButton;
+ delete mItems;
+ delete mWeightLabel;
+ delete mSlotsLabel;
+ delete mInvenScroll;
+}
+
void InventoryWindow::logic()
{
Window::logic();
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 2c19ce26..78d30461 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -27,7 +27,6 @@
#include "window.h"
-#include "../guichanfwd.h"
#include "../localplayer.h"
class Item;
@@ -50,6 +49,11 @@ class InventoryWindow : public Window, gcn::ActionListener,
InventoryWindow(int invSize = (INVENTORY_SIZE - 2));
/**
+ * Destructor.
+ */
+ ~InventoryWindow();
+
+ /**
* Logic (updates buttons and weight information).
*/
void logic();
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index d8682c95..92be3d6e 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -70,7 +70,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
resetAmount();
- switch (usage) {
+ switch (usage)
+ {
case AMOUNT_TRADE_ADD:
setCaption(_("Select amount of items to trade."));
okButton->setActionEventId("AddTrade");
diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h
index d8eedadb..618d7d51 100644
--- a/src/gui/item_amount.h
+++ b/src/gui/item_amount.h
@@ -22,14 +22,10 @@
#ifndef ITEM_AMOUNT_WINDOW_H
#define ITEM_AMOUNT_WINDOW_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class IntTextField;
class Item;
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index e3ecdd4e..0beb5cfb 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -36,7 +36,6 @@
#include "../log.h"
#include "../resources/image.h"
-#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
#include "../utils/tostring.h"
@@ -68,6 +67,7 @@ ItemContainer::ItemContainer(Inventory *inventory, int offset):
ItemContainer::~ItemContainer()
{
mSelImg->decRef();
+ delete mItemPopup;
}
void ItemContainer::logic()
@@ -124,6 +124,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
}
// Draw item caption
+ graphics->setFont(getFont());
graphics->setColor(gcn::Color(0, 0, 0));
graphics->drawText(
(item->isEquipped() ? "Eq." : toString(item->getQuantity())),
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 1905e820..71fcc5d0 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -28,8 +28,6 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class Image;
class Inventory;
class Item;
diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp
index 34c12a0c..97c0b94f 100644
--- a/src/gui/itemlinkhandler.cpp
+++ b/src/gui/itemlinkhandler.cpp
@@ -19,6 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <sstream>
+#include <string>
+
#include <SDL_mouse.h>
#include "itemlinkhandler.h"
@@ -27,9 +30,6 @@
#include "../resources/iteminfo.h"
#include "../resources/itemdb.h"
-#include <sstream>
-#include <string>
-
ItemLinkHandler::ItemLinkHandler()
{
mItemPopup = new ItemPopup;
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 2d3797c9..df7afa48 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -26,16 +26,15 @@
#include "gui.h"
#include "itempopup.h"
+#include "scrollarea.h"
+#include "textbox.h"
#include "windowcontainer.h"
#include "widgets/layout.h"
-#include "../resources/image.h"
#include "../resources/iteminfo.h"
-#include "../resources/resourcemanager.h"
#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
#include "../utils/tostring.h"
ItemPopup::ItemPopup():
@@ -47,16 +46,12 @@ ItemPopup::ItemPopup():
// Item Name
mItemName = new gcn::Label("Label");
- mItemName->setFont(gui->getFont());
- mItemName->setPosition(2, 2);
- mItemName->setWidth(getWidth() - 4);
mItemName->setFont(boldFont);
+ mItemName->setPosition(2, 2);
// Item Description
mItemDesc = new TextBox();
mItemDesc->setEditable(false);
- mItemDesc->setMinWidth(186);
- mItemDesc->setTextWrapped("");
mItemDescScroll = new ScrollArea(mItemDesc);
mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -68,8 +63,6 @@ ItemPopup::ItemPopup():
// Item Effect
mItemEffect = new TextBox();
mItemEffect->setEditable(false);
- mItemEffect->setMinWidth(186);
- mItemEffect->setTextWrapped("");
mItemEffectScroll = new ScrollArea(mItemEffect);
mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -81,8 +74,6 @@ ItemPopup::ItemPopup():
// Item Weight
mItemWeight = new TextBox();
mItemWeight->setEditable(false);
- mItemWeight->setMinWidth(186);
- mItemWeight->setTextWrapped("");
mItemWeightScroll = new ScrollArea(mItemWeight);
mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -97,42 +88,57 @@ ItemPopup::ItemPopup():
add(mItemWeightScroll);
setLocationRelativeTo(getParent());
+}
- // LEEOR / TODO: This causes an exception error.
- //moveToBottom(getParent());
+ItemPopup::~ItemPopup()
+{
+ delete mItemName;
+ delete mItemDesc;
+ delete mItemDescScroll;
+ delete mItemEffect;
+ delete mItemEffectScroll;
+ delete mItemWeight;
+ delete mItemWeightScroll;
}
void ItemPopup::setItem(const ItemInfo &item)
{
- const gcn::Rectangle &area = getChildrenArea();
- const int width = area.width;
+ mItemName->setCaption(item.getName());
+ mItemName->setForegroundColor(getColor(item.getType()));
+ mItemName->setWidth(boldFont->getWidth(item.getName()));
+ mItemDesc->setTextWrapped(item.getDescription(), 196);
+ mItemEffect->setTextWrapped(item.getEffect(), 196);
+ mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
+ _(" grams"), 196);
- mItemDesc->setMinWidth(width - 10);
- mItemEffect->setMinWidth(width - 10);
- mItemWeight->setMinWidth(width - 10);
+ int minWidth = mItemName->getWidth();
- mItemName->setCaption(item.getName());
- mItemDesc->setTextWrapped(item.getDescription());
- mItemEffect->setTextWrapped(item.getEffect());
- mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
- _(" grams"));
+ if (mItemDesc->getMinWidth() > minWidth)
+ minWidth = mItemDesc->getMinWidth();
+ if (mItemEffect->getMinWidth() > minWidth)
+ minWidth = mItemEffect->getMinWidth();
+ if (mItemWeight->getMinWidth() > minWidth)
+ minWidth = mItemWeight->getMinWidth();
+
+ minWidth += 8;
+ setWidth(minWidth);
int numRowsDesc = mItemDesc->getNumberOfRows();
int numRowsEffect = mItemEffect->getNumberOfRows();
int numRowsWeight = mItemWeight->getNumberOfRows();
- mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsDesc * getFont()->getHeight()));
- mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsEffect * getFont()->getHeight()));
- mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
numRowsWeight * getFont()->getHeight()));
if (item.getEffect() == "")
{
- setContentSize(200, (numRowsDesc * getFont()->getHeight() +
+ setContentSize(minWidth, (numRowsDesc * getFont()->getHeight() +
(3 * getFont()->getHeight())));
mItemWeightScroll->setPosition(2,
@@ -141,7 +147,7 @@ void ItemPopup::setItem(const ItemInfo &item)
}
else
{
- setContentSize(200, (numRowsDesc * getFont()->getHeight()) +
+ setContentSize(minWidth, (numRowsDesc * getFont()->getHeight()) +
(numRowsEffect * getFont()->getHeight()) +
(3 * getFont()->getHeight()));
@@ -156,6 +162,40 @@ void ItemPopup::setItem(const ItemInfo &item)
(2 * getFont()->getHeight()));
}
+gcn::Color ItemPopup::getColor(const std::string& type)
+{
+ gcn::Color color;
+
+ if (type.compare("generic") == 0)
+ color = 0x21a5b1;
+ else if (type.compare("equip-head") == 0)
+ color = 0x527fa4;
+ else if (type.compare("usable") == 0)
+ color = 0x268d24;
+ else if (type.compare("equip-torso") == 0)
+ color = 0xd12aa4;
+ else if (type.compare("equip-1hand") == 0)
+ color = 0xf42a2a;
+ else if (type.compare("equip-legs") == 0)
+ color = 0x699900;
+ else if (type.compare("equip-feet") == 0)
+ color = 0xaa1d48;
+ else if (type.compare("equip-2hand") == 0)
+ color = 0xf46d0e;
+ else if (type.compare("equip-shield") == 0)
+ color = 0x9c2424;
+ else if (type.compare("equip-ring") == 0)
+ color = 0x0000ff;
+ else if (type.compare("equip-arms") == 0)
+ color = 0x9c24e8;
+ else if (type.compare("equip-ammo") == 0)
+ color = 0x8b6311;
+ else
+ color = 0x000000;
+
+ return color;
+}
+
unsigned int ItemPopup::getNumRows()
{
return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() +
@@ -166,10 +206,10 @@ void ItemPopup::view(int x, int y)
{
if (windowContainer->getWidth() < (x + getWidth() + 5))
x = windowContainer->getWidth() - getWidth();
- if ((y - getHeight() - 5) < 0)
+ if ((y - getHeight() - 10) < 0)
y = 0;
else
- y = y - getHeight() - 5;
+ y = y - getHeight() - 10;
setPosition(x, y);
setVisible(true);
requestMoveToTop();
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index d4ad0e20..c820e3a0 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -23,16 +23,17 @@
#ifndef ITEMPOPUP_H
#define ITEMPOPUP_H
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../item.h"
+class ItemInfo;
+class ScrollArea;
+class TextBox;
class ItemPopup : public Window
{
public:
ItemPopup();
+ ~ItemPopup();
void setItem(const ItemInfo &item);
unsigned int getNumRows();
@@ -46,6 +47,8 @@ class ItemPopup : public Window
ScrollArea *mItemDescScroll;
ScrollArea *mItemEffectScroll;
ScrollArea *mItemWeightScroll;
+
+ gcn::Color getColor(const std::string& type);
};
#endif // ITEMPOPUP_H
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 3735afe2..42e3b853 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -20,7 +20,6 @@
*/
#include <SDL_mouse.h>
-#include "gui.h"
#include "itemshortcutcontainer.h"
#include "itempopup.h"
#include "viewport.h"
@@ -39,11 +38,10 @@
#include "../utils/tostring.h"
ItemShortcutContainer::ItemShortcutContainer():
+ ShortcutContainer(),
mItemClicked(false),
mItemMoved(NULL)
{
- mGridWidth=1;
- mGridHeight=1;
addMouseListener(this);
addWidgetListener(this);
@@ -63,6 +61,7 @@ ItemShortcutContainer::ItemShortcutContainer():
ItemShortcutContainer::~ItemShortcutContainer()
{
mBackgroundImg->decRef();
+ delete mItemPopup;
}
void ItemShortcutContainer::logic()
@@ -137,6 +136,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
gcn::Graphics::CENTER);
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ }
}
void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h
index d6a04d7b..22d94ec2 100644
--- a/src/gui/itemshortcutcontainer.h
+++ b/src/gui/itemshortcutcontainer.h
@@ -26,8 +26,6 @@
#include "shortcutcontainer.h"
-#include "../guichanfwd.h"
-
class Image;
class Item;
class ItemPopup;
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index 990a0ade..b63d6424 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -22,10 +22,14 @@
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
#include <guichan/listmodel.hpp>
-#include <guichan/mouseinput.hpp>
+#include "colour.h"
#include "listbox.h"
+#include "../configuration.h"
+
+float ListBox::mAlpha = config.getValue("guialpha", 0.8);
+
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel)
{
@@ -36,21 +40,28 @@ void ListBox::draw(gcn::Graphics *graphics)
if (!mListModel)
return;
- graphics->setColor(gcn::Color(235, 200, 115));
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ bool valid;
+ const int red = (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green = (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 255;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
graphics->setFont(getFont());
- int fontHeight = getFont()->getHeight();
+ const int fontHeight = getFont()->getHeight();
// Draw rectangle below the selected list element
- if (mSelected >= 0) {
+ if (mSelected >= 0)
graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected,
getWidth(), fontHeight));
- }
// Draw the list elements
- graphics->setColor(gcn::Color(0, 0, 0));
- for (int i = 0, y = 0;
- i < mListModel->getNumberOfElements();
+ graphics->setColor(gcn::Color(0, 0, 0, 255));
+ for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += fontHeight)
{
graphics->drawText(mListModel->getElementAt(i), 1, y);
diff --git a/src/gui/listbox.h b/src/gui/listbox.h
index 3d0062bc..12fcb955 100644
--- a/src/gui/listbox.h
+++ b/src/gui/listbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/listbox.hpp>
-#include "../guichanfwd.h"
-
class SelectionListener;
/**
@@ -49,6 +47,9 @@ class ListBox : public gcn::ListBox
void draw(gcn::Graphics *graphics);
void mouseDragged(gcn::MouseEvent &event);
+
+ private:
+ static float mAlpha;
};
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index bf1727ac..e22ee2ad 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -19,18 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-#include <vector>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "checkbox.h"
+#include "listbox.h"
#include "login.h"
#include "ok_dialog.h"
#include "passwordfield.h"
+#include "scrollarea.h"
#include "textfield.h"
+#include "widgets/dropdown.h"
#include "widgets/layout.h"
#include "../main.h"
@@ -62,7 +62,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
dfltPort.push_back("21001");
mServerList = new DropDownList("MostRecent00", dfltServer, dfltPort,
MAX_SERVER_LIST_SIZE);
- mServerListBox = new gcn::ListBox(mServerList);
+ mServerListBox = new ListBox(mServerList);
mServerScrollArea = new ScrollArea();
mUserField = new TextField(mLoginData->username);
@@ -72,6 +72,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
mServerDropDown = new DropDown(mServerList,
mServerScrollArea,
mServerListBox);
+ mServerDropDown->setOpaque(false);
mKeepCheck = new CheckBox(_("Remember Username"), mLoginData->remember);
mOkButton = new Button(_("OK"), "ok", this);
diff --git a/src/gui/login.h b/src/gui/login.h
index b7abbb2a..c0d6e755 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -22,21 +22,18 @@
#ifndef LOGIN_H
#define LOGIN_H
-#include <iosfwd>
#include <string>
#include <vector>
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
+#include <guichan/listmodel.hpp>
-#include "scrollarea.h"
#include "window.h"
-#include "widgets/dropdown.h"
-
-#include "../guichanfwd.h"
-
+class DropDown;
class LoginData;
+class ScrollArea;
/**
* The login dialog.
@@ -132,7 +129,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
};
DropDownList *mServerList;
gcn::ListBox *mServerListBox;
- ScrollArea *mServerScrollArea;
+ gcn::ScrollArea *mServerScrollArea;
};
#endif
diff --git a/src/gui/menuwindow.h b/src/gui/menuwindow.h
index 9b784c35..9bb54e29 100644
--- a/src/gui/menuwindow.h
+++ b/src/gui/menuwindow.h
@@ -24,8 +24,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The Button Menu.
*
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index cc9173ef..55cd8b5d 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -41,15 +41,19 @@ Minimap::Minimap():
mProportion(0.5)
{
setWindowName(_("MiniMap"));
- mShow = config.getValue(getWindowName() + "Visible", true);
+ mShow = config.getValue(getWindowName() + "Show", true);
setDefaultSize(5, 25, 100, 100);
setResizable(true);
+
+ loadWindowState();
}
Minimap::~Minimap()
{
if (mMapImage)
mMapImage->decRef();
+
+ config.setValue(getWindowName() + "Show", mShow);
}
void Minimap::setMapImage(Image *img)
@@ -71,23 +75,26 @@ void Minimap::setMapImage(Image *img)
setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
setMinHeight(mapHeight);
- setMaxWidth(mMapImage->getWidth() + offsetX);
+ setMaxWidth(mMapImage->getWidth() > titleWidth ?
+ mMapImage->getWidth() + offsetX : titleWidth);
setMaxHeight(mMapImage->getHeight() + offsetY);
- mMapImage->setAlpha(config.getValue("guialpha", 0.8));
-
- // Set content size to be within the minimum and maximum boundaries
- setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth());
- if (getMaxWidth() > getWidth())
+ // Make sure the window is within the minimum and maximum boundaries
+ // TODO: Shouldn't this be happening automatically within the Window
+ // class?
+ if (getMinWidth() > getWidth())
+ setWidth(getMinWidth());
+ else if (getMaxWidth() < getWidth())
setWidth(getMaxWidth());
- setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight());
- if (getMaxHeight() > getHeight())
+ if (getMinHeight() > getHeight())
+ setHeight(getMinHeight());
+ else if (getMaxHeight() < getHeight())
setHeight(getMaxHeight());
+ setContentSize(getWidth() - offsetX, getHeight() - offsetY);
setDefaultSize(getX(), getY(), getWidth(), getHeight());
resetToDefaultSize();
- loadWindowState();
setVisible(mShow);
}
else
@@ -99,7 +106,6 @@ void Minimap::setMapImage(Image *img)
void Minimap::toggle()
{
mShow = !mShow;
- config.setValue(getWindowName() + "Visible", mShow);
}
void Minimap::draw(gcn::Graphics *graphics)
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index b4574ad5..3ce0aacd 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -24,8 +24,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class Image;
/**
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 39813883..7058d572 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -23,6 +23,7 @@
#include "ministatus.h"
#include "progressbar.h"
+#include "../animatedsprite.h"
#include "../configuration.h"
#include "../graphics.h"
#include "../localplayer.h"
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index c6a36a98..f262a2a0 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -22,14 +22,11 @@
#ifndef MINISTATUS_H
#define MINISTATUS_H
-#include <iosfwd>
-#include <vector>
-
#include "window.h"
-#include "../guichanfwd.h"
-#include "../animatedsprite.h"
+#include <vector>
+class AnimatedSprite;
class ProgressBar;
/**
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index a2e043d1..b4313b70 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -19,12 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-
-#include "npc_text.h"
-#include "browserbox.h"
#include "button.h"
+#include "npc_text.h"
#include "scrollarea.h"
+#include "textbox.h"
#include "widgets/layout.h"
@@ -42,10 +40,11 @@ NpcTextDialog::NpcTextDialog():
setDefaultSize(0, 0, 260, 200);
- mBrowserBox = new BrowserBox(BrowserBox::AUTO_WRAP);
- mBrowserBox->setOpaque(false);
+ mTextBox = new TextBox;
+ mTextBox->setEditable(false);
+ mTextBox->setOpaque(false);
- scrollArea = new ScrollArea(mBrowserBox);
+ scrollArea = new ScrollArea(mTextBox);
okButton = new Button(_("OK"), "ok", this);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -61,30 +60,33 @@ NpcTextDialog::NpcTextDialog():
setLocationRelativeTo(getParent());
}
-void NpcTextDialog::clearText()
-{
- mBrowserBox->clearRows();
-}
-
void NpcTextDialog::setText(const std::string &text)
{
- mBrowserBox->clearRows();
- mBrowserBox->addRow(text);
+ mText = text;
+ mTextBox->setTextWrapped(mText, scrollArea->getWidth() - 15);
}
void NpcTextDialog::addText(const std::string &text)
{
- mBrowserBox->addRow(text);
+ setText(mText + text + "\n");
}
void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- clearText();
+ setText("");
setVisible(false);
if (current_npc)
current_npc->nextDialog();
current_npc = 0;
}
}
+
+void NpcTextDialog::widgetResized(const gcn::Event &event)
+{
+ Window::widgetResized(event);
+
+ setText(mText);
+}
+
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h
index b4b6f1af..a07aa04f 100644
--- a/src/gui/npc_text.h
+++ b/src/gui/npc_text.h
@@ -22,14 +22,13 @@
#ifndef NPC_TEXT_H
#define NPC_TEXT_H
-#include <iosfwd>
+#include <string>
#include <guichan/actionlistener.hpp>
-#include "scrollarea.h"
#include "window.h"
-class BrowserBox;
+class TextBox;
/**
* The npc text dialog.
@@ -71,10 +70,19 @@ class NpcTextDialog : public Window, public gcn::ActionListener
*/
void addText(const std::string &string);
+ /**
+ * Called when resizing the window.
+ *
+ * @param event The calling event
+ */
+ void widgetResized(const gcn::Event &event);
+
private:
gcn::Button *okButton;
gcn::ScrollArea *scrollArea;
- BrowserBox *mBrowserBox;
+ TextBox *mTextBox;
+
+ std::string mText;
};
#endif // NPC_TEXT_H
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 65a1a7f1..c58fc460 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -19,27 +19,23 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "npcintegerdialog.h"
-
-#include <limits>
-#include <sstream>
-
#include "button.h"
#include "inttextfield.h"
+#include "npcintegerdialog.h"
+
+#include "widgets/layout.h"
#include "../npc.h"
#include "../utils/gettext.h"
-#include "../utils/tostring.h"
-
-#include "widgets/layout.h"
NpcIntegerDialog::NpcIntegerDialog():
Window(_("NPC Number Request"))
{
+ mValueField = new IntTextField();
+
mDecButton = new Button("-", "decvalue", this);
mIncButton = new Button("+", "incvalue", this);
- mValueField = new IntTextField();
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
resetButton = new Button(_("Reset"), "reset", this);
@@ -61,9 +57,6 @@ NpcIntegerDialog::NpcIntegerDialog():
reflowLayout(175, 0);
setLocationRelativeTo(getParent());
-
- mValueField->setActionEventId("valuefield");
- mValueField->addKeyListener(this);
}
void NpcIntegerDialog::setRange(const int min, const int max)
@@ -110,3 +103,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
mValueField->reset();
}
}
+
+bool NpcIntegerDialog::isInputFocused()
+{
+ return mValueField->isFocused();
+}
+
+void NpcIntegerDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h
index 983c46fe..10ec60b9 100644
--- a/src/gui/npcintegerdialog.h
+++ b/src/gui/npcintegerdialog.h
@@ -22,16 +22,10 @@
#ifndef GUI_NPCINTEGERDIALOG_H
#define GUI_NPCINTEGERDIALOG_H
-#include <iosfwd>
-#include <vector>
-
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class IntTextField;
/**
@@ -39,8 +33,7 @@ class IntTextField;
*
* \ingroup Interface
*/
-class NpcIntegerDialog : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class NpcIntegerDialog : public Window, public gcn::ActionListener
{
public:
/**
@@ -68,6 +61,16 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener,
*/
void setRange(const int min, const int max);
+ /**
+ * Checks whether NpcStringDialog is Focused or not.
+ */
+ bool isInputFocused();
+
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::Button *mDecButton;
gcn::Button *mIncButton;
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index bb815680..7d8a362a 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -21,8 +21,10 @@
#include <sstream>
+#include "button.h"
#include "listbox.h"
#include "npclistdialog.h"
+#include "scrollarea.h"
#include "widgets/layout.h"
@@ -41,6 +43,7 @@ NpcListDialog::NpcListDialog():
setDefaultSize(0, 0, 260, 200);
mItemList = new ListBox(this);
+ mItemList->setWrappingEnabled(true);
scrollArea = new ScrollArea(mItemList);
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h
index ffeced3d..30167a5e 100644
--- a/src/gui/npclistdialog.h
+++ b/src/gui/npclistdialog.h
@@ -22,18 +22,13 @@
#ifndef GUI_NPCLISTDIALOG_H
#define GUI_NPCLISTDIALOG_H
-#include <iosfwd>
#include <vector>
#include <guichan/actionlistener.hpp>
#include <guichan/listmodel.hpp>
-#include "button.h"
-#include "scrollarea.h"
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The npc list dialog.
*
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index ccb3c411..718c416f 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -19,18 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "npcstringdialog.h"
-
-#include <limits>
-#include <sstream>
-
#include "button.h"
+#include "npcstringdialog.h"
#include "textfield.h"
#include "../npc.h"
#include "../utils/gettext.h"
-#include "../utils/tostring.h"
#include "widgets/layout.h"
@@ -38,6 +33,7 @@ NpcStringDialog::NpcStringDialog():
Window(_("NPC Text Request"))
{
mValueField = new TextField("");
+
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
@@ -76,3 +72,8 @@ bool NpcStringDialog::isInputFocused()
{
return mValueField->isFocused();
}
+
+void NpcStringDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h
index 5aea2de0..1933e0f1 100644
--- a/src/gui/npcstringdialog.h
+++ b/src/gui/npcstringdialog.h
@@ -22,16 +22,10 @@
#ifndef GUI_NPCSTRINGDIALOG_H
#define GUI_NPCSTRINGDIALOG_H
-#include <iosfwd>
-#include <vector>
-
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
/**
* The npc integer input dialog.
*
@@ -69,6 +63,11 @@ class NpcStringDialog : public Window, public gcn::ActionListener
*/
bool isInputFocused();
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::TextField *mValueField;
gcn::Button *okButton;
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 018fa489..2c67e71f 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -19,10 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ok_dialog.h"
-
#include <guichan/font.hpp>
+#include "button.h"
+#include "ok_dialog.h"
+#include "scrollarea.h"
+#include "textbox.h"
+
#include "../utils/gettext.h"
OkDialog::OkDialog(const std::string &title, const std::string &msg,
@@ -40,8 +43,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mTextArea->setOpaque(false);
- mTextBox->setMinWidth(260);
- mTextBox->setTextWrapped(msg);
+ mTextBox->setTextWrapped(msg, 260);
int numRows = mTextBox->getNumberOfRows();
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index 78b3d44f..3a438513 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -24,12 +24,10 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
-#include "../guichanfwd.h"
+class ScrollArea;
+class TextBox;
/**
* An 'Ok' button dialog.
diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp
index 09b6abda..345ee1c3 100644
--- a/src/gui/passwordfield.cpp
+++ b/src/gui/passwordfield.cpp
@@ -21,8 +21,6 @@
#include "passwordfield.h"
-#include <string>
-
PasswordField::PasswordField(const std::string& text):
TextField(text)
{
diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h
index bc50e267..42f8d187 100644
--- a/src/gui/passwordfield.h
+++ b/src/gui/passwordfield.h
@@ -22,9 +22,9 @@
#ifndef PASSWORDFIELD_H
#define PASSWORDFIELD_H
-#include "textfield.h"
+#include <string>
-#include "../guichanfwd.h"
+#include "textfield.h"
/**
* A password field.
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index c22d407c..60003fb5 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "playerbox.h"
#include "../animatedsprite.h"
@@ -34,6 +32,7 @@
#include "../utils/dtor.h"
int PlayerBox::instances = 0;
+float PlayerBox::mAlpha = config.getValue("guialpha", 0.8);
ImageRect PlayerBox::background;
PlayerBox::PlayerBox(const Player *player):
@@ -94,6 +93,14 @@ void PlayerBox::draw(gcn::Graphics *graphics)
}
}
}
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ for (int a = 0; a < 9; a++)
+ {
+ background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ }
+ }
}
void PlayerBox::drawFrame(gcn::Graphics *graphics)
diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h
index 5aacd26f..7c08defd 100644
--- a/src/gui/playerbox.h
+++ b/src/gui/playerbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/scrollarea.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
class Player;
@@ -68,6 +66,7 @@ class PlayerBox : public gcn::ScrollArea
private:
const Player *mPlayer; /**< The character used for display */
+ static float mAlpha;
static int instances;
static ImageRect background;
};
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 8cb22c55..be5252f7 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -20,9 +20,6 @@
*/
#include <cassert>
-#include <iostream>
-
-#include <guichan/focushandler.hpp>
#include "browserbox.h"
#include "chat.h"
@@ -43,7 +40,6 @@
#include "../net/protocol.h"
#include "../resources/itemdb.h"
-#include "../resources/iteminfo.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
@@ -80,27 +76,27 @@ void PopupMenu::showPopup(int x, int y, Being *being)
// Players can be traded with. Later also attack, follow and
// add as buddy will be options in this menu.
const std::string &name = being->getName();
- mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@");
- mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name)) {
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str()));
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@");
- mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str()));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
- mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str()));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
break;
}
@@ -108,8 +104,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
//mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(_("@@party-invite|Invite ") + name +
- " to party@@");
+ mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str()));
}
break;
@@ -254,7 +249,7 @@ void PopupMenu::handleLink(const std::string& link)
else if (link == "chat")
{
- chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName());
+ chatWindow->addItemText(mItem->getInfo().getName());
}
else if (link == "drop")
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index ecc0017d..867477e0 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -19,18 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/font.hpp>
+
#include "gui.h"
#include "progressbar.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
-#include <guichan/font.hpp>
-
ImageRect ProgressBar::mBorder;
int ProgressBar::mInstances = 0;
+float ProgressBar::mAlpha = config.getValue("guialpha", 0.8);
ProgressBar::ProgressBar(float progress,
unsigned int width, unsigned int height,
@@ -56,6 +58,12 @@ ProgressBar::ProgressBar(float progress,
mBorder.grid[6] = dBorders->getSubImage(0, 15, 4, 4);
mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4);
+
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+
dBorders->decRef();
}
@@ -93,12 +101,27 @@ void ProgressBar::logic()
void ProgressBar::draw(gcn::Graphics *graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ if (config.getValue("opengl", 0))
+ mAlpha = config.getValue("guialpha", 0.8);
+ else
+ mAlpha = 1.0f;
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+ }
+
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
+ const int alpha = mAlpha * 255;
+
// The bar
if (mProgress > 0) {
- graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200));
+
+ graphics->setColor(gcn::Color(mRed, mGreen, mBlue, alpha));
graphics->fillRectangle(gcn::Rectangle(4, 4,
(int) (mProgress * (getWidth() - 8)),
getHeight() - 8));
@@ -112,14 +135,16 @@ void ProgressBar::draw(gcn::Graphics *graphics)
graphics->setFont(f);
- graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->setColor(gcn::Color(0, 0, 0, alpha));
graphics->drawText(mText, textX + 1, textY, gcn::Graphics::CENTER);
graphics->drawText(mText, textX, textY - 1, gcn::Graphics::CENTER);
graphics->drawText(mText, textX, textY + 1, gcn::Graphics::CENTER);
graphics->drawText(mText, textX - 1, textY, gcn::Graphics::CENTER);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(gcn::Color(255, 255, 255, alpha));
graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER);
+
+ graphics->setColor(gcn::Color(0, 0, 0));
}
}
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index ee0a5f81..2c1b22da 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -22,12 +22,11 @@
#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
+#include <string>
+
#include <guichan/widget.hpp>
#include <SDL_types.h>
-#include <string>
-
-#include "../guichanfwd.h"
class ImageRect;
@@ -111,6 +110,7 @@ class ProgressBar : public gcn::Widget
static ImageRect mBorder;
static int mInstances;
+ static float mAlpha;
};
#endif
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index 245112a7..de8d4d9d 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -21,12 +21,14 @@
#include "radiobutton.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
int RadioButton::instances = 0;
+float RadioButton::mAlpha = config.getValue("guialpha", 0.8);
Image *RadioButton::radioNormal;
Image *RadioButton::radioChecked;
Image *RadioButton::radioDisabled;
@@ -43,6 +45,10 @@ RadioButton::RadioButton(const std::string& caption, const std::string& group,
radioChecked = resman->getImage("graphics/gui/radioin.png");
radioDisabled = resman->getImage("graphics/gui/radioout.png");
radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
+ radioNormal->setAlpha(mAlpha);
+ radioChecked->setAlpha(mAlpha);
+ radioDisabled->setAlpha(mAlpha);
+ radioDisabledChecked->setAlpha(mAlpha);
}
instances++;
@@ -63,32 +69,37 @@ RadioButton::~RadioButton()
void RadioButton::drawBox(gcn::Graphics* graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ radioNormal->setAlpha(mAlpha);
+ radioChecked->setAlpha(mAlpha);
+ radioDisabled->setAlpha(mAlpha);
+ radioDisabledChecked->setAlpha(mAlpha);
+ }
+
Image *box = NULL;
- if (isSelected()) {
- if (isEnabled()) {
+ if (isSelected())
+ {
+ if (isEnabled())
box = radioChecked;
- } else {
+ else
box = radioDisabledChecked;
- }
- } else if (isEnabled()) {
+ }
+ else if (isEnabled())
box = radioNormal;
- } else {
+ else
box = radioDisabled;
- }
- if (box != NULL) {
+ if (box != NULL)
static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
- }
}
void RadioButton::draw(gcn::Graphics* graphics)
{
-
- graphics->pushClipArea(gcn::Rectangle(1,
- 1,
- getWidth() - 1,
- getHeight() - 1));
+ graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1,
+ getHeight() - 1));
drawBox(graphics);
diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h
index dcd62802..3d952b3f 100644
--- a/src/gui/radiobutton.h
+++ b/src/gui/radiobutton.h
@@ -24,14 +24,13 @@
#include <guichan/widgets/radiobutton.hpp>
-#include "../guichanfwd.h"
-
class Image;
/*
* Guichan based RadioButton with custom look
*/
-class RadioButton : public gcn::RadioButton {
+class RadioButton : public gcn::RadioButton
+{
public:
/*
* Constructor.
@@ -57,6 +56,7 @@ class RadioButton : public gcn::RadioButton {
private:
static int instances;
+ static float mAlpha;
static Image *radioNormal;
static Image *radioChecked;
static Image *radioDisabled;
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
new file mode 100644
index 00000000..1e7d8e13
--- /dev/null
+++ b/src/gui/recorder.cpp
@@ -0,0 +1,115 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <physfs.h>
+
+#include "button.h"
+#include "chat.h"
+#include "recorder.h"
+#include "windowcontainer.h"
+
+#include "widgets/layout.h"
+
+#include "../utils/trim.h"
+
+Recorder::Recorder(ChatWindow *chat, const std::string &title,
+ const std::string &buttonTxt) :
+ Window(title)
+{
+ setWindowName(_("Recorder"));
+ const int offsetX = 2 * getPadding() + 10;
+ const int offsetY = getTitleBarHeight() + getPadding() + 10;
+
+ mChat = chat;
+ Button *button = new Button(buttonTxt, "activate", this);
+ setDefaultSize(0, windowContainer->getHeight() - 123 - button->getHeight() -
+ offsetY, button->getWidth() + offsetX, button->getHeight() +
+ offsetY);
+
+ place(0, 0, button);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+
+ loadWindowState();
+}
+
+void Recorder::record(const std::string &msg)
+{
+ if (mStream.is_open())
+ {
+ mStream << msg << std::endl;
+ }
+}
+
+void Recorder::changeRecordingStatus(const std::string &msg)
+{
+ std::string msgCopy = msg;
+ trim(msgCopy);
+
+ if (msgCopy == "")
+ {
+ if (mStream.is_open())
+ {
+ mStream.close();
+ setVisible(false);
+
+ /*
+ * Message should go after mStream is closed so that it isn't
+ * recorded.
+ */
+ mChat->chatLog(_("Finishing recording."), BY_SERVER);
+ }
+ else
+ {
+ mChat->chatLog(_("Not currently recording."), BY_SERVER);
+ }
+ }
+ else if (mStream.is_open())
+ {
+ mChat->chatLog(_("Already recording."), BY_SERVER);
+ }
+ else
+ {
+ /*
+ * Message should go before mStream is opened so that it isn't
+ * recorded.
+ */
+ mChat->chatLog(_("Starting to record..."), BY_SERVER);
+ std::string file = std::string(PHYSFS_getUserDir()) + "/.aethyra/" + msgCopy;
+
+ mStream.open(file.c_str(), std::ios_base::trunc);
+
+ if (mStream.is_open())
+ setVisible(true);
+ else
+ mChat->chatLog(_("Failed to start recording."), BY_SERVER);
+ }
+}
+
+void Recorder::action(const gcn::ActionEvent &event)
+{
+ changeRecordingStatus("");
+}
+
+Recorder::~Recorder()
+{
+}
diff --git a/src/recorder.h b/src/gui/recorder.h
index faf3c76a..0bbab012 100644
--- a/src/recorder.h
+++ b/src/gui/recorder.h
@@ -25,25 +25,52 @@
#include <fstream>
#include <string>
-#include "gui/buttonbox.h"
+#include <guichan/actionlistener.hpp>
+
+#include "window.h"
+
+#include "../utils/gettext.h"
class ChatWindow;
-class Recorder : public ButtonBoxListener
+class Recorder : public Window, public gcn::ActionListener
{
- private:
- ChatWindow *mChat;
- std::ofstream mStream;
- ButtonBox *mButtonBox;
public:
- Recorder(ChatWindow *chat);
+ Recorder(ChatWindow *chat, const std::string &title = _("Recording..."),
+ const std::string &buttonTxt = _("Stop recording"));
+
+ virtual ~Recorder();
+
+ /*
+ * Outputs the message to the recorder file
+ *
+ * @param msg the line to write to the recorded file.
+ */
void record(const std::string &msg);
- void respond(const std::string &msg);
- void help() const;
- void help(const std::string &args) const;
- void buttonBoxRespond();
+
+ /*
+ * Outputs the message to the recorder file
+ *
+ * @param msg The file to write out to. If null, then stop recording.
+ */
+ void changeRecordingStatus(const std::string &msg);
+
+ /*
+ * Whether or not the recorder is in use.
+ */
bool isRecording() {return (bool) mStream.is_open();}
- virtual ~Recorder();
+
+ /*
+ * called when the button is pressed
+ *
+ * @param event is the event that is generated
+ */
+ void action(const gcn::ActionEvent &event);
+
+ private:
+ ChatWindow *mChat;
+
+ std::ofstream mStream;
};
#endif
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index bf45b711..cf12375c 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -19,15 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <string>
-#include <sstream>
-
#include <guichan/widgets/label.hpp>
-#include "../main.h"
#include "../configuration.h"
#include "../log.h"
#include "../logindata.h"
+#include "../main.h"
#include "button.h"
#include "checkbox.h"
@@ -38,12 +35,11 @@
#include "register.h"
#include "textfield.h"
-#include "../utils/tostring.h"
-
#include "widgets/layout.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/tostring.h"
/**
* Listener used while dealing with wrong data. It is used to direct the focus
diff --git a/src/gui/register.h b/src/gui/register.h
index 8ba377fa..9588e07e 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -22,15 +22,13 @@
#ifndef REGISTER_H
#define REGISTER_H
-#include <iosfwd>
+#include <string>
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class LoginData;
class OkDialog;
class WrongDataNoticeListener;
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 3ee27064..eacc4714 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "scrollarea.h"
#include "../configuration.h"
@@ -32,19 +30,22 @@
#include "../utils/dtor.h"
int ScrollArea::instances = 0;
+float ScrollArea::mAlpha = config.getValue("guialpha", 0.8);
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
Image *ScrollArea::buttons[4][2];
-ScrollArea::ScrollArea(bool gc):
+ScrollArea::ScrollArea(bool gc, bool opaque):
gcn::ScrollArea(),
+ mOpaque(opaque),
mGC(gc)
{
init();
}
-ScrollArea::ScrollArea(gcn::Widget *widget, bool gc):
+ScrollArea::ScrollArea(gcn::Widget *widget, bool gc, bool opaque):
gcn::ScrollArea(widget),
+ mOpaque(opaque),
mGC(gc)
{
init();
@@ -53,9 +54,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget, bool gc):
ScrollArea::~ScrollArea()
{
// Garbage collection
- if (mGC) {
+ if (mGC)
delete getContent();
- }
instances--;
@@ -89,8 +89,10 @@ void ScrollArea::init()
const int bggridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
+ for (y = 0; y < 3; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
background.grid[a] = textbox->getSubImage(
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
@@ -193,6 +195,16 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mScrollbarWidth));
}
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ background.grid[a]->setAlpha(mAlpha);
+ vMarker.grid[a]->setAlpha(mAlpha);
+ }
+ }
+
drawChildren(graphics);
}
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
index 4fababfa..33ebc692 100644
--- a/src/gui/scrollarea.h
+++ b/src/gui/scrollarea.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/scrollarea.hpp>
-#include "../guichanfwd.h"
-
class Image;
class ImageRect;
@@ -40,12 +38,12 @@ class ScrollArea : public gcn::ScrollArea
/**
* Constructor.
*/
- ScrollArea(bool gc = true);
+ ScrollArea(bool gc = true, bool opaque = true);
/**
* Constructor.
*/
- ScrollArea(gcn::Widget *content, bool gc = true);
+ ScrollArea(gcn::Widget *content, bool gc = true, bool opaque = true);
/**
* Destructor.
@@ -102,6 +100,7 @@ class ScrollArea : public gcn::ScrollArea
void drawHMarker(gcn::Graphics *graphics);
static int instances;
+ static float mAlpha;
static ImageRect background;
static ImageRect vMarker;
static Image *buttons[4][2];
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 7976e32e..e4be7921 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -19,30 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "shoplistbox.h"
#include "scrollarea.h"
#include "sell.h"
#include "shop.h"
+#include "shoplistbox.h"
#include "slider.h"
#include "widgets/layout.h"
-#include "../item.h"
#include "../npc.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../resources/iteminfo.h"
-
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-#include "../utils/tostring.h"
SellDialog::SellDialog(Network *network):
Window(_("Sell")),
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 8e639a3d..c11a7b7c 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -25,9 +25,9 @@
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
-#include "window.h"
+#include <SDL_types.h>
-#include "../guichanfwd.h"
+#include "window.h"
class Item;
class Network;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index d18f365c..19575cfb 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-#include <iostream>
-
#include "button.h"
#include "setup.h"
#include "setup_audio.h"
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 7090136e..5c189882 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -109,8 +109,8 @@ void Setup_Audio::cancel()
sound.setMusicVolume(mMusicVolume);
mMusicSlider->setValue(mMusicVolume);
- config.setValue("sound", mSoundEnabled ? 1 : 0);
- config.setValue("sfxVolume", mSfxVolume ? 1 : 0);
+ config.setValue("sound", mSoundEnabled ? true : false);
+ config.setValue("sfxVolume", mSfxVolume);
config.setValue("musicVolume", mMusicVolume);
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 2f5cd736..9e951895 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -26,8 +26,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Audio : public SetupTab, public gcn::ActionListener
{
public:
diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp
index 112925ae..49e08aeb 100644
--- a/src/gui/setup_colours.cpp
+++ b/src/gui/setup_colours.cpp
@@ -19,13 +19,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <vector>
+#include <string>
#include <guichan/listmodel.hpp>
#include <guichan/widgets/label.hpp>
#include <guichan/widgets/slider.hpp>
+#include "browserbox.h"
#include "colour.h"
+#include "itemlinkhandler.h"
+#include "listbox.h"
#include "scrollarea.h"
#include "setup_colours.h"
#include "slider.h"
@@ -36,19 +39,31 @@
#include "../configuration.h"
#include "../utils/gettext.h"
+#include "../utils/tostring.h"
Setup_Colours::Setup_Colours() :
mSelected(-1)
{
setOpaque(false);
- mColourBox = new gcn::ListBox(textColour);
+ mColourBox = new ListBox(textColour);
mColourBox->setActionEventId("colour_box");
mColourBox->addActionListener(this);
mScroll = new ScrollArea(mColourBox);
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScroll->setWidth(90);
+
+ mPreview = new BrowserBox(BrowserBox::AUTO_WRAP);
+ mPreview->setOpaque(false);
+
+ // Replace this later with a more appropriate link handler. For now, this'll
+ // do, as it'll do nothing when clicked on.
+ mPreview->setLinkHandler(new ItemLinkHandler());
+
+ mPreviewBox = new ScrollArea(mPreview);
+ mPreviewBox->setHeight(20);
+ mPreviewBox->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
+ gcn::ScrollArea::SHOW_NEVER);
mRedLabel = new gcn::Label(_("Red: "));
@@ -59,7 +74,7 @@ Setup_Colours::Setup_Colours() :
mRedText->addListener(this);
mRedSlider = new Slider(0, 255);
- mRedSlider->setWidth(90);
+ mRedSlider->setWidth(160);
mRedSlider->setValue(mRedText->getValue());
mRedSlider->setActionEventId("slider_red");
mRedSlider->addActionListener(this);
@@ -73,7 +88,7 @@ Setup_Colours::Setup_Colours() :
mGreenText->addListener(this);
mGreenSlider = new Slider(0, 255);
- mGreenSlider->setWidth(90);
+ mGreenSlider->setWidth(160);
mGreenSlider->setValue(mGreenText->getValue());
mGreenSlider->setActionEventId("slider_green");
mGreenSlider->addActionListener(this);
@@ -87,7 +102,7 @@ Setup_Colours::Setup_Colours() :
mBlueText->addListener(this);
mBlueSlider = new Slider(0, 255);
- mBlueSlider->setWidth(90);
+ mBlueSlider->setWidth(160);
mBlueSlider->setValue(mBlueText->getValue());
mBlueSlider->setActionEventId("slider_blue");
mBlueSlider->addActionListener(this);
@@ -98,18 +113,19 @@ Setup_Colours::Setup_Colours() :
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 1, 3).setPadding(2);
- place(1, 0, mRedLabel, 2);
- place(3, 0, mRedSlider);
- place(4, 0, mRedText).setPadding(1);
- place(1, 1, mGreenLabel, 2);
- place(3, 1, mGreenSlider);
- place(4, 1, mGreenText).setPadding(1);
- place(1, 2, mBlueLabel, 2);
- place(3, 2, mBlueSlider);
- place(4, 2, mBlueText).setPadding(1);
-
- setDimension(gcn::Rectangle(0, 0, 290, 150));
+ place(0, 0, mScroll, 4, 7).setPadding(2);
+ place(0, 7, mPreviewBox, 4).setPadding(2);
+ place(0, 8, mRedLabel, 2);
+ place(2, 8, mRedSlider);
+ place(3, 8, mRedText).setPadding(1);
+ place(0, 9, mGreenLabel, 2);
+ place(2, 9, mGreenSlider);
+ place(3, 9, mGreenText).setPadding(1);
+ place(0, 10, mBlueLabel, 2);
+ place(2, 10, mBlueSlider);
+ place(3, 10, mBlueText).setPadding(1);
+
+ setDimension(gcn::Rectangle(0, 0, 290, 250));
}
Setup_Colours::~Setup_Colours()
@@ -135,6 +151,18 @@ void Setup_Colours::action(const gcn::ActionEvent &event)
{
mSelected = mColourBox->getSelected();
int col = textColour->getColourAt(mSelected);
+ char ch = textColour->getColourCharAt(mSelected);
+ std::string msg;
+
+ if (ch == '<')
+ msg = toString("@@|") +
+ _("This is what the color looks like") + "@@";
+ else
+ msg = "##" + toString(ch) +
+ _("This is what the color looks like");
+
+ mPreview->clearRows();
+ mPreview->addRow(msg);
setEntry(mRedSlider, mRedText, col >> 16);
setEntry(mGreenSlider, mGreenText, (col >> 8) & 0xff);
setEntry(mBlueSlider, mBlueText, col & 0xff);
@@ -169,7 +197,7 @@ void Setup_Colours::action(const gcn::ActionEvent &event)
}
}
-void Setup_Colours::setEntry(Slider *s, TextField *t, int value)
+void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value)
{
s->setValue(value);
char buffer[100];
diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h
index 79afe122..57d9e304 100644
--- a/src/gui/setup_colours.h
+++ b/src/gui/setup_colours.h
@@ -23,19 +23,19 @@
#define SETUP_COLOURS_H
#include <string>
-#include <vector>
#include <guichan/actionlistener.hpp>
+
#include <guichan/widgets/label.hpp>
#include <guichan/widgets/listbox.hpp>
-#include "scrollarea.h"
#include "setuptab.h"
-#include "slider.h"
#include "textfield.h"
#include "../guichanfwd.h"
+class BrowserBox;
+
class Setup_Colours : public SetupTab, public gcn::ActionListener,
public TextFieldListener
{
@@ -49,25 +49,27 @@ class Setup_Colours : public SetupTab, public gcn::ActionListener,
void listen(const TextField *tf);
private:
gcn::ListBox *mColourBox;
- ScrollArea *mScroll;
+ gcn::ScrollArea *mScroll;
+ BrowserBox *mPreview;
+ gcn::ScrollArea *mPreviewBox;
int mSelected;
gcn::Label *mRedLabel;
- Slider *mRedSlider;
+ gcn::Slider *mRedSlider;
TextField *mRedText;
int mRedValue;
gcn::Label *mGreenLabel;
- Slider *mGreenSlider;
+ gcn::Slider *mGreenSlider;
TextField *mGreenText;
int mGreenValue;
gcn::Label *mBlueLabel;
- Slider *mBlueSlider;
+ gcn::Slider *mBlueSlider;
TextField *mBlueText;
int mBlueValue;
- void setEntry(Slider *s, TextField *t, int value);
+ void setEntry(gcn::Slider *s, TextField *t, int value);
void updateColour();
};
#endif
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 2c726b87..2ebcdbde 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -41,7 +41,7 @@ Setup_Joystick::Setup_Joystick():
{
setOpaque(false);
- mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0;
+ mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->addActionListener(this);
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index 2dc56439..eba8a2cc 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -26,8 +26,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Joystick : public SetupTab, public gcn::ActionListener
{
public:
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index e38b9b8c..5d7519ef 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -33,9 +33,6 @@
#include "widgets/layouthelper.h"
-#include "widgets/layouthelper.h"
-
-#include "../configuration.h"
#include "../keyboardconfig.h"
#include "../utils/gettext.h"
@@ -81,11 +78,10 @@ Setup_Keyboard::Setup_Keyboard():
refreshKeys();
- mKeyList->setDimension(gcn::Rectangle(0, 0, 185, 140));
mKeyList->addActionListener(this);
- mKeyList->setSelected(-1);
ScrollArea *scrollArea = new ScrollArea(mKeyList);
+ scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mAssignKeyButton = new Button(_("Assign"), "assign", this);
mAssignKeyButton->addActionListener(this);
@@ -142,9 +138,8 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
if (event.getSource() == mKeyList)
{
- if (!mKeySetting) {
+ if (!mKeySetting)
mAssignKeyButton->setEnabled(true);
- }
}
else if (event.getId() == "assign")
{
@@ -188,7 +183,8 @@ void Setup_Keyboard::refreshKeys()
void Setup_Keyboard::keyUnresolved()
{
- if (mKeySetting) {
+ if (mKeySetting)
+ {
newKeyCallback(keyboard.getNewKeyIndex());
keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE);
}
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index 6aa2bfa2..dee12135 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -26,7 +26,6 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
#include "setuptab.h"
#include "../guichanfwd.h"
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 9a7fb441..5c19bd2b 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -19,22 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <string>
#include <vector>
-#include <guichan/widgets/dropdown.hpp>
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "checkbox.h"
+#include "listbox.h"
#include "ok_dialog.h"
+#include "scrollarea.h"
#include "setup_players.h"
+#include "table.h"
+#include "widgets/dropdown.h"
#include "widgets/layouthelper.h"
#include "../configuration.h"
#include "../log.h"
-#include "../player_relations.h"
-#include "../sound.h"
#include "../utils/gettext.h"
@@ -135,8 +137,12 @@ public:
std::string name = (*player_names)[r];
gcn::Widget *widget = new gcn::Label(name);
mWidgets.push_back(widget);
+ gcn::ListModel *playerRelation = new PlayerRelationListModel();
- gcn::DropDown *choicebox = new gcn::DropDown(new PlayerRelationListModel());
+ gcn::DropDown *choicebox = new DropDown(playerRelation,
+ new ScrollArea(),
+ new ListBox(playerRelation),
+ false);
choicebox->setSelected(player_relations.getRelation(name));
mWidgets.push_back(choicebox);
}
@@ -219,19 +225,23 @@ Setup_Players::Setup_Players():
player_relations.getDefault() & PlayerRelation::TRADE)),
mDefaultWhisper(new CheckBox(_("Allow whispers"),
player_relations.getDefault() & PlayerRelation::WHISPER)),
- mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
- mIgnoreActionChoicesBox(new gcn::DropDown(new IgnoreChoicesListModel()))
+ mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this))
{
setOpaque(false);
+ mPlayerTable->setOpaque(false);
int table_width = NAME_COLUMN_WIDTH + RELATION_CHOICE_COLUMN_WIDTH;
mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN,
RELATION_CHOICE_COLUMN_WIDTH);
- mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width, 10));
+ mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width - 1, 10));
mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf));
- for (int i = 0; i < COLUMNS_NR; i++)
+ gcn::ListModel *ignoreChoices = new IgnoreChoicesListModel();
+ mIgnoreActionChoicesBox = new DropDown(ignoreChoices, new ScrollArea(),
+ new ListBox(ignoreChoices), false);
+
+ for (int i = 0; i < COLUMNS_NR; i++)
{
mPlayerTableTitleModel->set(0, i,
new gcn::Label(gettext(table_titles[i])));
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 22c8a9b6..2edc6983 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -24,17 +24,16 @@
#include <guichan/actionlistener.hpp>
-#include "button.h"
-#include "scrollarea.h"
#include "setuptab.h"
-#include "table.h"
-#include "../guichanfwd.h"
#include "../player_relations.h"
+class GuiTable;
class PlayerTableModel;
+class StaticTableModel;
-class Setup_Players : public SetupTab, public gcn::ActionListener, public PlayerRelationsListener
+class Setup_Players : public SetupTab,
+ public gcn::ActionListener, public PlayerRelationsListener
{
public:
Setup_Players();
@@ -54,13 +53,13 @@ private:
PlayerTableModel *mPlayerTableModel;
GuiTable *mPlayerTable;
GuiTable *mPlayerTitleTable;
- ScrollArea *mPlayerScrollArea;
+ gcn::ScrollArea *mPlayerScrollArea;
gcn::CheckBox *mPersistIgnores;
gcn::CheckBox *mDefaultTrading;
gcn::CheckBox *mDefaultWhisper;
- Button *mDeleteButton;
+ gcn::Button *mDeleteButton;
gcn::DropDown *mIgnoreActionChoicesBox;
};
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 2381ab41..b1d33b09 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -104,12 +104,12 @@ ModeListModel::ModeListModel()
}
Setup_Video::Setup_Video():
- mFullScreenEnabled(config.getValue("screen", 0)),
- mOpenGLEnabled(config.getValue("opengl", 0)),
- mCustomCursorEnabled(config.getValue("customcursor", 1)),
- mParticleEffectsEnabled(config.getValue("particleeffects", 1)),
- mSpeechBubbleEnabled(config.getValue("speechbubble", 1)),
- mNameEnabled(config.getValue("showownname", 0)),
+ mFullScreenEnabled(config.getValue("screen", false)),
+ mOpenGLEnabled(config.getValue("opengl", false)),
+ mCustomCursorEnabled(config.getValue("customcursor", true)),
+ mParticleEffectsEnabled(config.getValue("particleeffects", true)),
+ mSpeechBubbleEnabled(config.getValue("speechbubble", true)),
+ mNameEnabled(config.getValue("showownname", false)),
mOpacity(config.getValue("guialpha", 0.8)),
mFps((int) config.getValue("fpslimit", 0)),
mModeListModel(new ModeListModel),
@@ -280,7 +280,7 @@ void Setup_Video::apply()
{
// Full screen changes
bool fullscreen = mFsCheckBox->isSelected();
- if (fullscreen != (config.getValue("screen", 0) == 1))
+ if (fullscreen != (config.getValue("screen", false) == 1))
{
/* The OpenGL test is only necessary on Windows, since switching
* to/from full screen works fine on Linux. On Windows we'd have to
@@ -291,7 +291,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__)
// checks for opengl usage
- if (!(config.getValue("opengl", 0) == 1))
+ if (!(config.getValue("opengl", false) == 1))
{
#endif
if (!graphics->setFullscreen(fullscreen))
@@ -313,13 +313,13 @@ void Setup_Video::apply()
_("Restart needed for changes to take effect."));
}
#endif
- config.setValue("screen", fullscreen ? 1 : 0);
+ config.setValue("screen", fullscreen ? true : false);
}
// OpenGL change
if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled)
{
- config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0);
+ config.setValue("opengl", mOpenGLCheckBox->isSelected() ? true : false);
// OpenGL can currently only be changed by restarting, notify user.
new OkDialog(_("Changing OpenGL"),
@@ -330,14 +330,14 @@ void Setup_Video::apply()
config.setValue("fpslimit", mFps);
// We sync old and new values at apply time
- mFullScreenEnabled = config.getValue("screen", 0);
- mCustomCursorEnabled = config.getValue("customcursor", 1);
- mParticleEffectsEnabled = config.getValue("particleeffects", 1);
- mSpeechBubbleEnabled = config.getValue("speechbubble", 1);
- mNameEnabled = config.getValue("showownname", 0);
+ mFullScreenEnabled = config.getValue("screen", false);
+ mCustomCursorEnabled = config.getValue("customcursor", true);
+ mParticleEffectsEnabled = config.getValue("particleeffects", true);
+ mSpeechBubbleEnabled = config.getValue("speechbubble", true);
+ mNameEnabled = config.getValue("showownname", false);
mOpacity = config.getValue("guialpha", 0.8);
mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
- mOpenGLEnabled = config.getValue("opengl", 0);
+ mOpenGLEnabled = config.getValue("opengl", false);
}
int Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field,
@@ -377,13 +377,13 @@ void Setup_Video::cancel()
updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius");
updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness");
- config.setValue("screen", mFullScreenEnabled ? 1 : 0);
- config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
- config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0);
- config.setValue("speechbubble", mSpeechBubbleEnabled ? 1 : 0);
- config.setValue("showownname", mNameEnabled ? 1 : 0);
+ config.setValue("screen", mFullScreenEnabled ? true : false);
+ config.setValue("customcursor", mCustomCursorEnabled ? true : false);
+ config.setValue("particleeffects", mParticleEffectsEnabled ? true : false);
+ config.setValue("speechbubble", mSpeechBubbleEnabled ? true : false);
+ config.setValue("showownname", mNameEnabled ? true : false);
config.setValue("guialpha", mOpacity);
- config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
+ config.setValue("opengl", mOpenGLEnabled ? true : false);
}
void Setup_Video::action(const gcn::ActionEvent &event)
@@ -393,23 +393,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
const std::string mode = mModeListModel->getElementAt(mModeList->getSelected());
const int width = atoi(mode.substr(0, mode.find("x")).c_str());
const int height = atoi(mode.substr(mode.find("x") + 1).c_str());
- const int bpp = 0;
- const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
- const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
-
- // Try to set the desired video mode
- if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
- {
- std::cerr << _("Couldn't set ")
- << width << "x" << height << "x" << bpp << _(" video mode: ")
- << SDL_GetError() << std::endl;
- exit(1);
- }
-
- // Initialize for drawing
- graphics->_endDraw();
- graphics->_beginDraw();
- graphics->updateScreen();
// TODO: Find out why the drawing area doesn't resize without a restart.
new OkDialog(_("Screen resolution changed"),
@@ -425,19 +408,19 @@ void Setup_Video::action(const gcn::ActionEvent &event)
else if (event.getId() == "customcursor")
{
config.setValue("customcursor",
- mCustomCursorCheckBox->isSelected() ? 1 : 0);
+ mCustomCursorCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "particleeffects")
{
config.setValue("particleeffects",
- mParticleEffectsCheckBox->isSelected() ? 1 : 0);
+ mParticleEffectsCheckBox->isSelected() ? true : false);
new OkDialog(_("Particle effect settings changed"),
_("Restart your client or change maps for the change to take effect."));
}
else if (event.getId() == "speechbubble")
{
config.setValue("speechbubble",
- mSpeechBubbleCheckBox->isSelected() ? 1 : 0);
+ mSpeechBubbleCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "showownname")
{
@@ -446,7 +429,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (player_node)
player_node->mUpdateName = true;
config.setValue("showownname",
- mNameCheckBox->isSelected() ? 1 : 0);
+ mNameCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "fpslimitslider")
{
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index d863fb64..303b5bfc 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -27,8 +27,6 @@
#include "setuptab.h"
-#include "../guichanfwd.h"
-
class Setup_Video : public SetupTab, public gcn::ActionListener,
public gcn::KeyListener
{
diff --git a/src/gui/shop.h b/src/gui/shop.h
index 22b649d0..e0db4c59 100644
--- a/src/gui/shop.h
+++ b/src/gui/shop.h
@@ -27,10 +27,9 @@
#include <guichan/listmodel.hpp>
-#include "../guichanfwd.h"
#include "../shopitem.h"
-#include "../resources/image.h"
+class ShopItem;
class ShopItems : public gcn::ListModel
{
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp
index 765b9f08..b5761535 100644
--- a/src/gui/shoplistbox.cpp
+++ b/src/gui/shoplistbox.cpp
@@ -19,19 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <guichan/basiccontainer.hpp>
#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/imagefont.hpp>
#include <guichan/listmodel.hpp>
-#include <guichan/mouseinput.hpp>
+#include "colour.h"
+#include "shop.h"
#include "shoplistbox.h"
+#include "../configuration.h"
#include "../graphics.h"
const int ITEM_ICON_SIZE = 32;
+float ShopListBox::mAlpha = config.getValue("guialpha", 0.8);
+
ShopListBox::ShopListBox(gcn::ListModel *listModel):
ListBox(listModel),
mPlayerMoney(0)
@@ -59,6 +60,15 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (!mListModel)
return;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ bool valid;
+ const int red = (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green = (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 255;
+
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
graphics->setFont(getFont());
@@ -68,16 +78,16 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
i < mListModel->getNumberOfElements();
++i, y += mRowHeight)
{
- gcn::Color backgroundColor = gcn::Color(0xffffff);
+ gcn::Color backgroundColor = gcn::Color(255, 255, 255, alpha);
if (i == mSelected)
{
- backgroundColor = gcn::Color(235, 200, 115);
+ backgroundColor = gcn::Color(red, green, blue, alpha);
}
else if (mShopItems &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
{
- backgroundColor = gcn::Color(0x919191);
+ backgroundColor = gcn::Color(145, 145, 145, alpha);
}
graphics->setColor(backgroundColor);
diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h
index 733af4eb..cde4786e 100644
--- a/src/gui/shoplistbox.h
+++ b/src/gui/shoplistbox.h
@@ -23,9 +23,8 @@
#define SHOPLISTBOX_H
#include "listbox.h"
-#include "shop.h"
-#include "../guichanfwd.h"
+class ShopItems;
/**
* A list box, meant to be used inside a scroll area. Same as the Guichan list
@@ -86,6 +85,8 @@ class ShopListBox : public ListBox
unsigned int mRowHeight; /**< Row Height */
+ static float mAlpha;
+
bool mPriceCheck;
};
diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp
index e7675c7d..4472818e 100644
--- a/src/gui/shortcutcontainer.cpp
+++ b/src/gui/shortcutcontainer.cpp
@@ -21,25 +21,20 @@
#include "shortcutcontainer.h"
-#include "../graphics.h"
-#include "../inventory.h"
-#include "../item.h"
-#include "../itemshortcut.h"
-#include "../keyboardconfig.h"
-#include "../localplayer.h"
+#include "../configuration.h"
#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
#include "../utils/tostring.h"
+float ShortcutContainer::mAlpha = config.getValue("guialpha", 0.8);
+
ShortcutContainer::ShortcutContainer():
mGridWidth(1),
mGridHeight(1)
{
}
-
void ShortcutContainer::widgetResized(const gcn::Event &event)
{
mGridWidth = getWidth() / mBoxWidth;
diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h
index 66aca6c3..f5f06163 100644
--- a/src/gui/shortcutcontainer.h
+++ b/src/gui/shortcutcontainer.h
@@ -26,12 +26,10 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
- * An item shortcut container. Used to quickly use items.
+ * A generic shortcut container.
*
* \ingroup GUI
*/
@@ -41,7 +39,7 @@ class ShortcutContainer : public gcn::Widget,
{
public:
/**
- * Constructor. Initializes the graphic.
+ * Constructor. Initializes the shortcut container.
*/
ShortcutContainer();
@@ -51,7 +49,7 @@ class ShortcutContainer : public gcn::Widget,
~ShortcutContainer(){}
/**
- * Draws the items.
+ * Draws the shortcuts
*/
virtual void draw(gcn::Graphics *graphics) = 0;
@@ -97,6 +95,8 @@ class ShortcutContainer : public gcn::Widget,
Image *mBackgroundImg;
+ static float mAlpha;
+
int mMaxItems;
int mBoxWidth;
int mBoxHeight;
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 799fc35b..5d49a3c6 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -19,14 +19,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "scrollarea.h"
#include "shortcutcontainer.h"
#include "shortcutwindow.h"
-#include "scrollarea.h"
#include "../configuration.h"
static const int SCROLL_PADDING = 0;
+int ShortcutWindow::mInstances = 0;
+
ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
{
setWindowName(title);
@@ -37,6 +39,8 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
mItems = content;
+ mInstances++;
+
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
setMinWidth(mItems->getBoxWidth() + border);
setMinHeight(mItems->getBoxHeight() + border);
@@ -46,10 +50,11 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
const int width = (int) config.getValue("screenwidth", 800);
const int height = (int) config.getValue("screenheight", 600);
- setDefaultSize(width - mItems->getBoxWidth() - border,
- height - (mItems->getBoxHeight() * mItems->getMaxItems()) -
- border, mItems->getBoxWidth() + border,
- (mItems->getBoxHeight() * mItems->getMaxItems()) + border);
+ setDefaultSize(width - (mInstances * mItems->getBoxWidth()) -
+ (mInstances * border), height - (mItems->getBoxHeight() *
+ mItems->getMaxItems()) - border, mItems->getBoxWidth() +
+ border, (mItems->getBoxHeight() * mItems->getMaxItems()) +
+ border);
mScrollArea = new ScrollArea(mItems);
mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index 0168669e..64592328 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -24,10 +24,8 @@
#include "window.h"
-#include "../guichanfwd.h"
-
-class ShortcutContainer;
class ScrollArea;
+class ShortcutContainer;
/**
* A window around the ItemShortcutContainer.
@@ -57,6 +55,8 @@ class ShortcutWindow : public Window
ShortcutContainer *mItems;
ScrollArea *mScrollArea;
+
+ static int mInstances;
};
extern ShortcutWindow *itemShortcutWindow;
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 304719b6..c4f8737b 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -23,7 +23,9 @@
#include "button.h"
#include "listbox.h"
+#include "scrollarea.h"
#include "skill.h"
+#include "table.h"
#include "windowcontainer.h"
#include "widgets/layout.h"
@@ -51,7 +53,7 @@ class SkillGuiTableModel : public StaticTableModel
{
public:
SkillGuiTableModel(SkillDialog *dialog) :
- StaticTableModel(0, 3, 0xbdb5aa)
+ StaticTableModel(0, 3)
{
mEntriesNr = 0;
mDialog = dialog;
@@ -124,8 +126,12 @@ SkillDialog::SkillDialog():
{
initSkillinfo();
mTableModel = new SkillGuiTableModel(this);
- mTable.setModel(mTableModel);
- mTable.setLinewiseSelection(true);
+ mTable = new GuiTable(mTableModel);
+ mTable->setOpaque(false);
+ mTable->setLinewiseSelection(true);
+ mTable->setWrappingEnabled(true);
+ mTable->setActionEventId("skill");
+ mTable->addActionListener(this);
setWindowName(_("Skills"));
setCloseButton(true);
@@ -134,18 +140,13 @@ SkillDialog::SkillDialog():
setMinHeight(50 + mTableModel->getHeight());
setMinWidth(200);
-// mSkillListBox = new ListBox(this);
- ScrollArea *skillScrollArea = new ScrollArea(&mTable);
+ ScrollArea *skillScrollArea = new ScrollArea(mTable);
mPointsLabel = new gcn::Label(strprintf(_("Skill points: %d"), 0));
mIncButton = new Button(_("Up"), _("inc"), this);
mUseButton = new Button(_("Use"), _("use"), this);
mUseButton->setEnabled(false);
-// mSkillListBox->setActionEventId("skill");
- mTable.setActionEventId("skill");
-
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- skillScrollArea->setOpaque(false);
place(0, 0, skillScrollArea, 5).setPadding(3);
place(0, 1, mPointsLabel, 2);
@@ -155,15 +156,13 @@ SkillDialog::SkillDialog():
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
-// mSkillListBox->addActionListener(this);
- mTable.addActionListener(this);
-
setLocationRelativeTo(getParent());
loadWindowState();
}
SkillDialog::~SkillDialog()
{
+ delete mTable;
}
void SkillDialog::action(const gcn::ActionEvent &event)
@@ -171,15 +170,14 @@ void SkillDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "inc")
{
// Increment skill
- int selectedSkill = mTable.getSelectedRow();//mSkillListBox->getSelected();
+ int selectedSkill = mTable->getSelectedRow();
if (selectedSkill >= 0)
player_node->raiseSkill(mSkillList[selectedSkill]->id);
}
else if (event.getId() == "skill")
{
- mIncButton->setEnabled(
- mTable.getSelectedRow() > -1 &&
- player_node->mSkillPoint > 0);
+ mIncButton->setEnabled(mTable->getSelectedRow() > -1 &&
+ player_node->mSkillPoint > 0);
}
else if (event.getId() == "close")
setVisible(false);
@@ -190,7 +188,7 @@ void SkillDialog::update()
mPointsLabel->setCaption(strprintf(_("Skill points: %d"),
player_node->mSkillPoint));
- int selectedSkill = mTable.getSelectedRow();
+ int selectedSkill = mTable->getSelectedRow();
if (selectedSkill >= 0)
{
@@ -278,7 +276,8 @@ static void initSkillinfo()
std::string name = XML::getProperty(node, "name", "");
bool modifiable = !atoi(XML::getProperty(node, "fixed", "0").c_str());
- if (index >= 0) {
+ if (index >= 0)
+ {
skill_db.resize(index + 1, emptySkillInfo);
skill_db[index].name = name;
skill_db[index].modifiable = modifiable;
diff --git a/src/gui/skill.h b/src/gui/skill.h
index 582892f0..0600d106 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -25,20 +25,15 @@
#include <vector>
#include <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
-#include "scrollarea.h"
-#include "table.h"
#include "window.h"
-#include "table.h"
-
-#include "../guichanfwd.h"
struct SKILL {
short id; /**< Index into "skill_db" array */
short lv, sp;
};
+class GuiTable;
class SkillGuiTableModel;
/**
@@ -73,7 +68,7 @@ class SkillDialog : public Window, public gcn::ActionListener
const std::vector<SKILL*>& getSkills() const { return mSkillList; }
private:
- GuiTable mTable;//gcn::ListBox *mSkillListBox;
+ GuiTable *mTable;
ScrollArea *skillScrollArea;
SkillGuiTableModel *mTableModel;
gcn::Label *mPointsLabel;
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 37136012..9bfa840f 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -21,6 +21,7 @@
#include "slider.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -28,6 +29,7 @@
Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip;
Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip;
+float Slider::mAlpha = config.getValue("guialpha", 0.8);
int Slider::mInstances = 0;
Slider::Slider(double scaleEnd):
@@ -107,6 +109,20 @@ void Slider::draw(gcn::Graphics *graphics)
int x = 0;
int y = (h - hStart->getHeight()) / 2;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ hStart->setAlpha(mAlpha);
+ hMid->setAlpha(mAlpha);
+ hEnd->setAlpha(mAlpha);
+ hGrip->setAlpha(mAlpha);
+
+ vStart->setAlpha(mAlpha);
+ vMid->setAlpha(mAlpha);
+ vEnd->setAlpha(mAlpha);
+ vGrip->setAlpha(mAlpha);
+ }
+
static_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
w -= hStart->getWidth() + hEnd->getWidth();
diff --git a/src/gui/slider.h b/src/gui/slider.h
index c14c5be9..56ea334a 100644
--- a/src/gui/slider.h
+++ b/src/gui/slider.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/slider.hpp>
-#include "../guichanfwd.h"
-
class Image;
/**
@@ -68,6 +66,7 @@ class Slider : public gcn::Slider {
static Image *hStart, *hMid, *hEnd, *hGrip;
static Image *vStart, *vMid, *vEnd, *vGrip;
+ static float mAlpha;
static int mInstances;
};
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 84eeb7d4..c76558e4 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -24,19 +24,15 @@
#include <guichan/widgets/label.hpp>
#include "gui.h"
+#include "scrollarea.h"
#include "speechbubble.h"
-
-#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
+#include "textbox.h"
#include "../utils/gettext.h"
-// TODO: Fix windows so that they can each load their own skins without the
-// other windows overriding another window's skin.
SpeechBubble::SpeechBubble():
Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml")
{
- // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px)
setContentSize(140, 46);
setShowTitle(false);
setTitleBarHeight(0);
@@ -61,11 +57,13 @@ SpeechBubble::SpeechBubble():
add(mSpeechArea);
setLocationRelativeTo(getParent());
+}
- // LEEOR / TODO: This causes an exception error.
- //moveToBottom(getParent());
-
- mSpeechBox->setTextWrapped( "" );
+SpeechBubble::~SpeechBubble()
+{
+ delete mCaption;
+ delete mSpeechBox;
+ delete mSpeechArea;
}
void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
@@ -77,31 +75,18 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
void SpeechBubble::setText(std::string mText)
{
- mSpeechBox->setMinWidth(140);
- mSpeechBox->setTextWrapped(mText);
+ int width = mCaption->getWidth() + 3;
+ mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width);
const int fontHeight = getFont()->getHeight();
const int numRows = mSpeechBox->getNumberOfRows() + 1;
- if (numRows > 2)
- {
- // 15 == height of each line of text (based on font heights)
- // 14 == speechbubble Top + Bottom graphic pixel heights
- setContentSize(mSpeechBox->getMinWidth() + fontHeight,
- (numRows * fontHeight) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- mSpeechBox->getMinWidth() + 5,
- (numRows * fontHeight)));
- }
- else
- {
- int width = mCaption->getWidth() + 3;
- if (width < getFont()->getWidth(mText))
- width = getFont()->getWidth(mText);
- setContentSize(width + fontHeight, (fontHeight * 2) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- width, fontHeight));
- }
+ if (width < mSpeechBox->getMinWidth())
+ width = mSpeechBox->getMinWidth();
+
+ setContentSize(width + fontHeight, (numRows * fontHeight) + 6);
+ mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5,
+ (numRows * fontHeight)));
}
unsigned int SpeechBubble::getNumRows()
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index 9606f8f7..d2d81332 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -22,14 +22,16 @@
#ifndef SPEECHBUBBLE_H
#define SPEECHBUBBLE_H
-#include "scrollarea.h"
-#include "textbox.h"
#include "window.h"
+class ScrollArea;
+class TextBox;
+
class SpeechBubble : public Window
{
public:
SpeechBubble();
+ ~SpeechBubble();
void setCaption(const std::string &name,
const gcn::Color &color = 0x000000);
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 526fa6b1..21087fad 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -26,6 +26,8 @@
#include "status.h"
#include "windowcontainer.h"
+#include "widgets/layout.h"
+
#include "../localplayer.h"
#include "../utils/gettext.h"
@@ -39,83 +41,27 @@ StatusWindow::StatusWindow(LocalPlayer *player):
setWindowName(_("Status"));
setCloseButton(true);
setDefaultSize((windowContainer->getWidth() - 365) / 2,
- (windowContainer->getHeight() - 255) / 2, 400, 275);
- loadWindowState();
+ (windowContainer->getHeight() - 255) / 2, 400, 335);
// ----------------------
// Status Part
// ----------------------
mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
- mGpLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
- mJobLvlLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
+ mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
+ mGpLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
mHpLabel = new gcn::Label(_("HP:"));
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
- mHpValueLabel = new gcn::Label;
mXpLabel = new gcn::Label(_("Exp:"));
mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mXpValueLabel = new gcn::Label;
mMpLabel = new gcn::Label(_("MP:"));
mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- mMpValueLabel = new gcn::Label;
-
- mJobXpLabel = new gcn::Label(_("Job:"));
- mJobXpBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
- mJobValueLabel = new gcn::Label;
-
- int y = 3;
- int x = 5;
-
- mLvlLabel->setPosition(x, y);
- x += mLvlLabel->getWidth() + 40;
- mJobLvlLabel->setPosition(x, y);
- x += mJobLvlLabel->getWidth() + 40;
- mGpLabel->setPosition(x, y);
-
- y += mLvlLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mHpLabel->setPosition(x, y);
- x += mHpLabel->getWidth() + 5;
- mHpBar->setPosition(x, y);
- x += mHpBar->getWidth() + 5;
- mHpValueLabel->setPosition(x, y);
-
- mXpLabel->setPosition(175, y);
- mXpBar->setPosition(205, y);
- mXpValueLabel->setPosition(290, y);
-
- y += mHpLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mMpLabel->setPosition(x, y);
- x += mMpLabel->getWidth() + 5;
- mMpBar->setPosition(x, y);
- x += mMpBar->getWidth() + 5;
- mMpValueLabel->setPosition(x, y);
-
- mJobXpLabel->setPosition(175, y);
- mJobXpBar->setPosition(205, y);
- mJobValueLabel->setPosition(290, y);
-
- add(mLvlLabel);
- add(mJobLvlLabel);
- add(mGpLabel);
- add(mHpLabel);
- add(mHpValueLabel);
- add(mMpLabel);
- add(mMpValueLabel);
- add(mXpLabel);
- add(mXpValueLabel);
- add(mJobXpLabel);
- add(mJobValueLabel);
- add(mHpBar);
- add(mMpBar);
- add(mXpBar);
- add(mJobXpBar);
+
+ mJobLabel = new gcn::Label(_("Job:"));
+ mJobBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
// ----------------------
// Stats Part
@@ -125,6 +71,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
gcn::Label *mStatsTitleLabel = new gcn::Label(_("Stats"));
gcn::Label *mStatsTotalLabel = new gcn::Label(_("Total"));
gcn::Label *mStatsCostLabel = new gcn::Label(_("Cost"));
+ mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER);
// Derived Stats
mStatsAttackLabel = new gcn::Label(_("Attack:"));
@@ -147,10 +94,13 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsReflexPoints = new gcn::Label;
// New labels
- for (int i = 0; i < 6; i++) {
- mStatsLabel[i] = new gcn::Label;
+ for (int i = 0; i < 6; i++)
+ {
+ mStatsLabel[i] = new gcn::Label("0");
+ mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER);
mStatsDisplayLabel[i] = new gcn::Label;
mPointsLabel[i] = new gcn::Label("0");
+ mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER);
}
mRemainingStatsPointsLabel = new gcn::Label;
@@ -162,68 +112,53 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsButton[4] = new Button("+", "DEX", this);
mStatsButton[5] = new Button("+", "LUK", this);
-
- // Set position
- mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 );
- mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
- int totalLabelY = mStatsTotalLabel->getY();
- mStatsCostLabel->setPosition(170, totalLabelY);
-
- for (int i = 0; i < 6; i++)
- {
- mStatsLabel[i]->setPosition(5, mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(115,
- totalLabelY + (i * 23) + 15);
- mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15);
- }
-
- mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[5]->getY() + 25);
-
- mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
- mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
- mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY());
- mStatsMagicDefenseLabel->setPosition(220, mStatsLabel[3]->getY());
- mStatsAccuracyLabel->setPosition(220, mStatsLabel[4]->getY());
- mStatsEvadeLabel->setPosition(220, mStatsLabel[5]->getY());
- mStatsReflexLabel->setPosition(220, mRemainingStatsPointsLabel->getY());
-
- mStatsAttackPoints->setPosition(310, mStatsLabel[0]->getY());
- mStatsDefensePoints->setPosition(310, mStatsLabel[1]->getY());
- mStatsMagicAttackPoints->setPosition(310, mStatsLabel[2]->getY());
- mStatsMagicDefensePoints->setPosition(310, mStatsLabel[3]->getY());
- mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY());
- mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY());
- mStatsReflexPoints->setPosition(310, mRemainingStatsPointsLabel->getY());
-
// Assemble
- add(mStatsTitleLabel);
- add(mStatsTotalLabel);
- add(mStatsCostLabel);
- for (int i = 0; i < 6; i++)
+ ContainerPlacer place;
+ place = getPlacer(0, 0);
+
+ place(0, 0, mLvlLabel, 3);
+ place(5, 0, mJobLvlLabel, 3);
+ place(8, 0, mGpLabel, 3);
+ place(1, 1, mHpLabel);
+ place(2, 1, mHpBar, 3);
+ place(6, 1, mXpLabel);
+ place(7, 1, mXpBar, 3);
+ place(1, 2, mMpLabel);
+ place(2, 2, mMpBar, 3);
+ place(6, 2, mJobLabel);
+ place(7, 2, mJobBar, 3);
+ place.getCell().matchColWidth(0, 1);
+ place = getPlacer(0, 3);
+ place(0, 0, mStatsTitleLabel, 5);
+ place(5, 1, mStatsTotalLabel, 5);
+ place(12, 1, mStatsCostLabel, 5);
+ for(int i = 0; i < 6; i++)
{
- add(mStatsLabel[i]);
- add(mStatsDisplayLabel[i]);
- add(mStatsButton[i]);
- add(mPointsLabel[i]);
+ place(0, 2 + i, mStatsLabel[i], 7).setPadding(5);
+ place(7, 2 + i, mStatsDisplayLabel[i]).setPadding(5);
+ place(10, 2 + i, mStatsButton[i]);
+ place(12, 2 + i, mPointsLabel[i]).setPadding(5);
}
- add(mStatsAttackLabel);
- add(mStatsDefenseLabel);
- add(mStatsMagicAttackLabel);
- add(mStatsMagicDefenseLabel);
- add(mStatsAccuracyLabel);
- add(mStatsEvadeLabel);
- add(mStatsReflexLabel);
-
- add(mStatsAttackPoints);
- add(mStatsDefensePoints);
- add(mStatsMagicAttackPoints);
- add(mStatsMagicDefensePoints);
- add(mStatsAccuracyPoints);
- add(mStatsEvadePoints);
- add(mStatsReflexPoints);
-
- add(mRemainingStatsPointsLabel);
+ place(14, 2, mStatsAttackLabel, 7).setPadding(5);
+ place(14, 3, mStatsDefenseLabel, 7).setPadding(5);
+ place(14, 4, mStatsMagicAttackLabel, 7).setPadding(5);
+ place(14, 5, mStatsMagicDefenseLabel, 7).setPadding(5);
+ place(14, 6, mStatsAccuracyLabel, 7).setPadding(5);
+ place(14, 7, mStatsEvadeLabel, 7).setPadding(5);
+ place(14, 8, mStatsReflexLabel, 7).setPadding(5);
+ place(21, 2, mStatsAttackPoints, 3).setPadding(5);
+ place(21, 3, mStatsDefensePoints, 3).setPadding(5);
+ place(21, 4, mStatsMagicAttackPoints, 3).setPadding(5);
+ place(21, 5, mStatsMagicDefensePoints, 3).setPadding(5);
+ place(21, 6, mStatsAccuracyPoints, 3).setPadding(5);
+ place(21, 7, mStatsEvadePoints, 3).setPadding(5);
+ place(21, 8, mStatsReflexPoints, 3).setPadding(5);
+ place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+
+ loadWindowState();
}
void StatusWindow::update()
@@ -239,21 +174,17 @@ void StatusWindow::update()
mGpLabel->setCaption(strprintf(_("Money: %d GP"), mPlayer->mGp));
mGpLabel->adjustSize();
- mHpValueLabel->setCaption(toString(mPlayer->mHp) +
- "/" + toString(mPlayer->mMaxHp));
- mHpValueLabel->adjustSize();
+ mHpBar->setText(toString(mPlayer->mHp) +
+ "/" + toString(mPlayer->mMaxHp));
- mMpValueLabel->setCaption(toString(mPlayer->mMp) +
- "/" + toString(mPlayer->mMaxMp));
- mMpValueLabel->adjustSize();
+ mMpBar->setText(toString(mPlayer->mMp) +
+ "/" + toString(mPlayer->mMaxMp));
- mXpValueLabel->setCaption(toString(mPlayer->getXp()) +
- "/" + toString(mPlayer->mXpForNextLevel));
- mXpValueLabel->adjustSize();
+ mXpBar->setText(toString(mPlayer->getXp()) +
+ "/" + toString(mPlayer->mXpForNextLevel));
- mJobValueLabel->setCaption(toString(mPlayer->mJobXp) +
- "/" + toString(mPlayer->mJobXpForNextLevel));
- mJobValueLabel->adjustSize();
+ mJobBar->setText(toString(mPlayer->mJobXp) +
+ "/" + toString(mPlayer->mJobXpForNextLevel));
// HP Bar coloration
if (mPlayer->mHp < int(mPlayer->mMaxHp / 3))
@@ -274,7 +205,7 @@ void StatusWindow::update()
mXpBar->setProgress(
(float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel);
- mJobXpBar->setProgress(
+ mJobBar->setProgress(
(float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel);
// Stats Part
@@ -339,30 +270,6 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-
- // Update Second column widgets position
- mJobLvlLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
- mLvlLabel->getY());
- mGpLabel->setPosition(mJobLvlLabel->getX() + mJobLvlLabel->getWidth() + 20,
- mJobLvlLabel->getY());
-
- mXpLabel->setPosition(
- mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(
- mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(
- mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
-
- mJobXpLabel->setPosition(mXpBar->getX() - mJobXpLabel->getWidth() - 5,
- mMpLabel->getY());
- mJobXpBar->setPosition(
- mJobXpLabel->getX() + mJobXpLabel->getWidth() + 5,
- mJobXpLabel->getY());
- mJobValueLabel->setPosition(mJobXpBar->getX() + mJobXpBar->getWidth() + 5,
- mJobXpLabel->getY());
}
void StatusWindow::draw(gcn::Graphics *g)
diff --git a/src/gui/status.h b/src/gui/status.h
index 14a7617e..00a48f4e 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -22,14 +22,10 @@
#ifndef STATUS_H
#define STATUS_H
-#include <iosfwd>
-
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-
class LocalPlayer;
class ProgressBar;
@@ -69,11 +65,9 @@ class StatusWindow : public Window, public gcn::ActionListener
*/
gcn::Label *mLvlLabel, *mJobLvlLabel;
gcn::Label *mGpLabel;
- gcn::Label *mHpLabel, *mHpValueLabel;
- gcn::Label *mMpLabel, *mMpValueLabel;
- gcn::Label *mXpLabel, *mXpValueLabel, *mJobXpLabel, *mJobValueLabel;
+ gcn::Label *mHpLabel, *mMpLabel, *mXpLabel, *mJobLabel;
ProgressBar *mHpBar, *mMpBar;
- ProgressBar *mXpBar, *mJobXpBar;
+ ProgressBar *mXpBar, *mJobBar;
/**
* Derived Statistics captions
diff --git a/src/gui/table.cpp b/src/gui/table.cpp
index 7e855523..19039b2d 100644
--- a/src/gui/table.cpp
+++ b/src/gui/table.cpp
@@ -19,13 +19,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
-#include <guichan/graphics.hpp>
#include <guichan/actionlistener.hpp>
+#include <guichan/graphics.hpp>
+#include <guichan/key.hpp>
+#include "colour.h"
#include "table.h"
+#include "../configuration.h"
+
+#include "../utils/dtor.h"
+
+float GuiTable::mAlpha = config.getValue("guialpha", 0.8);
+
class GuiTableActionListener : public gcn::ActionListener
{
public:
@@ -49,7 +55,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid
mColumn(column),
mWidget(widget)
{
- if (widget) {
+ if (widget)
+ {
widget->addActionListener(this);
widget->_setParent(table);
}
@@ -57,7 +64,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid
GuiTableActionListener::~GuiTableActionListener()
{
- if (mWidget) {
+ if (mWidget)
+ {
mWidget->removeActionListener(this);
mWidget->_setParent(NULL);
}
@@ -70,14 +78,20 @@ void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent)
}
-GuiTable::GuiTable(TableModel *initial_model) :
+GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
+ bool opacity) :
mLinewiseMode(false),
+ mWrappingEnabled(false),
+ mOpaque(opacity),
+ mBackgroundColor(background),
mModel(NULL),
mSelectedRow(0),
mSelectedColumn(0),
mTopWidget(NULL)
{
setModel(initial_model);
+ setFocusable(true);
+
addMouseListener(this);
addKeyListener(this);
}
@@ -94,16 +108,17 @@ TableModel *GuiTable::getModel() const
void GuiTable::setModel(TableModel *new_model)
{
- if (mModel) {
+ if (mModel)
+ {
uninstallActionListeners();
mModel->removeListener(this);
}
-
mModel = new_model;
installActionListeners();
- if (new_model) {
+ if (new_model)
+ {
new_model->installListener(this);
recomputeDimensions();
}
@@ -168,10 +183,62 @@ int GuiTable::getColumnWidth(int i)
return 0;
}
-void GuiTable::uninstallActionListeners()
+void GuiTable::setSelectedRow(int selected)
+{
+ if (mModel == NULL)
+ {
+ mSelectedRow = -1;
+ }
+ else
+ {
+ if (selected < 0 && !mWrappingEnabled)
+ {
+ mSelectedRow = -1;
+ }
+ else if (selected >= mModel->getRows() && mWrappingEnabled)
+ {
+ mSelectedRow = 0;
+ }
+ else if ((selected >= mModel->getRows() && !mWrappingEnabled) ||
+ (selected < 0 && mWrappingEnabled))
+ {
+ mSelectedRow = mModel->getRows() - 1;
+ }
+ else
+ {
+ mSelectedRow = selected;
+ }
+ }
+}
+
+void GuiTable::setSelectedColumn(int selected)
{
- for (std::vector<GuiTableActionListener *>::const_iterator it = action_listeners.begin(); it != action_listeners.end(); it++)
- delete *it;
+ if (mModel == NULL)
+ {
+ mSelectedColumn = -1;
+ }
+ else
+ {
+ if ((selected >= mModel->getColumns() && mWrappingEnabled) ||
+ (selected < 0 && !mWrappingEnabled))
+ {
+ mSelectedColumn = 0;
+ }
+ else if ((selected >= mModel->getColumns() && !mWrappingEnabled) ||
+ (selected < 0 && mWrappingEnabled))
+ {
+ mSelectedColumn = mModel->getColumns() - 1;
+ }
+ else
+ {
+ mSelectedColumn = selected;
+ }
+ }
+}
+
+void GuiTable::uninstallActionListeners(void)
+{
+ delete_all(action_listeners);
action_listeners.clear();
}
@@ -184,10 +251,11 @@ void GuiTable::installActionListeners()
int columns = mModel->getColumns();
for (int row = 0; row < rows; ++row)
- for (int column = 0; column < columns; ++column) {
+ for (int column = 0; column < columns; ++column)
+ {
gcn::Widget *widget = mModel->getElementAt(row, column);
action_listeners.push_back(new GuiTableActionListener(this, widget,
- row, column));
+ row, column));
}
_setFocusHandler(_getFocusHandler()); // propagate focus handler to widgets
@@ -196,12 +264,22 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(gcn::Graphics* graphics)
{
- graphics->setColor(getBackgroundColor());
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
-
if (!mModel)
return;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ if (mOpaque)
+ {
+ const int red = getBackgroundColor().r;
+ const int green = getBackgroundColor().g;
+ const int blue = getBackgroundColor().b;
+ const int alpha = mAlpha * 255;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ }
+
// First, determine how many rows we need to draw, and where we should start.
int first_row = -(getY() / getRowHeight());
@@ -223,44 +301,68 @@ void GuiTable::draw(gcn::Graphics* graphics)
int height = getRowHeight();
int y_offset = first_row * height;
- for (int r = first_row; r < first_row + rows_nr; ++r) {
+ for (int r = first_row; r < first_row + rows_nr; ++r)
+ {
int x_offset = 0;
- for (int c = first_column; c <= last_column; ++c) {
+ for (int c = first_column; c <= last_column; ++c)
+ {
gcn::Widget *widget = mModel->getElementAt(r, c);
int width = getColumnWidth(c);
- if (widget) {
+ if (widget)
+ {
gcn::Rectangle bounds(x_offset, y_offset, width, height);
- if (widget == mTopWidget) {
+ if (widget == mTopWidget)
+ {
bounds.height = widget->getHeight();
bounds.width = widget->getWidth();
}
widget->setDimension(bounds);
+ if (!mLinewiseMode && c == mSelectedColumn && r == mSelectedRow)
+ {
+ bool valid;
+ const int red =
+ (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green =
+ (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 127;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(bounds);
+ }
+
graphics->pushClipArea(bounds);
widget->draw(graphics);
graphics->popClipArea();
-
- if (!mLinewiseMode
- && c == mSelectedColumn
- && r == mSelectedRow)
- graphics->drawRectangle(bounds);
}
x_offset += width;
}
- if (mLinewiseMode
- && r == mSelectedRow)
- graphics->drawRectangle(gcn::Rectangle(0, y_offset,
+ if (mLinewiseMode && r == mSelectedRow)
+ {
+ bool valid;
+ const int red =
+ (textColour->getColour('H', valid) >> 16) & 0xFF;
+ const int green =
+ (textColour->getColour('H', valid) >> 8) & 0xFF;
+ const int blue = textColour->getColour('H', valid) & 0xFF;
+ const int alpha = mAlpha * 127;
+
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, y_offset,
x_offset, height));
+ }
y_offset += height;
}
- if (mTopWidget) {
+ if (mTopWidget)
+ {
gcn::Rectangle bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
mTopWidget->draw(graphics);
@@ -268,21 +370,17 @@ void GuiTable::draw(gcn::Graphics* graphics)
}
}
-void GuiTable::logic()
-{
-}
-
void GuiTable::moveToTop(gcn::Widget *widget)
{
gcn::Widget::moveToTop(widget);
- this->mTopWidget = widget;
+ mTopWidget = widget;
}
void GuiTable::moveToBottom(gcn::Widget *widget)
{
gcn::Widget::moveToBottom(widget);
- if (widget == this->mTopWidget)
- this->mTopWidget = NULL;
+ if (widget == mTopWidget)
+ mTopWidget = NULL;
}
gcn::Rectangle GuiTable::getChildrenArea()
@@ -293,16 +391,62 @@ gcn::Rectangle GuiTable::getChildrenArea()
// -- KeyListener notifications
void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
+ gcn::Key key = keyEvent.getKey();
+
+ if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE)
+ {
+ distributeActionEvent();
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::UP)
+ {
+ setSelectedRow(mSelectedRow - 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::DOWN)
+ {
+ setSelectedRow(mSelectedRow + 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::LEFT)
+ {
+ setSelectedColumn(mSelectedColumn - 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::RIGHT)
+ {
+ setSelectedColumn(mSelectedColumn + 1);
+
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::HOME)
+ {
+ setSelectedRow(0);
+ setSelectedColumn(0);
+ keyEvent.consume();
+ }
+ else if (key.getValue() == gcn::Key::END)
+ {
+ setSelectedRow(mModel->getRows() - 1);
+ setSelectedColumn(mModel->getColumns() - 1);
+ keyEvent.consume();
+ }
}
// -- MouseListener notifications
void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
{
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) {
+ if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ {
int row = getRowForY(mouseEvent.getY());
int column = getColumnForX(mouseEvent.getX());
- if (row > -1 && column > -1) {
+ if (row > -1 && column > -1 &&
+ row < mModel->getRows() && column < mModel->getColumns())
+ {
mSelectedColumn = column;
mSelectedRow = row;
}
@@ -313,10 +457,25 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
+ if (isFocused())
+ {
+ if (getSelectedRow() >= 0 )
+ {
+ setSelectedRow(getSelectedRow() - 1);
+ }
+
+ mouseEvent.consume();
+ }
}
void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
+ if (isFocused())
+ {
+ setSelectedRow(getSelectedRow() + 1);
+
+ mouseEvent.consume();
+ }
}
void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
@@ -326,10 +485,13 @@ void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
// -- TableModelListener notifications
void GuiTable::modelUpdated(bool completed)
{
- if (completed) {
+ if (completed)
+ {
recomputeDimensions();
installActionListeners();
- } else { // before the update?
+ }
+ else
+ { // before the update?
mTopWidget = NULL; // No longer valid in general
uninstallActionListeners();
}
@@ -340,18 +502,18 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y)
int row = getRowForY(y);
int column = getColumnForX(x);
- if (mTopWidget
- && mTopWidget->getDimension().isPointInRect(x, y))
+ if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
return mTopWidget;
- if (row > -1
- && column > -1) {
+ if (row > -1 && column > -1)
+ {
gcn::Widget *w = mModel->getElementAt(row, column);
if (w && w->isFocusable())
return w;
else
return NULL; // Grab the event locally
- } else
+ }
+ else
return NULL;
}
@@ -359,8 +521,7 @@ int GuiTable::getRowForY(int y)
{
int row = y / getRowHeight();
- if (row < 0
- || row >= mModel->getRows())
+ if (row < 0 || row >= mModel->getRows())
return -1;
else
return row;
@@ -371,14 +532,14 @@ int GuiTable::getColumnForX(int x)
int column;
int delta = 0;
- for (column = 0; column < mModel->getColumns(); column++) {
+ for (column = 0; column < mModel->getColumns(); column++)
+ {
delta += getColumnWidth(column);
if (x <= delta)
break;
}
- if (column < 0
- || column >= mModel->getColumns())
+ if (column < 0 || column >= mModel->getColumns())
return -1;
else
return column;
diff --git a/src/gui/table.h b/src/gui/table.h
index 9dde8900..841f6ef2 100644
--- a/src/gui/table.h
+++ b/src/gui/table.h
@@ -24,16 +24,12 @@
#include <vector>
-#include <guichan/gui.hpp>
#include <guichan/keylistener.hpp>
#include <guichan/mouselistener.hpp>
-#include <guichan/platform.hpp>
#include <guichan/widget.hpp>
#include "table_model.h"
-#include "../guichanfwd.h"
-
class GuiTableActionListener;
/**
@@ -54,7 +50,8 @@ class GuiTable : public gcn::Widget,
friend class GuiTableActionListener;
public:
- GuiTable(TableModel * initial_model = NULL);
+ GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff,
+ bool opacity = true);
virtual ~GuiTable();
@@ -68,25 +65,36 @@ public:
*
* Note that actions issued by widgets returned from the model will update
* the table selection, but only AFTER any event handlers installed within
- * the widget have been triggered. To be notified after such an update,
- * add an action listener to the table instead.
+ * the widget have been triggered. To be notified after such an update, add
+ * an action listener to the table instead.
*/
void setModel(TableModel *m);
+ const TableModel* getModel() {return mModel;}
+
void setSelected(int row, int column);
int getSelectedRow();
int getSelectedColumn();
- gcn::Rectangle getChildrenArea();
+ void setSelectedRow(int selected);
+
+ void setSelectedColumn(int selected);
+
+ bool isWrappingEnabled() const {return mWrappingEnabled;}
+
+ void setWrappingEnabled(bool wrappingEnabled)
+ {mWrappingEnabled = wrappingEnabled;}
+
+ gcn::Rectangle getChildrenArea(void);
/**
- * Toggle whether to use linewise selection mode, in which the table
- * selects an entire line at a time, rather than a single cell.
+ * Toggle whether to use linewise selection mode, in which the table selects
+ * an entire line at a time, rather than a single cell.
*
- * Note that column information is tracked even in linewise selection
- * mode; this mode therefore only affects visualisation.
+ * Note that column information is tracked even in linewise selection mode;
+ * this mode therefore only affects visualisation.
*
* Disabled by default.
*
@@ -97,8 +105,6 @@ public:
// Inherited from Widget
virtual void draw(gcn::Graphics* graphics);
- virtual void logic();
-
virtual gcn::Widget *getWidgetAt(int x, int y);
virtual void moveToTop(gcn::Widget *child);
@@ -110,6 +116,21 @@ public:
// Inherited from KeyListener
virtual void keyPressed(gcn::KeyEvent& keyEvent);
+ /**
+ * Sets the table to be opaque, that is sets the table
+ * to display its background.
+ *
+ * @param opaque True if the table should be opaque, false otherwise.
+ */
+ virtual void setOpaque(bool opaque) {mOpaque = opaque;}
+
+ /**
+ * Checks if the table is opaque, that is if the table area displays its
+ * background.
+ *
+ * @return True if the table is opaque, false otherwise.
+ */
+ virtual bool isOpaque() const {return mOpaque;}
// Inherited from MouseListener
virtual void mousePressed(gcn::MouseEvent& mouseEvent);
@@ -137,6 +158,15 @@ private:
int getColumnForX(int x); // -1 on error
void recomputeDimensions();
bool mLinewiseMode;
+ bool mWrappingEnabled;
+ bool mOpaque;
+
+ static float mAlpha;
+
+ /**
+ * Holds the background color of the table.
+ */
+ gcn::Color mBackgroundColor;
TableModel *mModel;
diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp
index 33dd8cb2..4fa13bae 100644
--- a/src/gui/table_model.cpp
+++ b/src/gui/table_model.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstdlib>
-
-#include <guichan/graphics.hpp>
#include <guichan/widget.hpp>
#include "table_model.h"
@@ -54,13 +51,10 @@ void TableModel::signalAfterUpdate()
#define WIDGET_AT(row, column) (((row) * mColumns) + (column))
#define DYN_SIZE(h) ((h) >= 0) // determines whether this size is tagged for auto-detection
-StaticTableModel::StaticTableModel(int row, int column,
- gcn::Color backgroundColor, bool opacity) :
+StaticTableModel::StaticTableModel(int row, int column) :
mRows(row),
mColumns(column),
- mHeight(1),
- mOpaque(opacity),
- mBackgroundColor(backgroundColor)
+ mHeight(1)
{
mTableModel.resize(row * column, NULL);
mWidths.resize(column, 1);
@@ -165,24 +159,3 @@ int StaticTableModel::getHeight(void)
return (mColumns * mHeight);
}
-void StaticTableModel::drawBackground(gcn::Graphics *graphics)
-{
- if (isOpaque())
- {
- for (unsigned int i = 0; i < mTableModel.size(); i++)
- {
- mTableModel[i]->setBackgroundColor(mBackgroundColor);
- }
- }
-}
-
-void StaticTableModel::setOpaque(bool opaque)
-{
- mOpaque = opaque;
-}
-
-bool StaticTableModel::isOpaque() const
-{
- return mOpaque;
-}
-
diff --git a/src/gui/table_model.h b/src/gui/table_model.h
index 03b69dba..9ca36120 100644
--- a/src/gui/table_model.h
+++ b/src/gui/table_model.h
@@ -25,11 +25,6 @@
#include <set>
#include <vector>
-#include <guichan/color.hpp>
-#include <guichan/gui.hpp>
-
-#include "../guichanfwd.h"
-
class TableModelListener
{
public:
@@ -101,8 +96,7 @@ private:
class StaticTableModel : public TableModel
{
public:
- StaticTableModel(int width, int height, gcn::Color background = 0xffffff,
- bool opacity = true);
+ StaticTableModel(int width, int height);
virtual ~StaticTableModel();
/**
@@ -132,22 +126,6 @@ public:
*/
virtual void resize();
- /**
- * Sets the table to be opaque, that is sets the table
- * to display its background.
- *
- * @param opaque True if the table should be opaque, false otherwise.
- */
- virtual void setOpaque(bool opaque);
-
- /**
- * Checks if the scroll area is opaque, that is if the scroll area
- * displays its background.
- *
- * @return True if the scroll area is opaque, false otherwise.
- */
- virtual bool isOpaque() const;
-
virtual int getRows();
virtual int getColumns();
virtual int getRowHeight();
@@ -159,22 +137,8 @@ public:
protected:
int mRows, mColumns;
int mHeight;
- bool mOpaque;
std::vector<gcn::Widget *> mTableModel;
std::vector<int> mWidths;
-
- /**
- * Holds the background color of the table.
- */
- gcn::Color mBackgroundColor;
-
- /**
- * Draws the background of the table, that is
- * the area behind the content.
- *
- * @param graphics a Graphics object to draw with.
- */
- virtual void drawBackground(gcn::Graphics *graphics);
};
#endif /* !defined(TABLE_MODEL_H) */
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index ee03c79d..2a86d549 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -21,7 +21,6 @@
#include <sstream>
-#include <guichan/basiccontainer.hpp>
#include <guichan/font.hpp>
#include "textbox.h"
@@ -31,9 +30,10 @@ TextBox::TextBox():
{
setOpaque(false);
setFrameSize(0);
+ mMinWidth = getWidth();
}
-void TextBox::setTextWrapped(const std::string &text)
+void TextBox::setTextWrapped(const std::string &text, int minDimension)
{
// Make sure parent scroll area sets width of this widget
if (getParent())
@@ -41,6 +41,9 @@ void TextBox::setTextWrapped(const std::string &text)
getParent()->logic();
}
+ // Take the supplied minimum dimension as a starting point and try to beat it
+ mMinWidth = minDimension;
+
std::stringstream wrappedStream;
std::string::size_type newlinePos, lastNewlinePos = 0;
int minWidth = 0;
@@ -61,6 +64,17 @@ void TextBox::setTextWrapped(const std::string &text)
std::string::size_type spacePos, lastSpacePos = 0;
xpos = 0;
+ spacePos = text.rfind(" ", text.size());
+
+ if (spacePos != std::string::npos)
+ {
+ const std::string word = text.substr(spacePos + 1);
+ const int length = getFont()->getWidth(word);
+
+ if (length > mMinWidth)
+ mMinWidth = length;
+ }
+
do
{
spacePos = line.find(" ", lastSpacePos);
@@ -88,9 +102,8 @@ void TextBox::setTextWrapped(const std::string &text)
else
{
if (xpos > minWidth)
- {
minWidth = xpos;
- }
+
// The window wasn't big enough. Resize it and try again.
if (minWidth > mMinWidth)
{
@@ -100,6 +113,8 @@ void TextBox::setTextWrapped(const std::string &text)
spacePos = 0;
lastNewlinePos = 0;
newlinePos = text.find("\n", lastNewlinePos);
+ if (newlinePos == std::string::npos)
+ newlinePos = text.size();
line = text.substr(lastNewlinePos, newlinePos -
lastNewlinePos);
width = 0;
@@ -116,17 +131,15 @@ void TextBox::setTextWrapped(const std::string &text)
while (spacePos != line.size());
if (text.find("\n", lastNewlinePos) != std::string::npos)
- {
wrappedStream << "\n";
- }
+
lastNewlinePos = newlinePos + 1;
}
while (newlinePos != text.size());
if (xpos > minWidth)
- {
minWidth = xpos;
- }
+
mMinWidth = minWidth;
gcn::TextBox::setText(wrappedStream.str());
diff --git a/src/gui/textbox.h b/src/gui/textbox.h
index 98b60402..10a81fc0 100644
--- a/src/gui/textbox.h
+++ b/src/gui/textbox.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/textbox.hpp>
-#include "../guichanfwd.h"
-
/**
* A text box, meant to be used inside a scroll area. Same as the Guichan text
* box except this one doesn't have a background or border, instead completely
@@ -33,7 +31,8 @@
*
* \ingroup GUI
*/
-class TextBox : public gcn::TextBox {
+class TextBox : public gcn::TextBox
+{
public:
/**
* Constructor.
@@ -43,18 +42,13 @@ class TextBox : public gcn::TextBox {
/**
* Sets the text after wrapping it to the current width of the widget.
*/
- void setTextWrapped(const std::string &text);
+ void setTextWrapped(const std::string &text, int minDimension);
/**
* Get the minimum text width for the text box.
*/
int getMinWidth() { return mMinWidth; }
- /**
- * Set the minimum text width for the text box.
- */
- void setMinWidth(int width) { mMinWidth = width; }
-
private:
int mMinWidth;
};
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 3369195d..99a95a2e 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include <guichan/font.hpp>
#include "sdlinput.h"
@@ -37,6 +35,7 @@
#undef DELETE //Win32 compatibility hack
int TextField::instances = 0;
+float TextField::mAlpha = config.getValue("guialpha", 0.8);
ImageRect TextField::skin;
TextField::TextField(const std::string& text):
@@ -53,9 +52,6 @@ TextField::TextField(const std::string& text):
Image *textbox = resman->getImage("graphics/gui/deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
- //Image *textbox = resman->getImage("graphics/gui/textbox.png");
- //int gridx[4] = {0, 5, 26, 31};
- //int gridy[4] = {0, 5, 26, 31};
int a = 0, x, y;
for (y = 0; y < 3; y++) {
@@ -96,6 +92,15 @@ void TextField::draw(gcn::Graphics *graphics)
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ skin.grid[a]->setAlpha(mAlpha);
+ }
+ }
}
void TextField::drawFrame(gcn::Graphics *graphics)
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index a2432175..73824615 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -24,8 +24,6 @@
#include <guichan/widgets/textfield.hpp>
-#include "../guichanfwd.h"
-
class ImageRect;
class TextField;
@@ -99,6 +97,7 @@ class TextField : public gcn::TextField {
private:
static int instances;
+ static float mAlpha;
static ImageRect skin;
bool mNumeric;
int mMinimum;
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index b20b7c86..af30d1fe 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -41,8 +41,6 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../resources/iteminfo.h"
-
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
#include "../utils/tostring.h"
diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h
index 6f0671a2..cd68a94e 100644
--- a/src/gui/truetypefont.h
+++ b/src/gui/truetypefont.h
@@ -25,7 +25,6 @@
#include <string>
#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
#ifndef __APPLE__
#include <SDL/SDL_ttf.h>
#else
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 67e05bbd..1f62bd2d 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -26,6 +26,9 @@
#include <guichan/widgets/label.hpp>
+// Curl should be included after Guichan to avoid Windows redefinitions
+#include <curl/curl.h>
+
#include "browserbox.h"
#include "button.h"
#include "progressbar.h"
@@ -34,9 +37,6 @@
#include "widgets/layout.h"
-// Curl should be included after Guichan to avoid Windows redefinitions
-#include <curl/curl.h>
-
#include "../configuration.h"
#include "../log.h"
#include "../main.h"
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 6450ece2..4ada3c3a 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -29,8 +29,6 @@
#include "window.h"
-#include "../guichanfwd.h"
-
#include "../utils/mutex.h"
class BrowserBox;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index fe058c0a..f5a6edb4 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
-
-#include "gui.h"
#include "ministatus.h"
#include "popupmenu.h"
#include "viewport.h"
@@ -37,9 +34,6 @@
#include "../npc.h"
#include "../textmanager.h"
-#include "../resources/animation.h"
-#include "../resources/image.h"
-#include "../resources/imageset.h"
#include "../resources/monsterinfo.h"
#include "../resources/resourcemanager.h"
@@ -216,7 +210,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
{
- (*i)->drawSpeech(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
+ (*i)->drawSpeech(-(int) mPixelViewX, -(int) mPixelViewY);
(*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 5ed40166..522ea734 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -26,16 +26,15 @@
#include "windowcontainer.h"
-#include "../being.h"
#include "../configlistener.h"
-#include "../guichanfwd.h"
+#include "../position.h"
-class Map;
class FloorItem;
+class Graphics;
class ImageSet;
class Item;
+class Map;
class PopupMenu;
-class Graphics;
/**
* The viewport on the map. Displays the current map and handles mouse input
@@ -139,4 +138,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
PopupMenu *mPopupMenu; /**< Popup menu. */
};
+extern Viewport *viewport; /**< The viewport */
+
#endif
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 88a12d68..31d35cb0 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -23,6 +23,11 @@
#include "dropdown.h"
+#include "../colour.h"
+#include "../listbox.h"
+#include "../scrollarea.h"
+
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -33,12 +38,12 @@
int DropDown::instances = 0;
Image *DropDown::buttons[2][2];
ImageRect DropDown::skin;
+float DropDown::mAlpha = config.getValue("guialpha", 0.8);
-DropDown::DropDown(gcn::ListModel *listModel,
- gcn::ScrollArea *scrollArea,
- gcn::ListBox *listBox):
- gcn::DropDown::DropDown(listModel,
- scrollArea, listBox)
+DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea,
+ gcn::ListBox *listBox, bool opacity):
+ gcn::DropDown::DropDown(listModel, scrollArea, listBox),
+ mOpaque(opacity)
{
setFrameSize(2);
@@ -58,6 +63,11 @@ DropDown::DropDown(gcn::ListModel *listModel,
buttons[0][1] =
resman->getImage("graphics/gui/vscroll_down_pressed.png");
+ buttons[0][0]->setAlpha(mAlpha);
+ buttons[0][1]->setAlpha(mAlpha);
+ buttons[1][0]->setAlpha(mAlpha);
+ buttons[1][1]->setAlpha(mAlpha);
+
// get the border skin
Image *boxBorder = resman->getImage("graphics/gui/deepbox.png");
int gridx[4] = {0, 3, 28, 31};
@@ -70,6 +80,7 @@ DropDown::DropDown(gcn::ListModel *listModel,
gridx[x], gridy[y],
gridx[x + 1] - gridx[x] + 1,
gridy[y + 1] - gridy[y] + 1);
+ skin.grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -108,19 +119,44 @@ void DropDown::draw(gcn::Graphics* graphics)
h = getHeight();
}
- int alpha = getBaseColor().a;
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+
+ buttons[0][0]->setAlpha(mAlpha);
+ buttons[0][1]->setAlpha(mAlpha);
+ buttons[1][0]->setAlpha(mAlpha);
+ buttons[1][1]->setAlpha(mAlpha);
+
+ for (int a = 0; a < 9; a++)
+ {
+ skin.grid[a]->setAlpha(mAlpha);
+ }
+ }
+
+ bool valid;
+ const int alpha = mAlpha * 255;
gcn::Color faceColor = getBaseColor();
faceColor.a = alpha;
- gcn::Color highlightColor = faceColor + 0x303030;
+ gcn::Color highlightColor = textColour->getColour('H', valid);
highlightColor.a = alpha;
gcn::Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
+ if (mOpaque)
+ {
+ int red = getBackgroundColor().r;
+ int green = getBackgroundColor().g;
+ int blue = getBackgroundColor().b;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h));
+
+ red = getForegroundColor().r;
+ green = getForegroundColor().g;
+ blue = getForegroundColor().b;
+ graphics->setColor(gcn::Color(red, green, blue, alpha));
+ }
- graphics->setColor(getBackgroundColor());
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h));
-
- graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
if (mListBox->getListModel() && mListBox->getSelected() >= 0)
@@ -140,7 +176,7 @@ void DropDown::draw(gcn::Graphics* graphics)
{
drawChildren(graphics);
- // Draw two lines separating the ListBox with se selected
+ // Draw two lines separating the ListBox with selected
// element view.
graphics->setColor(highlightColor);
graphics->drawLine(0, h, getWidth(), h);
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 25ae05f8..e5919dc7 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -22,15 +22,8 @@
#ifndef DROPDOWN_H
#define DROPDOWN_H
-#include <iosfwd>
-
#include <guichan/widgets/dropdown.hpp>
-#include "../listbox.h"
-#include "../scrollarea.h"
-
-#include "../../guichanfwd.h"
-
class Image;
class ImageRect;
@@ -56,7 +49,8 @@ class DropDown : public gcn::DropDown
*/
DropDown(gcn::ListModel *listModel = NULL,
gcn::ScrollArea *scrollArea = NULL,
- gcn::ListBox *listBox = NULL);
+ gcn::ListBox *listBox = NULL,
+ bool opacity = true);
/**
* Destructor.
@@ -67,6 +61,22 @@ class DropDown : public gcn::DropDown
void drawFrame(gcn::Graphics* graphics);
+ /**
+ * Sets the widget to be opaque, that is sets the widget to display its
+ * background.
+ *
+ * @param opaque True if the widget should be opaque, false otherwise.
+ */
+ void setOpaque(bool opaque) {mOpaque = opaque;}
+
+ /**
+ * Checks if the widget is opaque, that is if the widget area displays
+ * its background.
+ *
+ * @return True if the widget is opaque, false otherwise.
+ */
+ bool isOpaque() const {return mOpaque;}
+
protected:
/**
@@ -80,6 +90,9 @@ class DropDown : public gcn::DropDown
static int instances;
static Image *buttons[2][2];
static ImageRect skin;
+ static float mAlpha;
+
+ bool mOpaque;
};
#endif // end DROPDOWN_H
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index 4b8bb4da..fa264e37 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -23,6 +23,7 @@
#include "resizegrip.h"
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -30,6 +31,7 @@
Image *ResizeGrip::gripImage = 0;
int ResizeGrip::mInstances = 0;
+float ResizeGrip::mAlpha = config.getValue("guialpha", 0.8);
ResizeGrip::ResizeGrip(std::string image)
{
@@ -38,6 +40,7 @@ ResizeGrip::ResizeGrip(std::string image)
// Load the grip image
ResourceManager *resman = ResourceManager::getInstance();
gripImage = resman->getImage(image);
+ gripImage->setAlpha(mAlpha);
}
mInstances++;
@@ -58,5 +61,11 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ gripImage->setAlpha(mAlpha);
+ }
+
static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
}
diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h
index 7f1329a2..620c133f 100644
--- a/src/gui/widgets/resizegrip.h
+++ b/src/gui/widgets/resizegrip.h
@@ -24,8 +24,6 @@
#include <guichan/widget.hpp>
-#include "../../guichanfwd.h"
-
class Image;
/**
@@ -56,6 +54,7 @@ class ResizeGrip : public gcn::Widget
private:
static Image *gripImage; /**< Resize grip image */
static int mInstances; /**< Number of resize grip instances */
+ static float mAlpha;
};
#endif
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index c54b2390..22e952e7 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -19,12 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
+#include <guichan/widgets/label.hpp>
#include "tab.h"
-
#include "tabbedarea.h"
+#include "../../configuration.h"
#include "../../graphics.h"
#include "../../resources/image.h"
@@ -33,6 +33,7 @@
#include "../../utils/dtor.h"
int Tab::mInstances = 0;
+float Tab::mAlpha = config.getValue("guialpha", 0.8);
enum{
TAB_STANDARD, // 0
@@ -79,6 +80,7 @@ Tab::~Tab()
void Tab::init()
{
setFrameSize(0);
+ mHighlighted = false;
if (mInstances == 0)
{
@@ -98,6 +100,7 @@ void Tab::init()
data[x].gridX, data[y].gridY,
data[x + 1].gridX - data[x].gridX + 1,
data[y + 1].gridY - data[y].gridY + 1);
+ tabImg[mode].grid[a]->setAlpha(mAlpha);
a++;
}
}
@@ -109,16 +112,33 @@ void Tab::init()
void Tab::draw(gcn::Graphics *graphics)
{
- int mode;
+ int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea && mTabbedArea->isTabSelected(this))
+ if (mTabbedArea)
{
- mode = TAB_SELECTED;
+ if(mTabbedArea->isTabSelected(this))
+ {
+ mode = TAB_SELECTED;
+ // if tab is selected, it doesnt need to highlight activity
+ mLabel->setForegroundColor(gcn::Color(0, 0, 0));
+ mHighlighted = false;
+ }
+ else if (mHighlighted)
+ {
+ mode = TAB_HIGHLIGHTED;
+ mLabel->setForegroundColor(gcn::Color(255, 0, 0));
+ }
}
- else
+
+ if (config.getValue("guialpha", 0.8) != mAlpha)
{
- mode = TAB_STANDARD;
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int a = 0; a < 9; a++)
+ {
+ tabImg[TAB_SELECTED].grid[a]->setAlpha(mAlpha);
+ tabImg[TAB_STANDARD].grid[a]->setAlpha(mAlpha);
+ }
}
// draw tab
@@ -128,3 +148,8 @@ void Tab::draw(gcn::Graphics *graphics)
// draw label
drawChildren(graphics);
}
+
+void Tab::setHighlighted(bool high)
+{
+ mHighlighted = high;
+}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 8382df83..3af4e2bf 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -47,12 +47,20 @@ class Tab : public gcn::Tab
*/
void draw(gcn::Graphics *graphics);
+ /**
+ * Set tab highlighted
+ */
+ void setHighlighted(bool high);
+
private:
/** Load images if no other instances exist yet */
void init();
static ImageRect tabImg[4]; /**< Tab state graphics */
static int mInstances; /**< Number of tab instances */
+ static float mAlpha;
+
+ bool mHighlighted;
};
#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index e97e9416..797b4be9 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -25,10 +25,7 @@
#include <guichan/exception.hpp>
-#include <guichan/widgets/icon.hpp>
-
#include "gui.h"
-#include "gccontainer.h"
#include "window.h"
#include "windowcontainer.h"
@@ -37,7 +34,6 @@
#include "../configlistener.h"
#include "../configuration.h"
-#include "../graphics.h"
#include "../log.h"
#include "../resources/image.h"
@@ -58,9 +54,6 @@ class WindowConfigListener : public ConfigListener
void optionChanged(const std::string &)
{
Window::mAlphaChanged = true;
-// for_each(Window::border.grid, Window::border.grid + 9,
-// std::bind2nd(std::mem_fun(&Image::setAlpha),
-// config.getValue("guialpha", 0.8)));
}
};
@@ -195,6 +188,15 @@ void Window::draw(gcn::Graphics *graphics)
getPadding()
);
}
+
+ // Update window alpha values
+ if (mAlphaChanged)
+ {
+ for_each(border.grid, border.grid + 9,
+ std::bind2nd(std::mem_fun(&Image::setAlpha),
+ config.getValue("guialpha", 0.8)));
+ closeImage->setAlpha(config.getValue("guialpha", 0.8));
+ }
drawChildren(graphics);
}
diff --git a/src/gui/windowcontainer.h b/src/gui/windowcontainer.h
index a3e80223..62704d1b 100644
--- a/src/gui/windowcontainer.h
+++ b/src/gui/windowcontainer.h
@@ -24,15 +24,14 @@
#include <guichan/widgets/container.hpp>
-#include "../guichanfwd.h"
-
/**
* A window container. This container adds functionality for more convenient
* widget (windows in particular) destruction.
*
* \ingroup GUI
*/
-class WindowContainer : public gcn::Container {
+class WindowContainer : public gcn::Container
+{
public:
/**
* Do GUI logic. This functions adds automatic deletion of objects that
diff --git a/src/guichanfwd.h b/src/guichanfwd.h
index 2e97db68..4863421c 100644
--- a/src/guichanfwd.h
+++ b/src/guichanfwd.h
@@ -22,7 +22,8 @@
#ifndef GUICHANFWD_H
#define GUICHANFWD_H
-namespace gcn {
+namespace gcn
+{
class ActionListener;
class AllegroGraphics;
class AllegroImage;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 8824e1ba..3ca26e1e 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -20,7 +20,6 @@
*/
#include <algorithm>
-#include <cassert>
#include "inventory.h"
#include "item.h"
@@ -28,7 +27,8 @@
struct SlotUsed : public std::unary_function<Item*, bool>
{
- bool operator()(const Item *item) const {
+ bool operator()(const Item *item) const
+ {
return item && item->getId() != -1 && item->getQuantity() > 0;
}
};
@@ -59,10 +59,9 @@ Item* Inventory::getItem(int index) const
Item* Inventory::findItem(int itemId) const
{
for (int i = 0; i < mSize; i++)
- {
if (mItems[i] && mItems[i]->getId() == itemId)
return mItems[i];
- }
+
return NULL;
}
@@ -73,38 +72,41 @@ void Inventory::addItem(int id, int quantity, bool equipment)
void Inventory::setItem(int index, int id, int quantity, bool equipment)
{
- if (index < 0 || index >= mSize) {
+ if (index < 0 || index >= mSize)
+ {
logger->log("Warning: invalid inventory index: %d", index);
return;
}
- if (!mItems[index] && id > 0) {
+ if (!mItems[index] && id > 0)
+ {
Item *item = new Item(id, quantity, equipment);
item->setInvIndex(index);
mItems[index] = item;
- } else if (id > 0) {
+ }
+ else if (id > 0)
+ {
mItems[index]->setId(id);
mItems[index]->setQuantity(quantity);
mItems[index]->setEquipment(equipment);
- } else if (mItems[index]) {
+ }
+ else if (mItems[index])
+ {
removeItemAt(index);
}
}
void Inventory::clear()
{
- for (int i = 0; i < mSize; i++) {
+ for (int i = 0; i < mSize; i++)
removeItemAt(i);
- }
}
void Inventory::removeItem(int id)
{
- for (int i = 0; i < mSize; i++) {
- if (mItems[i] && mItems[i]->getId() == id) {
+ for (int i = 0; i < mSize; i++)
+ if (mItems[i] && mItems[i]->getId() == id)
removeItemAt(i);
- }
- }
}
void Inventory::removeItemAt(int index)
@@ -115,11 +117,9 @@ void Inventory::removeItemAt(int index)
bool Inventory::contains(Item *item) const
{
- for (int i = 0; i < mSize; i++) {
- if (mItems[i] && mItems[i]->getId() == item->getId()) {
+ for (int i = 0; i < mSize; i++)
+ if (mItems[i] && mItems[i]->getId() == item->getId())
return true;
- }
- }
return false;
}
@@ -138,11 +138,9 @@ int Inventory::getNumberOfSlotsUsed() const
int Inventory::getLastUsedSlot() const
{
- for (int i = mSize - 1; i >= 0; i--) {
- if (SlotUsed()(mItems[i])) {
+ for (int i = mSize - 1; i >= 0; i--)
+ if (SlotUsed()(mItems[i]))
return i;
- }
- }
return -1;
}
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 7bfbc88e..3404b0e3 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -33,9 +33,8 @@ ItemShortcut::ItemShortcut():
mItemSelected(-1)
{
for (int i = 0; i < SHORTCUT_ITEMS; i++)
- {
mItems[i] = -1;
- }
+
load();
}
@@ -51,9 +50,7 @@ void ItemShortcut::load()
int itemId = (int) config.getValue("shortcut" + toString(i), -1);
if (itemId != -1)
- {
mItems[i] = itemId;
- }
}
}
@@ -73,13 +70,15 @@ void ItemShortcut::useItem(int index)
Item *item = player_node->getInventory()->findItem(mItems[index]);
if (item && item->getQuantity())
{
- if (item->isEquipment()) {
- if (item->isEquipped()) {
+ if (item->isEquipment())
+ {
+ if (item->isEquipped())
player_node->unequipItem(item);
- } else {
+ else
player_node->equipItem(item);
- }
- } else {
+ }
+ else
+ {
player_node->useItem(item);
}
}
diff --git a/src/joystick.cpp b/src/joystick.cpp
index 1233c37f..7e9a2285 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -25,8 +25,6 @@
#include "joystick.h"
#include "log.h"
-#include <cassert>
-
int Joystick::joystickCount = 0;
void Joystick::init()
diff --git a/src/joystick.h b/src/joystick.h
index e053fecc..4e5c3d23 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -30,14 +30,16 @@ class Joystick
/**
* Number of buttons we can handle.
*/
- enum {
+ enum
+ {
MAX_BUTTONS = 6
};
/**
* Directions, to be used as bitmask values.
*/
- enum {
+ enum
+ {
UP = 1,
DOWN = 2,
LEFT = 4,
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 32fc0216..413a8036 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -19,72 +19,83 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <guichan/sdl/sdlinput.hpp>
-
#include "configuration.h"
#include "keyboardconfig.h"
#include "log.h"
+#include "gui/sdlinput.h"
#include "gui/setup_keyboard.h"
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
+
struct KeyData
{
const char *configField;
int defaultValue;
- const char *caption;
+ std::string caption;
};
// keyData must be in same order as enum keyAction.
static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
- {"keyMoveUp", SDLK_UP, "Move Up"},
- {"keyMoveDown", SDLK_DOWN, "Move Down"},
- {"keyMoveLeft", SDLK_LEFT, "Move Left"},
- {"keyMoveRight", SDLK_RIGHT, "Move Right"},
- {"keyAttack", SDLK_LCTRL, "Attack"},
- {"keySmilie", SDLK_LALT, "Smilie"},
- {"keyTalk", SDLK_t, "Talk"},
- {"keyTarget", SDLK_LSHIFT, "Stop Attack"},
- {"keyTargetClosest", SDLK_a, "Target Closest"},
- {"keyTargetNPC", SDLK_n, "Target NPC"},
- {"keyTargetPlayer", SDLK_q, "Target Player"},
- {"keyPickup", SDLK_z, "Pickup"},
- {"keyHideWindows", SDLK_h, "Hide Windows"},
- {"keyBeingSit", SDLK_s, "Sit"},
- {"keyShortcut1", SDLK_1, "Item Shortcut 1"},
- {"keyShortcut2", SDLK_2, "Item Shortcut 2"},
- {"keyShortcut3", SDLK_3, "Item Shortcut 3"},
- {"keyShortcut4", SDLK_4, "Item Shortcut 4"},
- {"keyShortcut5", SDLK_5, "Item Shortcut 5"},
- {"keyShortcut6", SDLK_6, "Item Shortcut 6"},
- {"keyShortcut7", SDLK_7, "Item Shortcut 7"},
- {"keyShortcut8", SDLK_8, "Item Shortcut 8"},
- {"keyShortcut9", SDLK_9, "Item Shortcut 9"},
- {"keyShortcut10", SDLK_0, "Item Shortcut 10"},
- {"keyShortcut11", SDLK_MINUS, "Item Shortcut 11"},
- {"keyShortcut12", SDLK_EQUALS, "Item Shortcut 12"},
- {"keyWindowStatus", SDLK_F2, "Status Window"},
- {"keyWindowInventory", SDLK_F3, "Inventory Window"},
- {"keyWindowEquipment", SDLK_F4, "Equipment WIndow"},
- {"keyWindowSkill", SDLK_F5, "Skill Window"},
- {"keyWindowMinimap", SDLK_F6, "Minimap Window"},
- {"keyWindowChat", SDLK_F7, "Chat Window"},
- {"keyWindowShortcut", SDLK_F8, "Item Shortcut Window"},
- {"keyWindowSetup", SDLK_F9, "Setup Window"},
- {"keyWindowDebug", SDLK_F10, "Debug Window"},
- {"keyWindowEmote", SDLK_F11, "Emote Window"},
- {"keyWindowEmoteBar", SDLK_F12, "Emote Shortcut Window"},
- {"keyEmoteShortcut1", SDLK_1, "Emote Shortcut 1"},
- {"keyEmoteShortcut2", SDLK_2, "Emote Shortcut 2"},
- {"keyEmoteShortcut3", SDLK_3, "Emote Shortcut 3"},
- {"keyEmoteShortcut4", SDLK_4, "Emote Shortcut 4"},
- {"keyEmoteShortcut5", SDLK_5, "Emote Shortcut 5"},
- {"keyEmoteShortcut6", SDLK_6, "Emote Shortcut 6"},
- {"keyEmoteShortcut7", SDLK_7, "Emote Shortcut 7"},
- {"keyEmoteShortcut8", SDLK_8, "Emote Shortcut 8"},
- {"keyEmoteShortcut9", SDLK_9, "Emote Shortcut 9"},
- {"keyEmoteShortcut10", SDLK_0, "Emote Shortcut 10"},
- {"keyEmoteShortcut11", SDLK_MINUS, "Emote Shortcut 11"},
- {"keyEmoteShortcut12", SDLK_EQUALS, "Emote Shortcut 12"}
+ {"keyMoveUp", SDLK_UP, _("Move Up")},
+ {"keyMoveDown", SDLK_DOWN, _("Move Down")},
+ {"keyMoveLeft", SDLK_LEFT, _("Move Left")},
+ {"keyMoveRight", SDLK_RIGHT, _("Move Right")},
+ {"keyAttack", SDLK_LCTRL, _("Attack")},
+ {"keySmilie", SDLK_LALT, _("Smilie")},
+ {"keyTalk", SDLK_t, _("Talk")},
+ {"keyTarget", SDLK_LSHIFT, _("Stop Attack")},
+ {"keyTargetClosest", SDLK_a, _("Target Closest")},
+ {"keyTargetNPC", SDLK_n, _("Target NPC")},
+ {"keyTargetPlayer", SDLK_q, _("Target Player")},
+ {"keyPickup", SDLK_z, _("Pickup")},
+ {"keyHideWindows", SDLK_h, _("Hide Windows")},
+ {"keyBeingSit", SDLK_s, _("Sit")},
+ {"keyScreenshot", SDLK_p, _("Screenshot")},
+ {"keyTrade", SDLK_r, _("Enable/Disable Trading")},
+ {"keyPathfind", SDLK_f, _("Find Path to Mouse")},
+ {"keyShortcut1", SDLK_1, strprintf(_("Item Shortcut %d"), 1)},
+ {"keyShortcut2", SDLK_2, strprintf(_("Item Shortcut %d"), 2)},
+ {"keyShortcut3", SDLK_3, strprintf(_("Item Shortcut %d"), 3)},
+ {"keyShortcut4", SDLK_4, strprintf(_("Item Shortcut %d"), 4)},
+ {"keyShortcut5", SDLK_5, strprintf(_("Item Shortcut %d"), 5)},
+ {"keyShortcut6", SDLK_6, strprintf(_("Item Shortcut %d"), 6)},
+ {"keyShortcut7", SDLK_7, strprintf(_("Item Shortcut %d"), 7)},
+ {"keyShortcut8", SDLK_8, strprintf(_("Item Shortcut %d"), 8)},
+ {"keyShortcut9", SDLK_9, strprintf(_("Item Shortcut %d"), 9)},
+ {"keyShortcut10", SDLK_0, strprintf(_("Item Shortcut %d"), 10)},
+ {"keyShortcut11", SDLK_MINUS, strprintf(_("Item Shortcut %d"), 11)},
+ {"keyShortcut12", SDLK_EQUALS, strprintf(_("Item Shortcut %d"), 12)},
+ {"keyWindowHelp", SDLK_F1, _("Help Window")},
+ {"keyWindowStatus", SDLK_F2, _("Status Window")},
+ {"keyWindowInventory", SDLK_F3, _("Inventory Window")},
+ {"keyWindowEquipment", SDLK_F4, _("Equipment WIndow")},
+ {"keyWindowSkill", SDLK_F5, _("Skill Window")},
+ {"keyWindowMinimap", SDLK_F6, _("Minimap Window")},
+ {"keyWindowChat", SDLK_F7, _("Chat Window")},
+ {"keyWindowShortcut", SDLK_F8, _("Item Shortcut Window")},
+ {"keyWindowSetup", SDLK_F9, _("Setup Window")},
+ {"keyWindowDebug", SDLK_F10, _("Debug Window")},
+ {"keyWindowEmote", SDLK_F11, _("Emote Window")},
+ {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")},
+ {"keyEmoteShortcut1", SDLK_1, strprintf(_("Emote Shortcut %d"), 1)},
+ {"keyEmoteShortcut2", SDLK_2, strprintf(_("Emote Shortcut %d"), 2)},
+ {"keyEmoteShortcut3", SDLK_3, strprintf(_("Emote Shortcut %d"), 3)},
+ {"keyEmoteShortcut4", SDLK_4, strprintf(_("Emote Shortcut %d"), 4)},
+ {"keyEmoteShortcut5", SDLK_5, strprintf(_("Emote Shortcut %d"), 5)},
+ {"keyEmoteShortcut6", SDLK_6, strprintf(_("Emote Shortcut %d"), 6)},
+ {"keyEmoteShortcut7", SDLK_7, strprintf(_("Emote Shortcut %d"), 7)},
+ {"keyEmoteShortcut8", SDLK_8, strprintf(_("Emote Shortcut %d"), 8)},
+ {"keyEmoteShortcut9", SDLK_9, strprintf(_("Emote Shortcut %d"), 9)},
+ {"keyEmoteShortcut10", SDLK_0, strprintf(_("Emote Shortcut %d"), 10)},
+ {"keyEmoteShortcut11", SDLK_MINUS, strprintf(_("Emote Shortcut %d"), 11)},
+ {"keyEmoteShortcut12", SDLK_EQUALS, strprintf(_("Emote Shortcut %d"), 12)},
+ {"keyChat", SDLK_RETURN, _("Toggle Chat")},
+ {"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")},
+ {"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")},
+ {"keyOK", SDLK_RETURN, _("Select OK")},
+ {"keyQuit", SDLK_ESCAPE, _("Quit")}
};
void KeyboardConfig::init()
@@ -139,10 +150,11 @@ bool KeyboardConfig::hasConflicts()
for (j = i, j++; j < KEY_TOTAL; j++)
{
// Allow for item shortcut and emote keys to overlap, but no other keys
- if (!(((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) &&
- ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12)))
- && mKey[i].value == mKey[j].value
- )
+ if (!((((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) &&
+ ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12))) ||
+ ((i == KEY_TOGGLE_CHAT) && (j == KEY_OK))) &&
+ (mKey[i].value == mKey[j].value)
+ )
{
return true;
}
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index ba249b87..8949a48e 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -22,13 +22,9 @@
#ifndef KEYBOARDCONFIG_H
#define KEYBOARDCONFIG_H
+#include <SDL_types.h>
#include <string>
-#include <guichan/sdl/sdlinput.hpp>
-
-#include "gui/sdlinput.h"
-#include "gui/setup_keyboard.h"
-
/**
* Each key represents a key function. Such as 'Move up', 'Attack' etc.
*/
@@ -40,6 +36,8 @@ struct KeyFunction
int value; /** The actual value that is used. */
};
+class Setup_Keyboard;
+
class KeyboardConfig
{
public:
@@ -148,7 +146,8 @@ class KeyboardConfig
* The key assignment view gets arranged according to the order of
* these values.
*/
- enum KeyAction {
+ enum KeyAction
+ {
KEY_NO_VALUE = -1,
KEY_MOVE_UP,
KEY_MOVE_DOWN,
@@ -164,6 +163,9 @@ class KeyboardConfig
KEY_PICKUP,
KEY_HIDE_WINDOWS,
KEY_SIT,
+ KEY_SCREENSHOT,
+ KEY_TRADE,
+ KEY_PATHFIND,
KEY_SHORTCUT_1,
KEY_SHORTCUT_2,
KEY_SHORTCUT_3,
@@ -176,6 +178,7 @@ class KeyboardConfig
KEY_SHORTCUT_10,
KEY_SHORTCUT_11,
KEY_SHORTCUT_12,
+ KEY_WINDOW_HELP,
KEY_WINDOW_STATUS,
KEY_WINDOW_INVENTORY,
KEY_WINDOW_EQUIPMENT,
@@ -199,6 +202,11 @@ class KeyboardConfig
KEY_EMOTE_10,
KEY_EMOTE_11,
KEY_EMOTE_12,
+ KEY_TOGGLE_CHAT,
+ KEY_SCROLL_CHAT_UP,
+ KEY_SCROLL_CHAT_DOWN,
+ KEY_OK,
+ KEY_QUIT,
KEY_TOTAL
};
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 5eef30e1..b450c0ba 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -24,15 +24,17 @@
#include "equipment.h"
#include "floor_item.h"
#include "game.h"
+#include "graphics.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
-#include "main.h"
+#include "map.h"
#include "monster.h"
#include "particle.h"
+#include "simpleanimation.h"
#include "sound.h"
-#include "monster.h"
#include "statuseffect.h"
+#include "text.h"
#include "gui/gui.h"
#include "gui/ministatus.h"
@@ -40,6 +42,8 @@
#include "net/messageout.h"
#include "net/protocol.h"
+#include "resources/animation.h"
+#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -65,6 +69,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
ATK_BONUS(0), MATK_BONUS(0), DEF_BONUS(0), MDEF_BONUS(0), FLEE_BONUS(0),
mStatPoint(0), mSkillPoint(0),
mStatsPointsToAttribute(0),
+ mEquipment(new Equipment()),
mXp(0), mNetwork(0),
mTarget(NULL), mPickUpTarget(NULL),
mTrading(false), mGoingToTarget(false),
diff --git a/src/localplayer.h b/src/localplayer.h
index 55e12bf1..c128f4a4 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -22,10 +22,10 @@
#ifndef LOCALPLAYER_H
#define LOCALPLAYER_H
+#include <memory>
#include <vector>
#include "player.h"
-#include "simpleanimation.h"
// TODO move into some sane place...
#define MAX_SLOT 2
@@ -33,11 +33,14 @@
#define INVENTORY_SIZE 102
#define STORAGE_SIZE 301
+class Equipment;
class FloorItem;
class ImageSet;
class Inventory;
class Item;
+class Map;
class Network;
+class SimpleAnimation;
/**
* The local player character.
@@ -45,7 +48,8 @@ class Network;
class LocalPlayer : public Player
{
public:
- enum Attribute {
+ enum Attribute
+ {
STR = 0, AGI, VIT, INT, DEX, LUK
};
@@ -236,6 +240,8 @@ class LocalPlayer : public Player
/** Animated out of range target cursor. */
SimpleAnimation *mTargetCursorOutRange[NUM_TC];
+ const std::auto_ptr<Equipment> mEquipment;
+
protected:
virtual void
handleStatusEffect(StatusEffect *effect, int effectId);
diff --git a/src/log.cpp b/src/log.cpp
index e50edeb2..b0024f80 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstdarg>
-#include <cstdlib>
#include <iostream>
#include <sstream>
diff --git a/src/log.h b/src/log.h
index fcd48757..b06bdc89 100644
--- a/src/log.h
+++ b/src/log.h
@@ -22,7 +22,6 @@
#ifndef _LOG_H
#define _LOG_H
-#include <iosfwd>
#include <fstream>
class ChatWindow;
diff --git a/src/main.cpp b/src/main.cpp
index 2d77f18c..a9206505 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,8 +28,6 @@
#include <guichan/actionlistener.hpp>
-#include <guichan/sdl/sdlinput.hpp>
-
#include <guichan/widgets/label.hpp>
#include <libxml/parser.h>
@@ -54,6 +52,7 @@
#include "serverinfo.h"
#include "sound.h"
+#include "gui/button.h"
#include "gui/char_server.h"
#include "gui/char_select.h"
#include "gui/colour.h"
@@ -64,7 +63,6 @@
#include "gui/register.h"
#include "gui/sdlinput.h"
#include "gui/setup.h"
-#include "gui/textfield.h"
#include "gui/updatewindow.h"
#include "net/charserverhandler.h"
@@ -81,7 +79,6 @@
#include "resources/npcdb.h"
#include "resources/resourcemanager.h"
-#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/tostring.h"
diff --git a/src/map.cpp b/src/map.cpp
index 17c28180..b6ccad3b 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -68,6 +68,11 @@ TileAnimation::TileAnimation(Animation *ani):
{
}
+TileAnimation::~TileAnimation()
+{
+ delete mLastImage;
+}
+
void TileAnimation::update()
{
//update animation
diff --git a/src/map.h b/src/map.h
index bd4cb122..1423565f 100644
--- a/src/map.h
+++ b/src/map.h
@@ -27,9 +27,9 @@
#include "position.h"
#include "properties.h"
-
#include "simpleanimation.h"
+class Animation;
class AmbientOverlay;
class Graphics;
class Image;
@@ -72,6 +72,7 @@ class TileAnimation
{
public:
TileAnimation(Animation *ani);
+ ~TileAnimation();
void update();
void addAffectedTile(MapLayer *layer, int index)
{ mAffected.push_back(std::make_pair(layer, index)); }
diff --git a/src/monster.cpp b/src/monster.cpp
index 3b0c2029..3b1e4c80 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -28,8 +28,7 @@
#include "text.h"
#include "resources/monsterdb.h"
-
-#include "utils/tostring.h"
+#include "resources/monsterinfo.h"
static const int NAME_X_OFFSET = 16;
static const int NAME_Y_OFFSET = 16;
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index e13ef3a2..0db8fcbf 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -32,7 +32,6 @@
#include "../game.h"
#include "../localplayer.h"
#include "../log.h"
-#include "../main.h"
#include "../npc.h"
#include "../particle.h"
#include "../player_relations.h"
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 5292b6f9..67c79ec4 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -35,6 +35,8 @@
#include "../gui/chat.h"
#include "../gui/sell.h"
+#include "../utils/gettext.h"
+
extern BuyDialog *buyDialog;
extern Window *buySellDialog;
extern SellDialog *sellDialog;
@@ -104,27 +106,27 @@ void BuySellHandler::handleMessage(MessageIn *msg)
}
}
else {
- chatWindow->chatLog("Nothing to sell", BY_SERVER);
+ chatWindow->chatLog(_("Nothing to sell"), BY_SERVER);
current_npc = 0;
}
break;
case SMSG_NPC_BUY_RESPONSE:
if (msg->readInt8() == 0) {
- chatWindow->chatLog("Thanks for buying", BY_SERVER);
+ chatWindow->chatLog(_("Thanks for buying"), BY_SERVER);
} else {
// Reset player money since buy dialog already assumed purchase
// would go fine
buyDialog->setMoney(player_node->mGp);
- chatWindow->chatLog("Unable to buy", BY_SERVER);
+ chatWindow->chatLog(_("Unable to buy"), BY_SERVER);
}
break;
case SMSG_NPC_SELL_RESPONSE:
if (msg->readInt8() == 0) {
- chatWindow->chatLog("Thanks for selling", BY_SERVER);
+ chatWindow->chatLog(_("Thanks for selling"), BY_SERVER);
} else {
- chatWindow->chatLog("Unable to sell", BY_SERVER);
+ chatWindow->chatLog(_("Unable to sell"), BY_SERVER);
}
break;
}
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index b04fb94a..932cf705 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -21,10 +21,8 @@
#include "charserverhandler.h"
#include "messagein.h"
-#include "network.h"
#include "protocol.h"
-#include "../extensions.h"
#include "../game.h"
#include "../localplayer.h"
#include "../log.h"
@@ -34,10 +32,8 @@
#include "../gui/char_select.h"
#include "../gui/ok_dialog.h"
-/*
- * Yeah, this is a global. Get over it.
- */
-struct EXTENSIONS extensions;
+#include "../utils/gettext.h"
+#include "../utils/tostring.h"
CharServerHandler::CharServerHandler():
mCharCreateDialog(0)
@@ -58,9 +54,7 @@ CharServerHandler::CharServerHandler():
void CharServerHandler::handleMessage(MessageIn *msg)
{
- int slot;
- int flags;
- int code;
+ int slot, flags, code;
LocalPlayer *tempPlayer;
logger->log("CharServerHandler: Packet ID: %x, Length: %d",
@@ -73,22 +67,22 @@ void CharServerHandler::handleMessage(MessageIn *msg)
switch (code) {
case 0:
- errorMessage = "Authentication failed";
+ errorMessage = _("Authentication failed");
break;
case 1:
- errorMessage = "Map server(s) offline";
+ errorMessage = _("Map server(s) offline");
break;
case 2:
- errorMessage = "This account is already logged in";
+ errorMessage = _("This account is already logged in");
break;
case 3:
- errorMessage = "Speed hack detected";
+ errorMessage = _("Speed hack detected");
break;
case 8:
- errorMessage = "Duplicated login";
+ errorMessage = _("Duplicated login");
break;
default:
- errorMessage = "Unknown connection error";
+ errorMessage = _("Unknown connection error");
break;
}
state = ERROR_STATE;
@@ -96,11 +90,8 @@ void CharServerHandler::handleMessage(MessageIn *msg)
case 0x006b:
msg->skip(2); // Length word
- flags = msg->readInt32(); // Aethyra extensions flags
+ flags = msg->readInt32(); // Aethyra extensions flags
logger->log("Server flags are: %x", flags);
- extensions.aethyra_inventory = (bool)(flags & 0x01);
- extensions.aethyra_spells = (bool)(flags & 0x02);
- extensions.aethyra_misc = (bool)(flags & 0x04);
msg->skip(16); // Unused
// Derive number of characters from message length
@@ -112,7 +103,7 @@ void CharServerHandler::handleMessage(MessageIn *msg)
mCharInfo->select(slot);
mCharInfo->setEntry(tempPlayer);
logger->log("CharServer: Player: %s (%d)",
- tempPlayer->getName().c_str(), slot);
+ tempPlayer->getName().c_str(), slot);
}
state = CHAR_SELECT_STATE;
@@ -121,13 +112,13 @@ void CharServerHandler::handleMessage(MessageIn *msg)
case 0x006c:
switch (msg->readInt8()) {
case 0:
- errorMessage = "Access denied";
+ errorMessage = _("Access denied");
break;
case 1:
- errorMessage = "Cannot use this ID";
+ errorMessage = _("Cannot use this ID");
break;
default:
- errorMessage = "Unknown failure to select character";
+ errorMessage = _("Unknown failure to select character");
break;
}
mCharInfo->unlock();
@@ -149,8 +140,8 @@ void CharServerHandler::handleMessage(MessageIn *msg)
break;
case 0x006e:
- new OkDialog("Error", "Failed to create character. Most likely"
- " the name is already taken.");
+ new OkDialog(_("Error"), _("Failed to create character. Most likely"
+ " the name is already taken."));
if (mCharCreateDialog)
mCharCreateDialog->unlock();
@@ -161,12 +152,12 @@ void CharServerHandler::handleMessage(MessageIn *msg)
mCharInfo->setEntry(0);
mCharInfo->unlock();
n_character--;
- new OkDialog("Info", "Player deleted");
+ new OkDialog(_("Info"), _("Player deleted"));
break;
case 0x0070:
mCharInfo->unlock();
- new OkDialog("Error", "Failed to delete character.");
+ new OkDialog(_("Error"), _("Failed to delete character."));
break;
case 0x0071:
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index bf5a5a37..25877907 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -33,6 +33,7 @@
#include "../gui/chat.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
#include "../utils/trim.h"
@@ -72,10 +73,10 @@ void ChatHandler::handleMessage(MessageIn *msg)
//chatWindow->chatLog("Whisper sent", BY_SERVER);
break;
case 0x01:
- chatWindow->chatLog("Whisper could not be sent, user is offline", BY_SERVER);
+ chatWindow->chatLog(_("Whisper could not be sent, user is offline"), BY_SERVER);
break;
case 0x02:
- chatWindow->chatLog("Whisper could not be sent, ignored by user", BY_SERVER);
+ chatWindow->chatLog(_("Whisper could not be sent, ignored by user"), BY_SERVER);
break;
}
break;
diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp
index 973de0f6..9a3c396a 100644
--- a/src/net/equipmenthandler.cpp
+++ b/src/net/equipmenthandler.cpp
@@ -23,7 +23,6 @@
#include "messagein.h"
#include "protocol.h"
-#include "../beingmanager.h"
#include "../equipment.h"
#include "../inventory.h"
#include "../item.h"
@@ -32,6 +31,8 @@
#include "../gui/chat.h"
+#include "../utils/gettext.h"
+
EquipmentHandler::EquipmentHandler()
{
static const Uint16 _messages[] = {
@@ -97,7 +98,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
logger->log("Equipping: %i %i %i", index, equipPoint, type);
if (!type) {
- chatWindow->chatLog("Unable to equip.", BY_SERVER);
+ chatWindow->chatLog(_("Unable to equip."), BY_SERVER);
break;
}
@@ -135,7 +136,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
type = msg->readInt8();
if (!type) {
- chatWindow->chatLog("Unable to unequip.", BY_SERVER);
+ chatWindow->chatLog(_("Unable to unequip."), BY_SERVER);
break;
}
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index 3ce0899a..46f03e28 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -35,6 +35,8 @@
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
InventoryHandler::InventoryHandler()
@@ -139,13 +141,13 @@ void InventoryHandler::handleMessage(MessageIn *msg)
itemType = msg->readInt8();
if (msg->readInt8() > 0) {
- chatWindow->chatLog("Unable to pick up item", BY_SERVER);
+ chatWindow->chatLog(_("Unable to pick up item"), BY_SERVER);
} else {
const ItemInfo &itemInfo = ItemDB::get(itemId);
const std::string amountStr =
(amount > 1) ? toString(amount) : "a";
- chatWindow->chatLog("You picked up " + amountStr + " " +
- itemInfo.getName(), BY_SERVER);
+ chatWindow->chatLog(strprintf(_("You picked up %s %s"),
+ amountStr.c_str(), itemInfo.getName().c_str()), BY_SERVER);
if (Item *item = inventory->getItem(index)) {
item->setId(itemId);
@@ -182,7 +184,7 @@ void InventoryHandler::handleMessage(MessageIn *msg)
amount = msg->readInt16();
if (msg->readInt8() == 0) {
- chatWindow->chatLog("Failed to use item", BY_SERVER);
+ chatWindow->chatLog(_("Failed to use item"), BY_SERVER);
} else {
if (Item *item = inventory->getItem(index))
item->setQuantity(amount);
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index a262e361..41314d16 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -21,7 +21,6 @@
#include "loginhandler.h"
#include "messagein.h"
-#include "network.h"
#include "protocol.h"
#include "../log.h"
@@ -29,6 +28,10 @@
#include "../main.h"
#include "../serverinfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+#include "../utils/tostring.h"
+
extern SERVER_INFO **server_info;
LoginHandler::LoginHandler()
@@ -55,16 +58,16 @@ void LoginHandler::handleMessage(MessageIn *msg)
switch (code) {
case 0:
- errorMessage = "Authentication failed";
+ errorMessage = _("Authentication failed");
break;
case 1:
- errorMessage = "No servers available";
+ errorMessage = _("No servers available");
break;
case 2:
- errorMessage = "This account is already logged in";
+ errorMessage = _("This account is already logged in");
break;
default:
- errorMessage = "Unknown connection error";
+ errorMessage = _("Unknown connection error");
break;
}
state = ERROR_STATE;
@@ -119,30 +122,34 @@ void LoginHandler::handleMessage(MessageIn *msg)
switch (code) {
case 0:
- errorMessage = "Unregistered ID";
+ errorMessage = _("Unregistered ID");
break;
case 1:
- errorMessage = "Wrong password";
+ errorMessage = _("Wrong password");
break;
case 2:
- errorMessage = "Account expired";
+ errorMessage = _("Account expired");
break;
case 3:
- errorMessage = "Rejected from server";
+ errorMessage = _("Rejected from server");
break;
case 4:
- errorMessage = "You have been permanently banned from the game. Please contact the GM Team";
+ errorMessage = _("You have been permanently banned from the"
+ " game. Please contact the GM Team");
break;
case 6:
- errorMessage = "You have been temporarily banned from the game until "
- + msg->readString(20) + ".\n Please contact the GM team via the forums";
+ errorMessage = strprintf(_("You have been temporarily "
+ "banned from the game until %s.\n"
+ " Please contact the GM team via "
+ "the forums"),
+ msg->readString(20).c_str());
break;
case 9:
- errorMessage = "This user name is already taken";
+ errorMessage = _("This user name is already taken");
break;
default:
- errorMessage = "Unknown error";
+ errorMessage = _("Unknown error");
break;
}
state = ERROR_STATE;
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index c847b4c1..df86b634 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -25,7 +25,6 @@
#include <string>
#include "messagehandler.h"
-#include <string>
struct LoginData;
diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp
index b851117e..b5192bd7 100644
--- a/src/net/maploginhandler.cpp
+++ b/src/net/maploginhandler.cpp
@@ -27,6 +27,8 @@
#include "../log.h"
#include "../main.h"
+#include "../utils/gettext.h"
+
MapLoginHandler::MapLoginHandler()
{
static const Uint16 _messages[] = {
@@ -50,13 +52,13 @@ void MapLoginHandler::handleMessage(MessageIn *msg)
switch (code) {
case 0:
- errorMessage = "Authentication failed";
+ errorMessage = _("Authentication failed");
break;
case 2:
- errorMessage = "This account is already logged in";
+ errorMessage = _("This account is already logged in");
break;
default:
- errorMessage = "Unknown connection error";
+ errorMessage = _("Unknown connection error");
break;
}
state = ERROR_STATE;
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 941995c9..059da779 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -26,6 +26,7 @@
#include "network.h"
#include "../log.h"
+#include "../utils/tostring.h"
/** Warning: buffers and other variables are shared,
so there can be only one connection active at a time */
@@ -418,19 +419,6 @@ void Network::receive()
SDLNet_FreeSocketSet(set);
}
-char *iptostring(int address)
-{
- static char asciiIP[16];
-
- sprintf(asciiIP, "%i.%i.%i.%i",
- (unsigned char)(address),
- (unsigned char)(address >> 8),
- (unsigned char)(address >> 16),
- (unsigned char)(address >> 24));
-
- return asciiIP;
-}
-
void Network::setError(const std::string& error)
{
logger->log("Network error: %s", error.c_str());
diff --git a/src/net/network.h b/src/net/network.h
index c035f55c..02fe7538 100644
--- a/src/net/network.h
+++ b/src/net/network.h
@@ -115,7 +115,4 @@ class Network
MessageHandlers mMessageHandlers;
};
-/** Convert an address from int format to string */
-char *iptostring(int address);
-
#endif
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index 20f2b7dc..ea03537f 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -92,6 +92,7 @@ void NPCHandler::handleMessage(MessageIn *msg)
current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcIntegerDialog->setRange(0, 2147483647);
npcIntegerDialog->setVisible(true);
+ npcIntegerDialog->requestFocus();
break;
case SMSG_NPC_STR_INPUT:
@@ -100,6 +101,7 @@ void NPCHandler::handleMessage(MessageIn *msg)
current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcStringDialog->setValue("");
npcStringDialog->setVisible(true);
+ npcStringDialog->requestFocus();
break;
}
}
diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp
index 8f0b3a00..03aca66d 100644
--- a/src/net/partyhandler.cpp
+++ b/src/net/partyhandler.cpp
@@ -29,7 +29,6 @@
#include "../gui/confirm_dialog.h"
#include "../beingmanager.h"
-#include "../game.h"
#include "../party.h"
PartyHandler::PartyHandler(Party *party) : mParty(party)
diff --git a/src/npc.cpp b/src/npc.cpp
index 19be4c4d..dfbc7d16 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -20,7 +20,6 @@
*/
#include "animatedsprite.h"
-#include "graphics.h"
#include "localplayer.h"
#include "npc.h"
#include "particle.h"
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index d3278c1a..e7e7b204 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -19,14 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cstring>
#include <SDL.h>
-#include <guichan/exception.hpp>
-#include <guichan/image.hpp>
-
#include "log.h"
-#include "main.h"
#include "openglgraphics.h"
#include "resources/image.h"
diff --git a/src/particle.cpp b/src/particle.cpp
index a3026994..45cbb4c9 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -22,6 +22,8 @@
#include <algorithm>
#include <cmath>
+#include <guichan/color.hpp>
+
#include "animationparticle.h"
#include "configuration.h"
#include "imageparticle.h"
diff --git a/src/particle.h b/src/particle.h
index 653e848f..e79a46dd 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -25,8 +25,6 @@
#include <list>
#include <string>
-#include <guichan/color.hpp>
-
#include "guichanfwd.h"
#include "sprite.h"
#include "vector.h"
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 6300350d..63f89079 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -21,6 +21,7 @@
#include <cassert>
+#include "particle.h"
#include "particlecontainer.h"
@@ -108,9 +109,6 @@ void ParticleList::moveTo(float x, float y)
}
}
-
-
-
// -- particle vector ----------------------------------------
ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent):
diff --git a/src/particlecontainer.h b/src/particlecontainer.h
index 27e02f8b..26539dd7 100644
--- a/src/particlecontainer.h
+++ b/src/particlecontainer.h
@@ -25,8 +25,7 @@
#include <list>
#include <vector>
-#include "particle.h"
-
+class Particle;
/**
* Set of particle effects. May be stacked with other ParticleContainers. All
@@ -65,8 +64,6 @@ protected:
ParticleContainer *mNext; /**< Contained container, if any */
};
-
-
/**
* Linked list of particle effects.
*/
@@ -94,7 +91,6 @@ protected:
std::list<Particle *> mElements; /**< Contained particle effects */
};
-
/**
* Particle container with indexing facilities
*/
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index ca9f7bf5..fa5dcde4 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -19,19 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <cmath>
+
#include "animationparticle.h"
#include "imageparticle.h"
#include "log.h"
#include "particle.h"
#include "particleemitter.h"
-#include "resources/animation.h"
#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
-#include <cmath>
-
#define SIN45 0.707106781f
#define DEG_RAD_FACTOR 0.017453293f
diff --git a/src/particleemitter.h b/src/particleemitter.h
index cc77f215..67b35ae2 100644
--- a/src/particleemitter.h
+++ b/src/particleemitter.h
@@ -26,10 +26,10 @@
#include "utils/xml.h"
-#include "resources/animation.h"
-
#include "particleemitterprop.h"
+#include "resources/animation.h"
+
class Image;
class Map;
class Particle;
diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h
index fde78f8f..e68ac222 100644
--- a/src/particleemitterprop.h
+++ b/src/particleemitterprop.h
@@ -20,7 +20,6 @@
*/
#include <cmath>
-#include <cstdlib>
/**
* Returns a random numeric value that is larger than or equal min and smaller
diff --git a/src/party.cpp b/src/party.cpp
index bf9d3a06..fe575a37 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -19,8 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "beingmanager.h"
-#include "game.h"
+#include "being.h"
#include "localplayer.h"
#include "party.h"
@@ -168,11 +167,6 @@ void Party::receiveChat(Being *being, const std::string &msg)
mChat->chatLog(being->getName() + " : " + msg, BY_PARTY);
}
-void Party::help()
-{
- mChat->chatLog(_("/party <command> <params>: Party commands."), BY_SERVER);
-}
-
void Party::help(const std::string &msg)
{
if (msg == "")
diff --git a/src/party.h b/src/party.h
index 846b9d11..98252c37 100644
--- a/src/party.h
+++ b/src/party.h
@@ -47,7 +47,6 @@ class Party
void leftResponse(const std::string &nick);
void receiveChat(Being *being, const std::string &msg);
- void help();
void help(const std::string &msg);
private:
diff --git a/src/player.cpp b/src/player.cpp
index ca8c9f14..610dfeb1 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -19,16 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iostream>
-
#include "animatedsprite.h"
#include "game.h"
-#include "graphics.h"
-#include "log.h"
#include "player.h"
+#include "text.h"
+#include "resources/colordb.h"
#include "resources/itemdb.h"
-#include "resources/iteminfo.h"
#include "utils/strprintf.h"
diff --git a/src/player.h b/src/player.h
index 5fe9963a..f9911bb8 100644
--- a/src/player.h
+++ b/src/player.h
@@ -23,8 +23,8 @@
#define PLAYER_H
#include "being.h"
-#include "text.h"
+class FlashText;
class Graphics;
class Map;
diff --git a/src/player_relations.cpp b/src/player_relations.cpp
index 057eea94..aa83115c 100644
--- a/src/player_relations.cpp
+++ b/src/player_relations.cpp
@@ -21,12 +21,13 @@
#include <algorithm>
+#include "being.h"
#include "beingmanager.h"
+#include "configuration.h"
#include "graphics.h"
+#include "player.h"
#include "player_relations.h"
-#include "gui/gui.h"
-
#define PLAYER_IGNORE_STRATEGY_NOP "nop"
#define PLAYER_IGNORE_STRATEGY_EMOTE0 "emote0"
#define DEFAULT_IGNORE_STRATEGY PLAYER_IGNORE_STRATEGY_EMOTE0
@@ -304,7 +305,7 @@ public:
virtual void ignore(Player *player, unsigned int flags)
{
- player->setSpeech("...", 5);
+ player->setSpeech("...", 500);
}
};
diff --git a/src/player_relations.h b/src/player_relations.h
index 0f8bb4e3..1eb4ede6 100644
--- a/src/player_relations.h
+++ b/src/player_relations.h
@@ -27,9 +27,8 @@
#include <string>
#include <vector>
-#include "being.h"
-#include "configuration.h"
-#include "player.h"
+class Being;
+class Player;
struct PlayerRelation
{
diff --git a/src/recorder.cpp b/src/recorder.cpp
deleted file mode 100644
index 9f166fef..00000000
--- a/src/recorder.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * A chat recorder
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <physfs.h>
-
-#include "recorder.h"
-
-#include "gui/buttonbox.h"
-#include "gui/chat.h"
-
-#include "utils/trim.h"
-
-Recorder::Recorder(ChatWindow *chat) : mChat(chat)
-{
- mButtonBox = new ButtonBox("Recording...", "Stop recording", this);
- mButtonBox->setY(20);
-}
-
-Recorder::~Recorder()
-{
- delete mButtonBox;
-}
-
-void Recorder::record(const std::string &msg)
-{
- if (mStream.is_open())
- {
- mStream << msg << std::endl;
- }
-}
-
-void Recorder::respond(const std::string &msg)
-{
- std::string msgCopy = msg;
- trim(msgCopy);
- if (msgCopy == "")
- {
- if (mStream.is_open())
- {
- mStream.close();
- mButtonBox->setVisible(false);
- /*
- * Message should go after mStream is closed so that it isn't
- * recorded.
- */
- mChat->chatLog("Finishing recording.", BY_SERVER);
- }
- else
- {
- mChat->chatLog("Not currently recording.", BY_SERVER);
- }
- return;
- }
- if (mStream.is_open())
- {
- mChat->chatLog("Already recording.", BY_SERVER);
- }
- else
- {
- /*
- * Message should go before mStream is opened so that it isn't
- * recorded.
- */
- mChat->chatLog("Starting to record...", BY_SERVER);
- std::string file = std::string(PHYSFS_getUserDir()) + "/.tmw/" + msgCopy;
-
- mStream.open(file.c_str(), std::ios_base::trunc);
- if (mStream.is_open())
- {
- mButtonBox->setVisible(true);
- }
- else
- {
- mChat->chatLog("Failed to start recording.", BY_SERVER);
- }
- }
-}
-
-void Recorder::help() const
-{
- mChat->chatLog("/record <filename>: Start recording the chat.", BY_SERVER);
-}
-
-void Recorder::help(const std::string &args) const
-{
- mChat->chatLog("Command: /record <filename>", BY_SERVER);
- mChat->chatLog("This command starts recording the chat log to the file "
- "<filename>.", BY_SERVER);
- mChat->chatLog("Command: /record", BY_SERVER);
- mChat->chatLog("This command finishes a recording session.", BY_SERVER);
-}
-
-void Recorder::buttonBoxRespond()
-{
- respond("");
-}
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 8d7156a9..54c319de 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "animation.h"
#include "../utils/dtor.h"
diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h
index d769b2b8..f0758c25 100644
--- a/src/resources/buddylist.h
+++ b/src/resources/buddylist.h
@@ -27,7 +27,8 @@
#include <guichan/listmodel.hpp>
-class BuddyList : public gcn::ListModel {
+class BuddyList : public gcn::ListModel
+{
public:
/**
* Constructor
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 34c48496..61ea4bc0 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -19,14 +19,12 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
#include <libxml/tree.h>
#include "colordb.h"
#include "../log.h"
-#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/xml.h"
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 1b34a403..22bd2411 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
#include <sstream>
#include "dye.h"
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index bbc6b634..ac41b59c 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -20,11 +20,9 @@
*/
#include "emotedb.h"
-#include "resourcemanager.h"
#include "../log.h"
-#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/xml.h"
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index c3310849..7a7e6ac8 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -167,7 +167,8 @@ Image *Image::load(SDL_Surface *tmpImage)
tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
- if (!tmpImage) {
+ if (!tmpImage)
+ {
logger->log("Error, image convert failed: out of memory");
return NULL;
}
@@ -178,9 +179,8 @@ Image *Image::load(SDL_Surface *tmpImage)
glGenTextures(1, &texture);
glBindTexture(mTextureType, texture);
- if (SDL_MUSTLOCK(tmpImage)) {
+ if (SDL_MUSTLOCK(tmpImage))
SDL_LockSurface(tmpImage);
- }
glTexImage2D(
mTextureType, 0, 4,
@@ -255,14 +255,13 @@ Image *Image::load(SDL_Surface *tmpImage)
SDL_Surface *image;
// Convert the surface to the current display format
- if (hasAlpha) {
+ if (hasAlpha)
image = SDL_DisplayFormatAlpha(tmpImage);
- }
- else {
+ else
image = SDL_DisplayFormat(tmpImage);
- }
- if (!image) {
+ if (!image)
+ {
logger->log("Error: Image convert failed.");
return NULL;
}
@@ -274,14 +273,16 @@ void Image::unload()
{
mLoaded = false;
- if (mImage) {
+ if (mImage)
+ {
// Free the image surface.
SDL_FreeSurface(mImage);
mImage = NULL;
}
#ifdef USE_OPENGL
- if (mGLImage) {
+ if (mGLImage)
+ {
glDeleteTextures(1, &mGLImage);
mGLImage = 0;
}
@@ -292,10 +293,9 @@ Image *Image::getSubImage(int x, int y, int width, int height)
{
// Create a new clipped sub-image
#ifdef USE_OPENGL
- if (mUseOpenGL) {
+ if (mUseOpenGL)
return new SubImage(this, mGLImage, x, y, width, height,
mTexWidth, mTexHeight);
- }
#endif
return new SubImage(this, mImage, x, y, width, height);
@@ -303,13 +303,13 @@ Image *Image::getSubImage(int x, int y, int width, int height)
void Image::setAlpha(float a)
{
- if (mAlpha == a) {
+ if (mAlpha == a)
return;
- }
mAlpha = a;
- if (mImage) {
+ if (mImage)
+ {
// Set the alpha value this image is drawn at
SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha));
}
@@ -321,14 +321,12 @@ float Image::getAlpha()
}
#ifdef USE_OPENGL
-void
-Image::setLoadAsOpenGL(bool useOpenGL)
+void Image::setLoadAsOpenGL(bool useOpenGL)
{
Image::mUseOpenGL = useOpenGL;
}
-int
-Image::powerOfTwo(int input)
+int Image::powerOfTwo(int input)
{
int value;
if (mTextureType == GL_TEXTURE_2D)
@@ -353,7 +351,8 @@ Image::powerOfTwo(int input)
SubImage::SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height):
- Image(image), mParent(parent)
+ Image(image),
+ mParent(parent)
{
mParent->incRef();
@@ -368,7 +367,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
SubImage::SubImage(Image *parent, GLuint image,
int x, int y, int width, int height,
int texWidth, int texHeight):
- Image(image, width, height, texWidth, texHeight), mParent(parent)
+ Image(image, width, height, texWidth, texHeight),
+ mParent(parent)
{
mParent->incRef();
@@ -394,3 +394,4 @@ Image *SubImage::getSubImage(int x, int y, int w, int h)
{
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
}
+
diff --git a/src/resources/image.h b/src/resources/image.h
index a4048803..9af10fda 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -40,6 +40,8 @@
#include "resource.h"
class Dye;
+class SDL_Rect;
+class SDL_Surface;
/**
* Defines a class for loading and storing images.
@@ -92,6 +94,12 @@ class Image : public Resource
virtual void unload();
/**
+ * Returns the image.
+ */
+ virtual const Image* getImage() const
+ { return this; }
+
+ /**
* Returns the width of the image.
*/
virtual int getWidth() const
@@ -114,7 +122,7 @@ class Image : public Resource
/**
* Sets the alpha value of this image.
*/
- void setAlpha(float alpha);
+ virtual void setAlpha(float alpha);
/**
* Returns the alpha value of this image.
@@ -181,6 +189,12 @@ class SubImage : public Image
~SubImage();
/**
+ * Returns the image.
+ */
+ virtual const Image* getImage() const
+ { return mParent; }
+
+ /**
* Creates a new image with the desired clipping rectangle.
*
* @return <code>NULL</code> if creation failed and a valid
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index 7895d33d..40d62797 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -20,7 +20,6 @@
*/
#include <cassert>
-#include <string>
#include <guichan/color.hpp>
#include <guichan/sdl/sdlpixel.hpp>
diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h
index a9133846..039d3afb 100644
--- a/src/resources/imagewriter.h
+++ b/src/resources/imagewriter.h
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iosfwd>
-
struct SDL_Surface;
class ImageWriter
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 773febd7..9976f0d4 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -24,13 +24,12 @@
#include <libxml/tree.h>
#include "itemdb.h"
-#include "iteminfo.h"
-#include "resourcemanager.h"
#include "../log.h"
#include "../utils/dtor.h"
#include "../utils/gettext.h"
+#include "../utils/trim.h"
#include "../utils/xml.h"
namespace
@@ -83,7 +82,7 @@ void ItemDB::load()
logger->log(_("ItemDB: Redefinition of item ID %d"), id);
}
- int type = XML::getProperty(node, "type", 0);
+ std::string type = XML::getProperty(node, "type", "other");
int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
@@ -125,14 +124,7 @@ void ItemDB::load()
if (itr == mNamedItemInfos.end())
{
std::string temp = name;
- while (temp[0] == ' ')
- {
- temp = temp.substr(1, temp.size());
- }
- while (temp[temp.size()] == ' ')
- {
- temp = temp.substr(0, temp.size() - 1);
- }
+ trim(temp);
for (unsigned int i = 0; i < temp.size(); i++)
{
@@ -158,7 +150,7 @@ void ItemDB::load()
CHECK_PARAM(description, "");
// CHECK_PARAM(effect, "");
// CHECK_PARAM(type, 0);
- CHECK_PARAM(weight, 0);
+ // CHECK_PARAM(weight, 0);
// CHECK_PARAM(slot, 0);
#undef CHECK_PARAM
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index e7c23ca2..08a7acd0 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -26,6 +26,8 @@
#include "iteminfo.h"
+class ItemInfo;
+
/**
* The namespace that holds the item information.
*/
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 86725ca2..c03dec28 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -47,7 +47,7 @@ class ItemInfo
* Constructor.
*/
ItemInfo():
- mType(0),
+ mType(""),
mWeight(0),
mView(0),
mAttackType(ACTION_DEFAULT)
@@ -81,14 +81,12 @@ class ItemInfo
void setEffect(const std::string &effect)
{ mEffect = effect; }
- const std::string&
- getEffect() const { return mEffect; }
+ const std::string& getEffect() const { return mEffect; }
- void setType(short type)
+ void setType(const std::string& type)
{ mType = type; }
- short getType() const
- { return mType; }
+ const std::string& getType() const { return mType; }
void setWeight(short weight)
{ mWeight = weight; }
@@ -118,7 +116,7 @@ class ItemInfo
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
- char mType; /**< Item type. */
+ std::string mType; /**< Item type. */
short mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index ddf48df0..3270c665 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -23,6 +23,7 @@
#include <iostream>
#include <zlib.h>
+#include "animation.h"
#include "image.h"
#include "mapreader.h"
#include "resourcemanager.h"
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index ef945c3f..0ed553c3 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -22,8 +22,6 @@
#ifndef MAPREADER_H
#define MAPREADER_H
-#include <iosfwd>
-
#include <libxml/tree.h>
class Map;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index c7926260..c7824a5d 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -20,7 +20,7 @@
*/
#include "monsterdb.h"
-#include "resourcemanager.h"
+#include "monsterinfo.h"
#include "../log.h"
diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h
index 6fbde55f..0a218661 100644
--- a/src/resources/monsterdb.h
+++ b/src/resources/monsterdb.h
@@ -24,7 +24,7 @@
#include <map>
-#include "monsterinfo.h"
+class MonsterInfo;
/**
* Monster information database.
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 88572481..73c3939d 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -20,11 +20,9 @@
*/
#include "npcdb.h"
-#include "resourcemanager.h"
#include "../log.h"
-#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/xml.h"
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 303b82c8..7c5f989e 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -62,8 +62,7 @@ class Resource
/**
* Destructor.
*/
- virtual
- ~Resource();
+ virtual ~Resource();
private:
std::string mIdPath; /**< Path identifying this resource. */
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index 05ec9e54..116df930 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -35,8 +35,7 @@ class SoundEffect : public Resource
/**
* Destructor.
*/
- virtual
- ~SoundEffect();
+ virtual ~SoundEffect();
/**
* Loads a sample from a buffer in memory.
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 17d9ce60..d90602a6 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -19,14 +19,22 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "graphics.h"
#include "log.h"
#include "simpleanimation.h"
+#include "resources/animation.h"
#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+SimpleAnimation::SimpleAnimation(Animation *animation):
+ mAnimation(animation),
+ mAnimationTime(0),
+ mAnimationPhase(0),
+ mCurrentFrame(mAnimation->getFrame(0))
+{
+}
+
SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode):
mAnimationTime(0),
mAnimationPhase(0)
diff --git a/src/simpleanimation.h b/src/simpleanimation.h
index a7178145..16ac2906 100644
--- a/src/simpleanimation.h
+++ b/src/simpleanimation.h
@@ -22,12 +22,12 @@
#ifndef SIMPLEANIMAION_H
#define SIMPLEANIMAION_H
-#include "resources/animation.h"
-
#include "utils/xml.h"
+class Animation;
class Frame;
class Graphics;
+class Image;
/**
* This class is a leightweight alternative to the AnimatedSprite class.
@@ -39,12 +39,7 @@ class SimpleAnimation
/**
* Creates a simple animation with an already created animation.
*/
- SimpleAnimation(Animation *animation):
- mAnimation(animation),
- mAnimationTime(0),
- mAnimationPhase(0),
- mCurrentFrame(mAnimation->getFrame(0))
- {};
+ SimpleAnimation(Animation *animation);
/**
* Creates a simple animation that creates its animation from XML Data.
diff --git a/src/text.cpp b/src/text.cpp
index b8e56338..e4f1d409 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -22,8 +22,6 @@
#include "text.h"
-#include <cstring>
-
#include <guichan/font.hpp>
#include "configuration.h"
@@ -114,7 +112,7 @@ void Text::adviseXY(int x, int y)
textManager->moveText(this, x - mXOffset, y);
}
-void Text::draw(Graphics *graphics, int xOff, int yOff)
+void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
graphics->setFont(boldFont);
@@ -176,7 +174,7 @@ FlashText::FlashText(const std::string &text, int x, int y,
{
}
-void FlashText::draw(Graphics *graphics, int xOff, int yOff)
+void FlashText::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
if (mTime)
{
diff --git a/src/text.h b/src/text.h
index 9895ab30..6dcfd90a 100644
--- a/src/text.h
+++ b/src/text.h
@@ -23,11 +23,11 @@
#ifndef TEXT_H
#define TEXT_H
+#include <guichan/color.hpp>
+
#include "graphics.h"
#include "guichanfwd.h"
-#include <list>
-
class TextManager;
class Text
@@ -55,7 +55,7 @@ class Text
/**
* Draws the text.
*/
- virtual void draw(Graphics *graphics, int xOff, int yOff);
+ virtual void draw(gcn::Graphics *graphics, int xOff, int yOff);
private:
int mX; /**< Actual x-value of left of text written. */
@@ -93,7 +93,7 @@ class FlashText : public Text
/**
* Draws the text.
*/
- virtual void draw(Graphics *graphics, int xOff, int yOff);
+ virtual void draw(gcn::Graphics *graphics, int xOff, int yOff);
private:
int mTime; /**< Time left for flashing */
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index f792d463..6bc8f8b6 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -61,7 +61,7 @@ TextManager::~TextManager()
{
}
-void TextManager::draw(Graphics *graphics, int xOff, int yOff)
+void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end();
bPtr != ePtr; ++bPtr)
@@ -91,21 +91,13 @@ void TextManager::place(const Text *textObj, const Text *omit,
int from = (*ptr)->mY - occupiedTop;
int to = from + (*ptr)->mHeight - 1;
if (to < 0 || from >= TEST) // out of range considered
- {
continue;
- }
if (from < 0)
- {
from = 0;
- }
if (to >= TEST)
- {
to = TEST - 1;
- }
for (int i = from; i <= to; ++i)
- {
occupied[i] = true;
- }
}
}
bool ok = true;
@@ -113,10 +105,10 @@ void TextManager::place(const Text *textObj, const Text *omit,
{
ok = ok && !occupied[i];
}
+
if (ok)
- {
return;
- }
+
// Have to move it up or down, so find nearest spaces either side
int consec = 0;
int upSlot = -1; // means not found
diff --git a/src/textmanager.h b/src/textmanager.h
index 3e851c3f..ee8e1209 100644
--- a/src/textmanager.h
+++ b/src/textmanager.h
@@ -24,8 +24,9 @@
#include <list>
+#include "guichanfwd.h"
+
class Text;
-class Graphics;
class TextManager
{
@@ -58,7 +59,7 @@ class TextManager
/**
* Draw the text
*/
- void draw(Graphics *graphics, int xOff, int yOff);
+ void draw(gcn::Graphics *graphics, int xOff, int yOff);
private:
/**
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index 7e329b4e..f38c32ce 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -19,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/color.hpp>
+
#include "graphics.h"
#include "textparticle.h"
diff --git a/src/textparticle.h b/src/textparticle.h
index bc7cd88c..cdf99d8f 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -22,8 +22,6 @@
#ifndef _TEXTPARTICLE_H
#define _TEXTPARTICLE_H
-#include <guichan/color.hpp>
-
#include "guichanfwd.h"
#include "particle.h"
diff --git a/src/utils/tostring.h b/src/utils/tostring.h
index 5ac1d3aa..62eb44e4 100644
--- a/src/utils/tostring.h
+++ b/src/utils/tostring.h
@@ -32,4 +32,19 @@ std::string toString(const T &arg)
return ss.str();
}
+// TODO: Is there a good way to suppress warnings from classes which don't use
+// this function?
+inline char *iptostring(int address)
+{
+ static char asciiIP[16];
+
+ sprintf(asciiIP, "%i.%i.%i.%i",
+ (unsigned char)(address),
+ (unsigned char)(address >> 8),
+ (unsigned char)(address >> 16),
+ (unsigned char)(address >> 24));
+
+ return asciiIP;
+}
+
#endif