summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-15 13:10:38 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-15 13:10:38 -0600
commite8a1b2386bb2c28cfce0eb28d7e7067d51bb6701 (patch)
tree6c9218f32675f9d401301172869c30488ab08b16 /src
parent56c224050f10d976298cef98607aa3b3e56fcc99 (diff)
parent3d85a00ff2a33e22ba63d0b7dfc156d8076933e1 (diff)
downloadmana-client-e8a1b2386bb2c28cfce0eb28d7e7067d51bb6701.tar.gz
mana-client-e8a1b2386bb2c28cfce0eb28d7e7067d51bb6701.tar.bz2
mana-client-e8a1b2386bb2c28cfce0eb28d7e7067d51bb6701.tar.xz
mana-client-e8a1b2386bb2c28cfce0eb28d7e7067d51bb6701.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp6
-rw-r--r--src/floor_item.cpp5
-rw-r--r--src/floor_item.h6
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/palette.cpp62
-rw-r--r--src/gui/palette.h31
-rw-r--r--src/gui/popupmenu.cpp48
-rw-r--r--src/gui/setup_colors.cpp90
-rw-r--r--src/gui/setup_colors.h4
-rw-r--r--src/gui/setup_video.cpp9
-rw-r--r--src/gui/viewport.cpp9
-rw-r--r--src/gui/viewport.h6
-rw-r--r--src/map.cpp10
-rw-r--r--src/map.h6
-rw-r--r--src/monster.cpp21
-rw-r--r--src/net/ea/playerhandler.cpp1
-rw-r--r--src/shopitem.cpp1
17 files changed, 218 insertions, 103 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 95f2cb1b..a0e475f6 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -58,6 +58,10 @@ bool Engine::changeMap(const std::string &mapPath)
floorItemManager->clear();
beingManager->clear();
+ // Close the popup menu on map change so that invalid options can't be
+ // executed.
+ viewport->closePopupMenu();
+
// Unset the map of the player so that its particles are cleared before
// being deleted in the next step
if (player_node)
@@ -144,7 +148,5 @@ void Engine::logic()
{
beingManager->logic();
particleEngine->update();
- if (mCurrentMap)
- mCurrentMap->update();
gui->logic();
}
diff --git a/src/floor_item.cpp b/src/floor_item.cpp
index 000835ad..b8c0ffaf 100644
--- a/src/floor_item.cpp
+++ b/src/floor_item.cpp
@@ -56,6 +56,11 @@ int FloorItem::getItemId() const
return mItem->getId();
}
+Item* FloorItem::getItem() const
+{
+ return mItem;
+}
+
void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
{
graphics->drawImage(mItem->getImage(),
diff --git a/src/floor_item.h b/src/floor_item.h
index 7ca0f5a3..0e269c77 100644
--- a/src/floor_item.h
+++ b/src/floor_item.h
@@ -64,6 +64,12 @@ class FloorItem : public Sprite
int getItemId() const;
/**
+ * Returns the item object. Useful for adding an item link for the floor
+ * item to chat.
+ */
+ Item* getItem() const;
+
+ /**
* Returns the x coordinate.
*/
int getX() const { return mX; }
diff --git a/src/game.cpp b/src/game.cpp
index 750725db..2ee4ad13 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -41,6 +41,7 @@
#include "keyboardconfig.h"
#include "localplayer.h"
#include "log.h"
+#include "map.h"
#include "npc.h"
#include "particle.h"
#include "player_relations.h"
@@ -95,8 +96,6 @@
#include "utils/gettext.h"
-class Map;
-
std::string map_path;
bool done = false;
@@ -473,6 +472,9 @@ void Game::logic()
while (!done)
{
+ if (Map *map = engine->getCurrentMap())
+ map->update(get_elapsed_time(gameTime));
+
// Handle all necessary game logic
while (get_elapsed_time(gameTime) > 0)
{
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 92a2aea5..d06d589f 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -73,8 +73,6 @@ std::string Palette::getConfigName(const std::string &typeName)
DEFENUMNAMES(ColorType, COLOR_TYPE);
-const int Palette::GRADIENT_DELAY = 40;
-
Palette::Palette() :
mRainbowTime(tick_time),
mColVector(ColVector(TYPE_COUNT))
@@ -149,10 +147,12 @@ Palette::~Palette()
{
configName = &ColorTypeNames[col->type];
config.setValue(*configName + "Gradient", col->committedGrad);
+
+ if (col->grad != STATIC)
+ config.setValue(*configName + "Delay", col->delay);
+
if (col->grad == STATIC || col->grad == PULSE)
- {
config.setValue(*configName, toString(col->getRGB()));
- }
}
}
@@ -227,6 +227,7 @@ void Palette::commit(bool commitNonStatic)
i != iEnd; ++i)
{
i->committedGrad = i->grad;
+ i->committedDelay = i->delay;
if (commitNonStatic || i->grad == STATIC)
{
i->committedColor = i->color;
@@ -241,13 +242,13 @@ void Palette::commit(bool commitNonStatic)
void Palette::rollback()
{
for (ColVector::iterator i = mColVector.begin(), iEnd = mColVector.end();
- i != iEnd;
- ++i)
+ i != iEnd; ++i)
{
if (i->grad != i->committedGrad)
{
setGradient(i->type, i->committedGrad);
}
+ setGradientDelay(i->type, i->committedDelay);
setColor(i->type, i->committedColor.r, i->committedColor.g,
i->committedColor.b);
if (i->grad == PULSE)
@@ -260,24 +261,24 @@ void Palette::rollback()
}
void Palette::addColor(Palette::ColorType type, int rgb,
- Palette::GradientType grad,
- const std::string &text, char c)
+ Palette::GradientType grad, const std::string &text,
+ char c, int delay)
{
const std::string *configName = &ColorTypeNames[type];
- gcn::Color trueCol = (int)config.getValue(*configName, rgb);
- grad = (GradientType)config.getValue(*configName + "Gradient", grad);
- mColVector[type].set(type, trueCol, grad, text, c);
+ gcn::Color trueCol = (int) config.getValue(*configName, rgb);
+ grad = (GradientType) config.getValue(*configName + "Gradient", grad);
+ delay = (int) config.getValue(*configName + "Delay", delay);
+ mColVector[type].set(type, trueCol, grad, text, c, delay);
+
if (grad != STATIC)
- {
mGradVector.push_back(&mColVector[type]);
- }
}
void Palette::advanceGradient ()
{
if (get_elapsed_time(mRainbowTime) > 5)
{
- int pos, colIndex, colVal;
+ int pos, colIndex, colVal, delay, numOfColors;
// For slower systems, advance can be greater than one (advance > 1
// skips advance-1 steps). Should make gradient look the same
// independent of the framerate.
@@ -286,19 +287,25 @@ void Palette::advanceGradient ()
for (size_t i = 0; i < mGradVector.size(); i++)
{
+ delay = mGradVector[i]->delay;
+
+ if (mGradVector[i]->grad == PULSE)
+ delay = delay / 20;
+
+ numOfColors = (mGradVector[i]->grad == SPECTRUM ? 6 :
+ mGradVector[i]->grad == PULSE ? 127 :
+ RAINBOW_COLOR_COUNT);
+
mGradVector[i]->gradientIndex =
- (mGradVector[i]->gradientIndex + advance) %
- (GRADIENT_DELAY * ((mGradVector[i]->grad == SPECTRUM) ?
- (mGradVector[i]->grad == PULSE) ? 255 : 6 :
- RAINBOW_COLOR_COUNT));
+ (mGradVector[i]->gradientIndex + advance) %
+ (delay * numOfColors);
- pos = mGradVector[i]->gradientIndex % GRADIENT_DELAY;
- colIndex = mGradVector[i]->gradientIndex / GRADIENT_DELAY;
+ pos = mGradVector[i]->gradientIndex % delay;
+ colIndex = mGradVector[i]->gradientIndex / delay;
if (mGradVector[i]->grad == PULSE)
{
- colVal = (int) (255.0 * (sin(M_PI *
- (mGradVector[i]->gradientIndex) / 255) + 1) / 2);
+ colVal = (int) (255.0 * sin(M_PI * colIndex / numOfColors));
const gcn::Color* col = &mGradVector[i]->testColor;
@@ -310,13 +317,12 @@ void Palette::advanceGradient ()
{
if (colIndex % 2)
{ // falling curve
- colVal = (int)(255.0 * (cos(M_PI * pos / GRADIENT_DELAY) +
- 1) / 2);
+ colVal = (int)(255.0 * (cos(M_PI * pos / delay) + 1) / 2);
}
else
{ // ascending curve
- colVal = (int)(255.0 * (cos(M_PI * (GRADIENT_DELAY-pos) /
- GRADIENT_DELAY) + 1) / 2);
+ colVal = (int)(255.0 * (cos(M_PI * (delay - pos) / delay) +
+ 1) / 2);
}
mGradVector[i]->color.r =
@@ -333,9 +339,9 @@ void Palette::advanceGradient ()
{
const gcn::Color* startCol = &RAINBOW_COLORS[colIndex];
const gcn::Color* destCol =
- &RAINBOW_COLORS[(colIndex + 1) % RAINBOW_COLOR_COUNT];
+ &RAINBOW_COLORS[(colIndex + 1) % numOfColors];
- startColVal = (cos(M_PI * pos / GRADIENT_DELAY) + 1) / 2;
+ startColVal = (cos(M_PI * pos / delay) + 1) / 2;
destColVal = 1 - startColVal;
mGradVector[i]->color.r =(int)(startColVal * startCol->r +
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 6a9fc937..1dec2a60 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -42,6 +42,9 @@
#define DEFENUMNAMES(name,def)\
const std::string Palette::name ## Names[] = { def(ECONFIGSTR,ECONFIGSTR) "" }
+// Default Gradient Delay
+#define GRADIENT_DELAY 40
+
/**
* Class controlling the game's color palette.
*/
@@ -196,6 +199,16 @@ class Palette : public gcn::ListModel
}
/**
+ * Gets the gradient delay for the specified type.
+ *
+ * @param type the color type of the color
+ *
+ * @return the gradient delay of the color with the given index
+ */
+ inline int getGradientDelay(ColorType type)
+ { return mColVector[type].delay; }
+
+ /**
* Get the character used by the specified color.
*
* @param type the color type of the color
@@ -225,6 +238,14 @@ class Palette : public gcn::ListModel
void setGradient(ColorType type, GradientType grad);
/**
+ * Sets the gradient delay for the specified color.
+ *
+ * @param grad gradient type to set
+ */
+ void setGradientDelay(ColorType type, int delay)
+ { mColVector[type].delay = delay; }
+
+ /**
* Returns the number of colors known.
*
* @return the number of colors known
@@ -275,8 +296,6 @@ class Palette : public gcn::ListModel
/** Colors used for the rainbow gradient */
static const gcn::Color RAINBOW_COLORS[];
static const int RAINBOW_COLOR_COUNT;
- /** Parameter to control the speed of the gradient */
- static const int GRADIENT_DELAY;
/** Time tick, that gradient-type colors were updated the last time. */
int mRainbowTime;
@@ -307,9 +326,11 @@ class Palette : public gcn::ListModel
GradientType grad;
GradientType committedGrad;
int gradientIndex;
+ int delay;
+ int committedDelay;
void set(ColorType type, gcn::Color& color, GradientType grad,
- const std::string &text, char c)
+ const std::string &text, char c, int delay)
{
ColorElem::type = type;
ColorElem::color = color;
@@ -317,6 +338,7 @@ class Palette : public gcn::ListModel
ColorElem::text = text;
ColorElem::ch = c;
ColorElem::grad = grad;
+ ColorElem::delay = delay;
ColorElem::gradientIndex = rand();
}
@@ -339,7 +361,8 @@ class Palette : public gcn::ListModel
* @param text identifier of color
*/
void addColor(ColorType type, int rgb, GradientType grad,
- const std::string &text, char c = 0);
+ const std::string &text, char c = 0,
+ int delay = GRADIENT_DELAY);
/**
* Prefixes the given string with "Color", lowercases all letters but
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index e8af3122..5142482f 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -78,13 +78,16 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (being->getType() != Being::UNKNOWN)
mBrowserBox->addRow(_("@@name|Add name to chat@@"));
+ const std::string &name = being->getType() == Being::NPC ?
+ being->getName().substr(0, being->getName().size()
+ - 6) : being->getName();
+
switch (being->getType())
{
case Being::PLAYER:
{
// Players can be traded with. Later also follow and
// add as buddy will be options in this menu.
- const std::string &name = being->getName();
mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str()));
mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
@@ -109,7 +112,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
break;
}
- //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@");
+ //mBrowserBox->addRow(_(strprintf("@@follow|Follow %s@@"), name.c_str()));
//mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@");
mBrowserBox->addRow(strprintf(_("@@guild|Invite %s to join your guild@@"), name.c_str()));
mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str()));
@@ -123,7 +126,12 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case Being::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow(_("@@talk|Talk To NPC@@"));
+ mBrowserBox->addRow(strprintf(_("@@talk|Talk To %s@@"), name.c_str()));
+ break;
+
+ case Being::MONSTER:
+ // Monsters can be attacked
+ mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
break;
/*case Being::MONSTER:
@@ -132,7 +140,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
default:
/* Other beings aren't interesting... */
- break;
+ return;
}
//browserBox->addRow("@@look|Look To@@");
@@ -145,11 +153,13 @@ void PopupMenu::showPopup(int x, int y, Being *being)
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
{
mFloorItem = floorItem;
+ mItem = floorItem->getItem();
mBrowserBox->clearRows();
// Floor item can be picked up (single option, candidate for removal)
std::string name = ItemDB::get(mFloorItem->getItemId()).getName();
mBrowserBox->addRow(strprintf(_("@@pickup|Pick Up %s@@"), name.c_str()));
+ mBrowserBox->addRow(_("@@chat|Add to Chat@@"));
//browserBox->addRow("@@look|Look To@@");
mBrowserBox->addRow("##3---");
@@ -181,9 +191,7 @@ void PopupMenu::handleLink(const std::string &link)
}
#ifdef EATHENA_SUPPORT
// Attack action
- else if (link == "attack" &&
- being &&
- being->getType() == Being::PLAYER)
+ else if (link == "attack" && being)
{
player_node->attack(being, true);
}
@@ -224,11 +232,6 @@ void PopupMenu::handleLink(const std::string &link)
player_node->inviteToGuild(being);
}
#endif
- // Add player to your party
- else if (link == "party")
- {
- player_node->inviteToParty(dynamic_cast<Player*>(being));
- }
/*
// Follow Player action
else if (link == "follow")
@@ -244,10 +247,6 @@ void PopupMenu::handleLink(const std::string &link)
buddyWindow->addBuddy(being->getName());
}*/
- else if (link == "name")
- {
- chatWindow->addInputText(being->getName());
- }
// Pick Up Floor Item action
else if ((link == "pickup") && mFloorItem)
@@ -294,11 +293,26 @@ void PopupMenu::handleLink(const std::string &link)
new ItemAmountWindow(ItemAmountWindow::ItemSplit,
inventoryWindow, mItem);
}
+
else if (link == "drop")
{
new ItemAmountWindow(ItemAmountWindow::ItemDrop,
inventoryWindow, mItem);
}
+
+ else if (link == "party" && being && being->getType() == Being::PLAYER)
+ {
+ player_node->inviteToParty(dynamic_cast<Player*>(being));
+ }
+
+ else if (link == "name" && being)
+ {
+ const std::string &name = being->getType() == Being::NPC ?
+ being->getName().substr(0,
+ being->getName().size() - 6) : being->getName();
+ chatWindow->addInputText(name);
+ }
+
else if (link == "admin-kick" &&
being &&
(being->getType() == Being::PLAYER ||
@@ -308,7 +322,7 @@ void PopupMenu::handleLink(const std::string &link)
}
// Unknown actions
- else
+ else if (link != "cancel")
{
std::cout << link << std::endl;
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 4d8c1e1d..352338e9 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -71,7 +71,7 @@ Setup_Colors::Setup_Colors() :
mGradTypeLabel = new Label(_("Type: "));
mGradTypeSlider = new Slider(0, 3);
- mGradTypeSlider->setWidth(160);
+ mGradTypeSlider->setWidth(200);
mGradTypeSlider->setActionEventId("slider_grad");
mGradTypeSlider->setValue(0);
mGradTypeSlider->addActionListener(this);
@@ -79,6 +79,33 @@ Setup_Colors::Setup_Colors() :
mGradTypeText = new Label;
+ std::string longText = _("Static");
+
+ if (getFont()->getWidth(_("Pulse")) > getFont()->getWidth(longText))
+ longText = _("Pulse");
+ if (getFont()->getWidth(_("Rainbow")) > getFont()->getWidth(longText))
+ longText = _("Rainbow");
+ if (getFont()->getWidth(_("Spectrum")) > getFont()->getWidth(longText))
+ longText = _("Spectrum");
+
+ mGradTypeText->setCaption(longText);
+
+ mGradDelayLabel = new Label(_("Delay: "));
+
+ mGradDelayText = new TextField();
+ mGradDelayText->setWidth(40);
+ mGradDelayText->setRange(20, 100);
+ mGradDelayText->setNumeric(true);
+ mGradDelayText->addListener(this);
+ mGradDelayText->setEnabled(false);
+
+ mGradDelaySlider = new Slider(20, 100);
+ mGradDelaySlider->setWidth(180);
+ mGradDelaySlider->setValue(mGradDelayText->getValue());
+ mGradDelaySlider->setActionEventId("slider_graddelay");
+ mGradDelaySlider->addActionListener(this);
+ mGradDelaySlider->setEnabled(false);
+
mRedLabel = new Label(_("Red: "));
mRedText = new TextField;
@@ -89,7 +116,7 @@ Setup_Colors::Setup_Colors() :
mRedText->setEnabled(false);
mRedSlider = new Slider(0, 255);
- mRedSlider->setWidth(160);
+ mRedSlider->setWidth(180);
mRedSlider->setValue(mRedText->getValue());
mRedSlider->setActionEventId("slider_red");
mRedSlider->addActionListener(this);
@@ -105,7 +132,7 @@ Setup_Colors::Setup_Colors() :
mGreenText->setEnabled(false);
mGreenSlider = new Slider(0, 255);
- mGreenSlider->setWidth(160);
+ mGreenSlider->setWidth(180);
mGreenSlider->setValue(mGreenText->getValue());
mGreenSlider->setActionEventId("slider_green");
mGreenSlider->addActionListener(this);
@@ -121,7 +148,7 @@ Setup_Colors::Setup_Colors() :
mBlueText->setEnabled(false);
mBlueSlider = new Slider(0, 255);
- mBlueSlider->setWidth(160);
+ mBlueSlider->setWidth(180);
mBlueSlider->setValue(mBlueText->getValue());
mBlueSlider->setActionEventId("slider_blue");
mBlueSlider->addActionListener(this);
@@ -133,11 +160,11 @@ Setup_Colors::Setup_Colors() :
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 4, 6).setPadding(2);
- place(0, 6, mPreviewBox, 4).setPadding(2);
+ place(0, 0, mScroll, 5, 6).setPadding(2);
+ place(0, 6, mPreviewBox, 5).setPadding(2);
place(0, 7, mGradTypeLabel, 2);
place(2, 7, mGradTypeSlider);
- place(3, 7, mGradTypeText);
+ place(3, 7, mGradTypeText, 2).setPadding(1);
place(0, 8, mRedLabel, 2);
place(2, 8, mRedSlider);
place(3, 8, mRedText).setPadding(1);
@@ -147,6 +174,11 @@ Setup_Colors::Setup_Colors() :
place(0, 10, mBlueLabel, 2);
place(2, 10, mBlueSlider);
place(3, 10, mBlueText).setPadding(1);
+ place(0, 11, mGradDelayLabel, 2);
+ place(2, 11, mGradDelaySlider);
+ place(3, 11, mGradDelayText).setPadding(1);
+
+ mGradTypeText->setCaption("");
setDimension(gcn::Rectangle(0, 0, 325, 280));
}
@@ -167,9 +199,10 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
Palette::ColorType type = guiPalette->getColorTypeAt(mSelected);
const gcn::Color *col = &guiPalette->getColor(type);
Palette::GradientType grad = guiPalette->getGradientType(type);
+ const int delay = guiPalette->getGradientDelay(type);
std::string msg;
- char ch = guiPalette->getColorChar(type);
+ const char ch = guiPalette->getColorChar(type);
mPreview->clearRows();
mPreviewBox->setContent(mTextPreview);
@@ -300,6 +333,7 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
col = &guiPalette->getTestColor(type);
}
+ setEntry(mGradDelaySlider, mGradDelayText, delay);
setEntry(mRedSlider, mRedText, col->r);
setEntry(mGreenSlider, mGreenText, col->g);
setEntry(mBlueSlider, mBlueText, col->b);
@@ -318,6 +352,13 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
return;
}
+ if (event.getId() == "slider_graddelay")
+ {
+ mGradDelayText->setText(toString(std::floor(mGradDelaySlider->getValue())));
+ updateColor();
+ return;
+ }
+
if (event.getId() == "slider_red")
{
mRedText->setText(toString(std::floor(mRedSlider->getValue())));
@@ -359,6 +400,8 @@ void Setup_Colors::cancel()
Palette::ColorType type = guiPalette->getColorTypeAt(mSelected);
const gcn::Color *col = &guiPalette->getColor(type);
mGradTypeSlider->setValue(guiPalette->getGradientType(type));
+ const int delay = guiPalette->getGradientDelay(type);
+ setEntry(mGradDelaySlider, mGradDelayText, delay);
setEntry(mRedSlider, mRedText, col->r);
setEntry(mGreenSlider, mGreenText, col->g);
setEntry(mBlueSlider, mBlueText, col->b);
@@ -366,24 +409,16 @@ void Setup_Colors::cancel()
void Setup_Colors::listen(const TextField *tf)
{
- if (tf == mRedText)
- {
+ if (tf == mGradDelayText)
+ mGradDelaySlider->setValue(tf->getValue());
+ else if (tf == mRedText)
mRedSlider->setValue(tf->getValue());
- updateColor();
- return;
- }
- if (tf == mGreenText)
- {
+ else if (tf == mGreenText)
mGreenSlider->setValue(tf->getValue());
- updateColor();
- return;
- }
- if (tf == mBlueText)
- {
+ else if (tf == mBlueText)
mBlueSlider->setValue(tf->getValue());
- updateColor();
- return;
- }
+
+ updateColor();
}
void Setup_Colors::updateGradType()
@@ -400,7 +435,12 @@ void Setup_Colors::updateGradType()
(grad == Palette::PULSE) ? _("Pulse") :
(grad == Palette::RAINBOW) ? _("Rainbow") : _("Spectrum"));
- bool enable = (grad == Palette::STATIC || grad == Palette::PULSE);
+ const bool enable = (grad == Palette::STATIC || grad == Palette::PULSE);
+ const bool delayEnable = (grad != Palette::STATIC);
+
+ mGradDelayText->setEnabled(delayEnable);
+ mGradDelaySlider->setEnabled(delayEnable);
+
mRedText->setEnabled(enable);
mRedSlider->setEnabled(enable);
mGreenText->setEnabled(enable);
@@ -417,7 +457,9 @@ void Setup_Colors::updateColor()
Palette::ColorType type = guiPalette->getColorTypeAt(mSelected);
Palette::GradientType grad =
static_cast<Palette::GradientType>((int)mGradTypeSlider->getValue());
+ int delay = (int) mGradDelaySlider->getValue();
guiPalette->setGradient(type, grad);
+ guiPalette->setGradientDelay(type, delay);
if (grad == Palette::STATIC)
{
diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h
index 0aaf8b49..10a3437c 100644
--- a/src/gui/setup_colors.h
+++ b/src/gui/setup_colors.h
@@ -62,6 +62,10 @@ class Setup_Colors : public SetupTab, public gcn::ActionListener,
gcn::Slider *mGradTypeSlider;
gcn::Label *mGradTypeText;
+ gcn::Label *mGradDelayLabel;
+ gcn::Slider *mGradDelaySlider;
+ TextField *mGradDelayText;
+
gcn::Label *mRedLabel;
gcn::Slider *mRedSlider;
TextField *mRedText;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 8f358eda..4a5e06a4 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -32,6 +32,7 @@
#include "gui/widgets/textfield.h"
#include "configuration.h"
+#include "engine.h"
#include "graphics.h"
#include "localplayer.h"
#include "log.h"
@@ -464,9 +465,11 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("particleeffects",
mParticleEffectsCheckBox->isSelected());
- new OkDialog(_("Particle effect settings changed."),
- _("Restart your client or change maps "
- "for the change to take effect."));
+ if (engine)
+ {
+ new OkDialog(_("Particle effect settings changed."),
+ _("Changes will take effect on map change."));
+ }
}
else if (event.getId() == "pickupchat")
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 3fc5f2d4..9ce537fc 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -313,8 +313,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if ((being = beingManager->findBeingByPixel(pixelx, pixely)) &&
being != player_node)
{
- mPopupMenu->showPopup(event.getX(), event.getY(), being);
- return;
+ mPopupMenu->showPopup(event.getX(), event.getY(), being);
+ return;
}
else if ((floorItem = floorItemManager->findByCoordinates(tilex,
tiley)))
@@ -446,6 +446,11 @@ void Viewport::showPopup(int x, int y, Item *item)
mPopupMenu->showPopup(x, y, item);
}
+void Viewport::closePopupMenu()
+{
+ mPopupMenu->handleLink("cancel");
+}
+
void Viewport::optionChanged(const std::string &name)
{
mScrollLaziness = (int) config.getValue("ScrollLaziness", 32);
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index cff23862..3dae5a2a 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -109,6 +109,12 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void showPopup(int x, int y, Item *item);
/**
+ * Closes the popup menu. Needed for when the player dies or switching
+ * maps.
+ */
+ void closePopupMenu();
+
+ /**
* A relevant config option changed.
*/
void optionChanged(const std::string &name);
diff --git a/src/map.cpp b/src/map.cpp
index 0dc4759e..472c136f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -75,13 +75,13 @@ TileAnimation::~TileAnimation()
delete mAnimation;
}
-void TileAnimation::update()
+void TileAnimation::update(int ticks)
{
if (!mAnimation)
return;
- //update animation
- mAnimation->update(1);
+ // update animation
+ mAnimation->update(ticks);
// exchange images
Image *img = mAnimation->getCurrentImage();
@@ -248,14 +248,14 @@ bool spriteCompare(const Sprite *a, const Sprite *b)
return a->getPixelY() < b->getPixelY();
}
-void Map::update()
+void Map::update(int ticks)
{
//update animated tiles
for (std::map<int, TileAnimation*>::iterator iAni = mTileAnimations.begin();
iAni != mTileAnimations.end();
iAni++)
{
- iAni->second->update();
+ iAni->second->update(ticks);
}
}
diff --git a/src/map.h b/src/map.h
index 09bed293..c49ebb12 100644
--- a/src/map.h
+++ b/src/map.h
@@ -73,7 +73,7 @@ class TileAnimation
public:
TileAnimation(Animation *ani);
~TileAnimation();
- void update();
+ void update(int ticks = 1);
void addAffectedTile(MapLayer *layer, int index)
{ mAffected.push_back(std::make_pair(layer, index)); }
private:
@@ -169,9 +169,9 @@ class Map : public Properties
void initializeOverlays();
/**
- * Updates animations. Called every game tick.
+ * Updates animations. Called as needed.
*/
- void update();
+ void update(int ticks = 1);
/**
* Draws the map to the given graphics output. This method draws all
diff --git a/src/monster.cpp b/src/monster.cpp
index 08a614ea..92e1f84a 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -43,8 +43,7 @@ Monster::Monster(int id, int job, Map *map):
const std::list<std::string> &sprites = info.getSprites();
for (std::list<std::string>::const_iterator i = sprites.begin();
- i != sprites.end();
- i++)
+ i != sprites.end(); i++)
{
if (c == VECTOREND_SPRITE) break;
@@ -62,15 +61,16 @@ Monster::Monster(int id, int job, Map *map):
if (mParticleEffects)
{
const std::list<std::string> &particleEffects = info.getParticleEffects();
- for ( std::list<std::string>::const_iterator i = particleEffects.begin();
- i != particleEffects.end(); i++
- )
+ for (std::list<std::string>::const_iterator i = particleEffects.begin();
+ i != particleEffects.end(); i++)
{
controlParticle(particleEngine->addEffect((*i), 0, 0));
}
}
mNameColor = &guiPalette->getColor(Palette::MONSTER);
+
+ Being::setName(getInfo().getName());
}
Monster::~Monster()
@@ -86,9 +86,7 @@ void Monster::logic()
mFrame = (get_elapsed_time(mWalkTime) * 4) / getWalkSpeed();
if (mFrame >= 4 && mAction != DEAD)
- {
nextStep();
- }
}
Being::logic();
@@ -132,8 +130,7 @@ void Monster::setAction(Action action, int attackType)
default: break;
}
Particle *p;
- p = particleEngine->addEffect(
- particleEffect, 0, 0, rotation);
+ p = particleEngine->addEffect(particleEffect, 0, 0, rotation);
controlParticle(p);
}
break;
@@ -153,9 +150,7 @@ void Monster::setAction(Action action, int attackType)
for (int i = 0; i < VECTOREND_SPRITE; i++)
{
if (mSprites[i])
- {
mSprites[i]->play(currentAction);
- }
}
mAction = action;
}
@@ -190,7 +185,9 @@ void Monster::handleAttack(Being *victim, int damage, AttackType type)
void Monster::takeDamage(Being *attacker, int amount, AttackType type)
{
- if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
+ if (amount > 0)
+ sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
+
Being::takeDamage(attacker, amount, type);
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 3b8b86af..5d2a4829 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -95,6 +95,7 @@ namespace {
if (storageWindow->isVisible())
storageWindow->close();
+ viewport->closePopupMenu();
}
} deathListener;
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 683cef7a..2389785a 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -63,7 +63,6 @@ void ShopItem::addDuplicate(int inventoryIndex, int quantity)
mQuantity += quantity;
}
-
void ShopItem::addDuplicate()
{
DuplicateItem* di = new DuplicateItem;