summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-03 17:00:07 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-03 17:00:07 +0000
commit061b9e817ffe73acca163510b276e6ca7dd8f6c2 (patch)
treec1488381a9a62520f94cdb353bd5bd12ebc1b699 /src
parent092bf185fc056338bcde2749a304e576edf342fd (diff)
downloadmana-client-061b9e817ffe73acca163510b276e6ca7dd8f6c2.tar.gz
mana-client-061b9e817ffe73acca163510b276e6ca7dd8f6c2.tar.bz2
mana-client-061b9e817ffe73acca163510b276e6ca7dd8f6c2.tar.xz
mana-client-061b9e817ffe73acca163510b276e6ca7dd8f6c2.zip
Made NPC names visible. Windows are now invisible by default.
Diffstat (limited to 'src')
-rw-r--r--src/beingmanager.cpp13
-rw-r--r--src/engine.cpp26
-rw-r--r--src/game.cpp40
-rw-r--r--src/gui/char_select.cpp4
-rw-r--r--src/gui/char_server.cpp3
-rw-r--r--src/gui/confirm_dialog.cpp3
-rw-r--r--src/gui/confirm_dialog.h2
-rw-r--r--src/gui/login.cpp1
-rw-r--r--src/gui/ok_dialog.cpp3
-rw-r--r--src/gui/ok_dialog.h2
-rw-r--r--src/gui/register.cpp4
-rw-r--r--src/gui/window.cpp3
-rw-r--r--src/gui/window.h3
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/net/beinghandler.cpp23
-rw-r--r--src/net/npchandler.cpp8
-rw-r--r--src/net/playerhandler.cpp20
-rw-r--r--src/npc.cpp14
-rw-r--r--src/npc.h7
-rw-r--r--src/player.cpp3
20 files changed, 105 insertions, 81 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index eea8c419..d3ac88f2 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -72,12 +72,7 @@ Being* BeingManager::createBeing(Uint32 id, Uint16 job)
Being *being;
if (job < 10)
- {
being = new Player(id, job, mMap);
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x0094);
- outMsg.writeInt32(id);//readLong(2));
- }
else if (job >= 100 & job < 200)
being = new NPC(id, job, mMap, mNetwork);
else if (job >= 1000 && job < 1200)
@@ -85,6 +80,14 @@ Being* BeingManager::createBeing(Uint32 id, Uint16 job)
else
being = new Being(id, job, mMap);
+ // Player or NPC
+ if (job < 200)
+ {
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(0x0094);
+ outMsg.writeInt32(id);//readLong(2));
+ }
+
mBeings.push_back(being);
return being;
diff --git a/src/engine.cpp b/src/engine.cpp
index a6177b30..2b2f168a 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -163,7 +163,7 @@ void Engine::draw(Graphics *graphics)
lastTick = tick_time;
}
- // calculate viewpoint
+ // Calculate viewpoint
int midTileX = graphics->getWidth() / 32 / 2;
int midTileY = graphics->getHeight() / 32 / 2;
@@ -174,9 +174,9 @@ void Engine::draw(Graphics *graphics)
scrollRadius = (int)config.getValue("ScrollRadius", 32);
if (scrollLaziness < 1)
- scrollLaziness = 1; //avoids division by zero
+ scrollLaziness = 1; // Avoids division by zero
- //apply lazy scrolling
+ // Apply lazy scrolling
while (lastTick < tick_time)
{
if (player_x > view_x + scrollRadius)
@@ -198,7 +198,7 @@ void Engine::draw(Graphics *graphics)
lastTick++;
}
- //auto center when player is off screen
+ // Auto center when player is off screen
if ( player_x - view_x > graphics->getWidth() / 2
|| view_x - player_x > graphics->getWidth() / 2
|| view_y - player_y > graphics->getHeight() / 2
@@ -224,19 +224,19 @@ void Engine::draw(Graphics *graphics)
}
}
- camera_x = int(view_x + 16) / 32;
- camera_y = int(view_y + 16) / 32;
+ camera_x = (int) (view_x + 16) / 32;
+ camera_y = (int) (view_y + 16) / 32;
// Draw tiles and sprites
if (mCurrentMap != NULL)
{
- mCurrentMap->draw(graphics, (int)view_x, (int)view_y, 0);
- mCurrentMap->draw(graphics, (int)view_x, (int)view_y, 1);
- mCurrentMap->draw(graphics, (int)view_x, (int)view_y, 2);
+ mCurrentMap->draw(graphics, (int) view_x, (int) view_y, 0);
+ mCurrentMap->draw(graphics, (int) view_x, (int) view_y, 1);
+ mCurrentMap->draw(graphics, (int) view_x, (int) view_y, 2);
mCurrentMap->drawOverlay( graphics,
view_x,
view_y,
- (int)config.getValue("OverlayDetail", 2)
+ (int) config.getValue("OverlayDetail", 2)
);
}
@@ -272,9 +272,9 @@ void Engine::draw(Graphics *graphics)
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
{
- (*i)->drawSpeech(graphics, -(int)view_x, -(int)view_y);
- (*i)->drawName(graphics, -(int)view_x, -(int)view_y);
- (*i)->drawEmotion(graphics, -(int)view_x, -(int)view_y);
+ (*i)->drawSpeech(graphics, -(int) view_x, -(int) view_y);
+ (*i)->drawName(graphics, -(int) view_x, -(int) view_y);
+ (*i)->drawEmotion(graphics, -(int) view_x, -(int) view_y);
}
// Draw target marker if needed
diff --git a/src/game.cpp b/src/game.cpp
index 6bc37365..a241e8bb 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -43,7 +43,7 @@
#include "gui/buy.h"
#include "gui/buysell.h"
-#include "gui/chargedialog.h"
+//#include "gui/chargedialog.h"
#include "gui/chat.h"
#include "gui/confirm_dialog.h"
#include "gui/equipmentwindow.h"
@@ -107,7 +107,7 @@ SkillDialog *skillDialog;
Setup* setupWindow;
Minimap *minimap;
EquipmentWindow *equipmentWindow;
-ChargeDialog *chargeDialog;
+//ChargeDialog *chargeDialog;
TradeWindow *tradeWindow;
//BuddyWindow *buddyWindow;
HelpWindow *helpWindow;
@@ -183,47 +183,23 @@ void createGuiWindows(Network *network)
setupWindow = new Setup();
minimap = new Minimap();
equipmentWindow = new EquipmentWindow(player_node->mEquipment.get());
- chargeDialog = new ChargeDialog();
+ //chargeDialog = new ChargeDialog();
tradeWindow = new TradeWindow(network);
//buddyWindow = new BuddyWindow();
helpWindow = new HelpWindow();
debugWindow = new DebugWindow();
// Initialize window positions
- int screenW = graphics->getWidth();
- int screenH = graphics->getHeight();
+ //chargeDialog->setPosition(
+ // graphics->getWidth() - 5 - chargeDialog->getWidth(),
+ // graphics->getHeight() - chargeDialog->getHeight() - 15);
- chargeDialog->setPosition(
- screenW - 5 - chargeDialog->getWidth(),
- screenH - chargeDialog->getHeight() - 15);
-
- /*buddyWindow->setPosition(10,
- minimap->getHeight() + 30);*/
+ //buddyWindow->setPosition(10, minimap->getHeight() + 30);
// Set initial window visibility
-// chatWindow->setSticky(true);
-// miniStatusWindow->setSticky(true);
-// menuWindow->setSticky(true);
-
chatWindow->setVisible(true);
miniStatusWindow->setVisible(true);
- statusWindow->setVisible(false);
menuWindow->setVisible(true);
- buyDialog->setVisible(false);
- sellDialog->setVisible(false);
- buySellDialog->setVisible(false);
- inventoryWindow->setVisible(false);
- npcTextDialog->setVisible(false);
- npcListDialog->setVisible(false);
- skillDialog->setVisible(false);
- //newSkillWindow->setVisible(false);
- setupWindow->setVisible(false);
- equipmentWindow->setVisible(false);
- chargeDialog->setVisible(false);
- tradeWindow->setVisible(false);
- //buddyWindow->setVisible(false);
- helpWindow->setVisible(false);
- debugWindow->setVisible(false);
}
/**
@@ -245,7 +221,7 @@ void destroyGuiWindows()
delete setupWindow;
delete minimap;
delete equipmentWindow;
- delete chargeDialog;
+ //delete chargeDialog;
//delete newSkillWindow;
delete tradeWindow;
//delete buddyWindow;
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index fa4c0241..d91019e3 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -121,8 +121,9 @@ CharSelectDialog::CharSelectDialog(Network *network,
add(mJobLevelLabel);
add(mMoneyLabel);
- mSelectButton->requestFocus();
setLocationRelativeTo(getParent());
+ setVisible(true);
+ mSelectButton->requestFocus();
updatePlayerInfo();
}
@@ -309,6 +310,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
add(mCancelButton);
setLocationRelativeTo(getParent());
+ setVisible(true);
}
void CharCreateDialog::action(const std::string& eventId, gcn::Widget* widget)
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 87ed9c17..302caf62 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -87,8 +87,9 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData):
mServerList->setSelected(1);
}
- mOkButton->requestFocus();
setLocationRelativeTo(getParent());
+ setVisible(true);
+ mOkButton->requestFocus();
}
ServerSelectDialog::~ServerSelectDialog()
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 3bd15589..5a70544f 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -61,10 +61,11 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
+ setVisible(true);
yesButton->requestFocus();
}
-void ConfirmDialog::action(const std::string& eventId, gcn::Widget* widget)
+void ConfirmDialog::action(const std::string &eventId, gcn::Widget *widget)
{
// Proxy button events to our listeners
ActionListenerIterator i;
diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h
index 1c206b03..771ecc36 100644
--- a/src/gui/confirm_dialog.h
+++ b/src/gui/confirm_dialog.h
@@ -47,7 +47,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId, gcn::Widget* widget);
+ void action(const std::string &eventId, gcn::Widget *widget);
};
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 675de078..97814360 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -112,6 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
add(mRegisterButton);
setLocationRelativeTo(getParent());
+ setVisible(true);
if (mUserField->getText().empty()) {
mUserField->requestFocus();
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index e527339e..4f9623d7 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -51,10 +51,11 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
add(okButton);
setLocationRelativeTo(getParent());
+ setVisible(true);
okButton->requestFocus();
}
-void OkDialog::action(const std::string& eventId, gcn::Widget* widget)
+void OkDialog::action(const std::string &eventId, gcn::Widget *widget)
{
// Proxy button events to our listeners
ActionListenerIterator i;
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index 06f703cc..8ae08955 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -46,7 +46,7 @@ class OkDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId, gcn::Widget* widget);
+ void action(const std::string &eventId, gcn::Widget *widget);
};
#endif
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 1c1f0a26..458452eb 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -83,7 +83,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
mFemaleButton->setPosition(width - mFemaleButton->getWidth() - 10,
mConfirmField->getY() + mConfirmField->getHeight() + 7);
- mMaleButton->setPosition(mFemaleButton->getX() - mMaleButton->getWidth() - 5,
+ mMaleButton->setPosition(
+ mFemaleButton->getX() - mMaleButton->getWidth() - 5,
mFemaleButton->getY());
mRegisterButton->setPosition(5, height - mRegisterButton->getHeight() - 5);
@@ -104,6 +105,7 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
add(mCancelButton);
setLocationRelativeTo(getParent());
+ setVisible(true);
mUserField->requestFocus();
mUserField->setCaretPosition(mUserField->getText().length());
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index fe23c775..51386eed 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -115,6 +115,9 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
{
requestModalFocus();
}
+
+ // Windows are invisible by default
+ setVisible(false);
}
Window::~Window()
diff --git a/src/gui/window.h b/src/gui/window.h
index 51c876e3..158035c0 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -36,7 +36,8 @@ class WindowContainer;
/**
- * A window. This window can be dragged around and has a title bar.
+ * A window. This window can be dragged around and has a title bar. Windows are
+ * invisible by default.
*
* \ingroup GUI
*/
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 46348efc..d5484ac3 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -223,10 +223,8 @@ void LocalPlayer::walk(unsigned char dir)
}
else if (dir)
{
- // Update the player direction to where he wants to walk
- // Warning: Not communicated to the server yet
-
// If the being can't move, just change direction
+ // TODO: Communicate this to the server (waiting on tmwserv)
setDirection(dir);
}
}
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 5a1ed1e5..3fe3059d 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -107,7 +107,8 @@ void BeingHandler::handleMessage(MessageIn *msg)
dstBeing->mJob = job;
dstBeing->setHairStyle(msg->readInt16());
dstBeing->setWeapon(msg->readInt16());
- dstBeing->setVisibleEquipment(Being::BOTTOMCLOTHES_SPRITE, msg->readInt16()); // head bottom
+ dstBeing->setVisibleEquipment(
+ Being::BOTTOMCLOTHES_SPRITE, msg->readInt16());
if (msg->getId() == SMSG_BEING_MOVE)
{
@@ -115,8 +116,9 @@ void BeingHandler::handleMessage(MessageIn *msg)
}
msg->readInt16(); // shield
- dstBeing->setVisibleEquipment(Being::HAT_SPRITE, msg->readInt16()); // head top
- dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, msg->readInt16()); // head mid
+ dstBeing->setVisibleEquipment(Being::HAT_SPRITE, msg->readInt16());
+ dstBeing->setVisibleEquipment(
+ Being::TOPCLOTHES_SPRITE, msg->readInt16());
dstBeing->setHairColor(msg->readInt16());
msg->readInt16(); // unknown
msg->readInt16(); // head dir
@@ -255,13 +257,19 @@ void BeingHandler::handleMessage(MessageIn *msg)
switch (msg->readInt8())
{
case 3:
- dstBeing->setVisibleEquipment(Being::BOTTOMCLOTHES_SPRITE, msg->readInt8());
+ dstBeing->setVisibleEquipment(
+ Being::BOTTOMCLOTHES_SPRITE,
+ msg->readInt8());
break;
case 4:
- dstBeing->setVisibleEquipment(Being::HAT_SPRITE, msg->readInt8());
+ dstBeing->setVisibleEquipment(
+ Being::HAT_SPRITE,
+ msg->readInt8());
break;
case 5:
- dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, msg->readInt8());
+ dstBeing->setVisibleEquipment(
+ Being::TOPCLOTHES_SPRITE,
+ msg->readInt8());
break;
}
break;
@@ -322,7 +330,8 @@ void BeingHandler::handleMessage(MessageIn *msg)
msg->readInt16(); // manner
msg->readInt8(); // karma
dstBeing->setSex(1 - msg->readInt8()); // sex
- dstBeing->setVisibleEquipment(Being::BOTTOMCLOTHES_SPRITE, headBottom);
+ dstBeing->setVisibleEquipment(
+ Being::BOTTOMCLOTHES_SPRITE, headBottom);
dstBeing->setVisibleEquipment(Being::HAT_SPRITE, headTop);
dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, headMid);
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index a803710e..da21b2a5 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -49,18 +49,22 @@ NPCHandler::NPCHandler()
void NPCHandler::handleMessage(MessageIn *msg)
{
+ int id;
+
switch (msg->getId())
{
case SMSG_NPC_CHOICE:
msg->readInt16(); // length
- current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg->readInt32()));
+ id = msg->readInt32();
+ current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcListDialog->parseItems(msg->readString(msg->getLength() - 8));
npcListDialog->setVisible(true);
break;
case SMSG_NPC_MESSAGE:
msg->readInt16(); // length
- current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg->readInt32()));
+ id = msg->readInt32();
+ current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcTextDialog->addText(msg->readString(msg->getLength() - 8));
npcListDialog->setVisible(false);
npcTextDialog->setVisible(true);
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index 3786cd0b..e83bcce8 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -46,7 +46,10 @@ OkDialog *deathNotice = NULL;
namespace {
struct WeightListener : public gcn::ActionListener
{
- void action(const std::string& eventId, gcn::Widget* widget) { weightNotice = NULL; }
+ void action(const std::string &eventId, gcn::Widget *widget)
+ {
+ weightNotice = NULL;
+ }
} weightListener;
}
@@ -55,8 +58,10 @@ namespace {
*/
// TODO Move somewhere else
namespace {
- struct DeathListener : public gcn::ActionListener {
- void action(const std::string& eventId, gcn::Widget* widget) {
+ struct DeathListener : public gcn::ActionListener
+ {
+ void action(const std::string &eventId, gcn::Widget *widget)
+ {
player_node->revive();
deathNotice = NULL;
}
@@ -137,10 +142,11 @@ void PlayerHandler::handleMessage(MessageIn *msg)
player_node->mMaxWeight / 2)
{
weightNotice = new OkDialog("Message",
- "You are carrying more then half your "
- "weight. You are unable to regain "
- "health.");
- weightNotice->addActionListener(&weightListener);
+ "You are carrying more then half "
+ "your weight. You are unable to "
+ "regain health.");
+ weightNotice->addActionListener(
+ &weightListener);
}
player_node->mTotalWeight = value;
break;
diff --git a/src/npc.cpp b/src/npc.cpp
index d2e3f93f..a961420f 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -24,10 +24,13 @@
#include "npc.h"
#include "animatedsprite.h"
+#include "graphics.h"
#include "net/messageout.h"
#include "net/protocol.h"
+#include "gui/gui.h"
+
class Spriteset;
extern Spriteset *npcset;
@@ -47,6 +50,17 @@ NPC::getType() const
}
void
+NPC::drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
+{
+ int px = mPx + offsetX;
+ int py = mPy + offsetY;
+
+ graphics->setFont(speechFont);
+ graphics->setColor(gcn::Color(200, 200, 255));
+ graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER);
+}
+
+void
NPC::talk()
{
MessageOut outMsg(mNetwork);
diff --git a/src/npc.h b/src/npc.h
index b08c315c..0d9966bd 100644
--- a/src/npc.h
+++ b/src/npc.h
@@ -27,13 +27,18 @@
#include "being.h"
class Network;
+class Graphics;
class NPC : public Being
{
public:
NPC(Uint32 id, Uint16 job, Map *map, Network *network);
- virtual Type getType() const;
+ virtual Type
+ getType() const;
+
+ virtual void
+ drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY);
void talk();
void nextDialog();
diff --git a/src/player.cpp b/src/player.cpp
index a543b345..b9076260 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -36,9 +36,6 @@
Player::Player(Uint32 id, Uint16 job, Map *map):
Being(id, job, map)
{
- // Load the weapon sprite.
- // When there are more different weapons this should be moved to the
- // setWeapon Method.
setWeapon(0);
}