From ef13037435c671b76c75c3ecefbad83dbdc578f2 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 15 Apr 2009 19:42:07 +0200 Subject: Exposed delay values to the user, but made it so that the delay is color based, instead of global, so that the user can specify different delays for different types of actions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ira Rice Signed-off-by: Bjørn Lindeijer --- src/gui/palette.cpp | 62 ++++++++++++++++++--------------- src/gui/palette.h | 31 ++++++++++++++--- src/gui/setup_colors.cpp | 89 ++++++++++++++++++++++++++++++++---------------- src/gui/setup_colors.h | 4 +++ 4 files changed, 124 insertions(+), 62 deletions(-) (limited to 'src/gui') 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. */ @@ -195,6 +198,16 @@ class Palette : public gcn::ListModel return mColVector[type].grad; } + /** + * 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. * @@ -224,6 +237,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. * @@ -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/setup_colors.cpp b/src/gui/setup_colors.cpp index 4d8c1e1d..80c425e5 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,22 @@ Setup_Colors::Setup_Colors() : mGradTypeText = new Label; + mGradDelayLabel = new Label(_("Delay: ")); + + mGradDelayText = new TextField(); + mGradDelayText->setWidth(40); + mGradDelayText->setRange(20, 400); + mGradDelayText->setNumeric(true); + mGradDelayText->addListener(this); + mGradDelayText->setEnabled(false); + + mGradDelaySlider = new Slider(20, 400); + mGradDelaySlider->setWidth(200); + mGradDelaySlider->setValue(mGradDelayText->getValue()); + mGradDelaySlider->setActionEventId("slider_graddelay"); + mGradDelaySlider->addActionListener(this); + mGradDelaySlider->setEnabled(false); + mRedLabel = new Label(_("Red: ")); mRedText = new TextField; @@ -89,7 +105,7 @@ Setup_Colors::Setup_Colors() : mRedText->setEnabled(false); mRedSlider = new Slider(0, 255); - mRedSlider->setWidth(160); + mRedSlider->setWidth(200); mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); @@ -105,7 +121,7 @@ Setup_Colors::Setup_Colors() : mGreenText->setEnabled(false); mGreenSlider = new Slider(0, 255); - mGreenSlider->setWidth(160); + mGreenSlider->setWidth(200); mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); @@ -121,7 +137,7 @@ Setup_Colors::Setup_Colors() : mBlueText->setEnabled(false); mBlueSlider = new Slider(0, 255); - mBlueSlider->setWidth(160); + mBlueSlider->setWidth(200); mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); mBlueSlider->addActionListener(this); @@ -138,15 +154,18 @@ Setup_Colors::Setup_Colors() : place(0, 7, mGradTypeLabel, 2); place(2, 7, mGradTypeSlider); place(3, 7, mGradTypeText); - 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); + place(0, 8, mGradDelayLabel, 2); + place(2, 8, mGradDelaySlider); + place(3, 8, mGradDelayText); + place(0, 9, mRedLabel, 2); + place(2, 9, mRedSlider); + place(3, 9, mRedText).setPadding(1); + place(0, 10, mGreenLabel, 2); + place(2, 10, mGreenSlider); + place(3, 10, mGreenText).setPadding(1); + place(0, 11, mBlueLabel, 2); + place(2, 11, mBlueSlider); + place(3, 11, mBlueText).setPadding(1); setDimension(gcn::Rectangle(0, 0, 325, 280)); } @@ -167,9 +186,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 +320,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 +339,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 +387,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 +396,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 +422,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 +444,9 @@ void Setup_Colors::updateColor() Palette::ColorType type = guiPalette->getColorTypeAt(mSelected); Palette::GradientType grad = static_cast((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; -- cgit v1.2.3-70-g09d2 From 5f00b25ba2895704123eb3d01b3ab5d012d2f333 Mon Sep 17 00:00:00 2001 From: Tametomo Date: Wed, 15 Apr 2009 19:55:29 +0200 Subject: Some PopupMenu cleanups/fixes and additions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tametomo Signed-off-by: Bjørn Lindeijer --- src/engine.cpp | 4 ++++ src/floor_item.cpp | 5 +++++ src/floor_item.h | 6 ++++++ src/gui/popupmenu.cpp | 42 +++++++++++++++++++++++++----------------- src/gui/viewport.cpp | 9 +++++++-- src/gui/viewport.h | 6 ++++++ src/monster.cpp | 21 +++++++++------------ src/net/ea/playerhandler.cpp | 1 + 8 files changed, 63 insertions(+), 31 deletions(-) (limited to 'src/gui') diff --git a/src/engine.cpp b/src/engine.cpp index 95f2cb1b..61293339 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) 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 @@ -63,6 +63,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. */ diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index e8af3122..ef1990f8 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -78,13 +78,13 @@ 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->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 +109,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 +123,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 +137,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 +150,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 +188,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 +229,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(being)); - } /* // Follow Player action else if (link == "follow") @@ -244,10 +244,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 +290,23 @@ 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(being)); + } + + else if (link == "name" && being) + { + chatWindow->addInputText(being->getName()); + } + else if (link == "admin-kick" && being && (being->getType() == Being::PLAYER || @@ -308,7 +316,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/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 @@ -108,6 +108,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. */ 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 &sprites = info.getSprites(); for (std::list::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 &particleEffects = info.getParticleEffects(); - for ( std::list::const_iterator i = particleEffects.begin(); - i != particleEffects.end(); i++ - ) + for (std::list::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; -- cgit v1.2.3-70-g09d2 From dcca13ea04fd7aa9b1539c1325cd0e465f9b545a Mon Sep 17 00:00:00 2001 From: Tametomo Date: Sat, 11 Apr 2009 09:36:44 -0600 Subject: Fixed the width of the gradient type label for the Setup Color tab, as well as moving the delay slider down. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tametomo Signed-off-by: Bjørn Lindeijer --- src/gui/setup_colors.cpp | 51 ++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 80c425e5..f68c6afe 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -79,6 +79,17 @@ 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(); @@ -89,7 +100,7 @@ Setup_Colors::Setup_Colors() : mGradDelayText->setEnabled(false); mGradDelaySlider = new Slider(20, 400); - mGradDelaySlider->setWidth(200); + mGradDelaySlider->setWidth(180); mGradDelaySlider->setValue(mGradDelayText->getValue()); mGradDelaySlider->setActionEventId("slider_graddelay"); mGradDelaySlider->addActionListener(this); @@ -105,7 +116,7 @@ Setup_Colors::Setup_Colors() : mRedText->setEnabled(false); mRedSlider = new Slider(0, 255); - mRedSlider->setWidth(200); + mRedSlider->setWidth(180); mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); @@ -121,7 +132,7 @@ Setup_Colors::Setup_Colors() : mGreenText->setEnabled(false); mGreenSlider = new Slider(0, 255); - mGreenSlider->setWidth(200); + mGreenSlider->setWidth(180); mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); @@ -137,7 +148,7 @@ Setup_Colors::Setup_Colors() : mBlueText->setEnabled(false); mBlueSlider = new Slider(0, 255); - mBlueSlider->setWidth(200); + mBlueSlider->setWidth(180); mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); mBlueSlider->addActionListener(this); @@ -149,23 +160,25 @@ 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(0, 8, mGradDelayLabel, 2); - place(2, 8, mGradDelaySlider); - place(3, 8, mGradDelayText); - place(0, 9, mRedLabel, 2); - place(2, 9, mRedSlider); - place(3, 9, mRedText).setPadding(1); - place(0, 10, mGreenLabel, 2); - place(2, 10, mGreenSlider); - place(3, 10, mGreenText).setPadding(1); - place(0, 11, mBlueLabel, 2); - place(2, 11, mBlueSlider); - place(3, 11, mBlueText).setPadding(1); + place(3, 7, mGradTypeText, 2).setPadding(1); + 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); + place(0, 11, mGradDelayLabel, 2); + place(2, 11, mGradDelaySlider); + place(3, 11, mGradDelayText).setPadding(1); + + mGradTypeText->setCaption(""); setDimension(gcn::Rectangle(0, 0, 325, 280)); } -- cgit v1.2.3-70-g09d2 From 717ad68ead37d5b28e06f1e5624bae5b73231f37 Mon Sep 17 00:00:00 2001 From: Tametomo Date: Wed, 15 Apr 2009 20:13:51 +0200 Subject: Only notify the user that they will need to change maps for changing whether or not to display particle effects when in game, since they don't need to see it beforehand. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tametomo Signed-off-by: Bjørn Lindeijer --- src/gui/setup_video.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gui') 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") { -- cgit v1.2.3-70-g09d2 From 55a161c970903237539c61d8584a4270dbfa3624 Mon Sep 17 00:00:00 2001 From: Tametomo Date: Sat, 11 Apr 2009 15:39:33 -0600 Subject: Reduced maximum gradient delay to 100. 400 was just too high of an upper bound to be useful to users. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tametomo Signed-off-by: Bjørn Lindeijer --- src/gui/setup_colors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index f68c6afe..352338e9 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -94,12 +94,12 @@ Setup_Colors::Setup_Colors() : mGradDelayText = new TextField(); mGradDelayText->setWidth(40); - mGradDelayText->setRange(20, 400); + mGradDelayText->setRange(20, 100); mGradDelayText->setNumeric(true); mGradDelayText->addListener(this); mGradDelayText->setEnabled(false); - mGradDelaySlider = new Slider(20, 400); + mGradDelaySlider = new Slider(20, 100); mGradDelaySlider->setWidth(180); mGradDelaySlider->setValue(mGradDelayText->getValue()); mGradDelaySlider->setActionEventId("slider_graddelay"); -- cgit v1.2.3-70-g09d2 From 3d85a00ff2a33e22ba63d0b7dfc156d8076933e1 Mon Sep 17 00:00:00 2001 From: Tametomo Date: Wed, 15 Apr 2009 20:36:46 +0200 Subject: Trim out (npc) tag from NPC names in PopupMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generally, it's good to tack on this tag onto nearly everything, but for popup options, it looks a tad tacky. Signed-off-by: Tametomo Signed-off-by: Bjørn Lindeijer --- src/gui/popupmenu.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index ef1990f8..5142482f 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -78,7 +78,10 @@ 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->getName(); + const std::string &name = being->getType() == Being::NPC ? + being->getName().substr(0, being->getName().size() + - 6) : being->getName(); + switch (being->getType()) { case Being::PLAYER: @@ -304,7 +307,10 @@ void PopupMenu::handleLink(const std::string &link) else if (link == "name" && being) { - chatWindow->addInputText(being->getName()); + 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" && -- cgit v1.2.3-70-g09d2