diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 127 | ||||
-rw-r--r-- | src/gui/browserbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/gui.cpp | 2 | ||||
-rw-r--r-- | src/gui/status.cpp | 44 | ||||
-rw-r--r-- | src/properties.h | 84 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 115 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 4 | ||||
-rw-r--r-- | src/sprite.h | 65 |
8 files changed, 230 insertions, 213 deletions
diff --git a/src/game.cpp b/src/game.cpp index 8d5d0cf8..8c1eee60 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -470,43 +470,44 @@ void do_input() // Keyboard events (for discontinuous keys) if (event.type == SDL_KEYDOWN) { + gcn::Window *requestedWindow = NULL; + switch (event.key.keysym.sym) { - // In-game Help case SDLK_F1: - if (helpWindow->isVisible()) { + // In-game Help + if (helpWindow->isVisible()) + { helpWindow->setVisible(false); - } else { + } + else + { helpWindow->loadHelp("index"); - if (helpWindow->isVisible()) helpWindow->requestMoveToTop(); + helpWindow->requestMoveToTop(); } used = true; break; - // Player sit action - case SDLK_F5: - if (!action_time) { - break; - } - - switch (player_node->action) - { - case Being::STAND: - action(2, 0); - break; - case Being::SIT: - action(3, 0); - break; - } + case SDLK_F2: requestedWindow = statusWindow; break; + case SDLK_F3: requestedWindow = inventoryWindow; break; + case SDLK_F4: requestedWindow = equipmentWindow; break; + case SDLK_F5: requestedWindow = skillDialog; break; + case SDLK_F6: requestedWindow = minimap; break; + case SDLK_F7: requestedWindow = chatWindow; break; + //case SDLK_F8: requestedWindow = buddyWindow; break; + + case SDLK_F9: + // Setup window + setupWindow->setVisible(true); + setupWindow->requestMoveToTop(); + used = true; break; - // Display path to mouse (debug purpose) - case SDLK_F6: - displayPathToMouse = !displayPathToMouse; - break; + case SDLK_F10: requestedWindow = debugWindow; break; + //case SDLK_F11: requestedWindow = newSkillWindow; break; - // Input chat window case SDLK_RETURN: + // Input chat window if (chatWindow->isFocused() || deathNotice != NULL || weightNotice != NULL) @@ -592,62 +593,37 @@ void do_input() break; } + if (requestedWindow) + { + requestedWindow->setVisible(!requestedWindow->isVisible()); + if (requestedWindow->isVisible()) + { + requestedWindow->requestMoveToTop(); + } + used = true; + } + // Keys pressed together with Alt/Meta // Emotions and some internal gui windows if (event.key.keysym.mod & KMOD_ALT) { - gcn::Window *requestedWindow = 0; - switch (event.key.keysym.sym) { - // Inventory window - case SDLK_i: - requestedWindow = inventoryWindow; - break; - - // Statistics window case SDLK_s: - requestedWindow = statusWindow; - break; - - // Skill window - case SDLK_k: - requestedWindow = skillDialog; - break; - - // Equipment window - case SDLK_e: - requestedWindow = equipmentWindow; - break; - - /* - // Buddy window - case SDLK_b: - requestedWindow = buddyWindow; - break; - */ - - /* - // New skills window - case SDLK_n: - requestedWindow = newSkillWindow; - break; - */ - - // Setup window - case SDLK_c: - setupWindow->setVisible(true); - setupWindow->requestMoveToTop(); - used = true; - break; + // Player sit action + if (!action_time) { + break; + } - // Debug window - case SDLK_d: - requestedWindow = debugWindow; + switch (player_node->action) + { + case Being::STAND: action(2, 0); break; + case Being::SIT: action(3, 0); break; + } break; - // screenshot (picture, hence the p) case SDLK_p: + // Screenshot (picture, hence the p) { SDL_Surface *screenshot = graphics->getScreenshot(); if (!saveScreenshot(screenshot)) @@ -660,16 +636,11 @@ void do_input() default: break; - } - if (requestedWindow) - { - requestedWindow->setVisible(!requestedWindow->isVisible()); - if (requestedWindow->isVisible()) - { - requestedWindow->requestMoveToTop(); - } - used = true; + case SDLK_f: + // Find path to mouse (debug purpose) + displayPathToMouse = !displayPathToMouse; + break; } // Emotions diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 973f9251..a4d418e0 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -58,7 +58,7 @@ BrowserBox::BrowserBox(unsigned int mode): " abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567" "89:@!\"$%&/=?^+*#[]{}()<>_;'.,\\|-~`" - "øåáÁéÉíÍóÓúÚç_¥£¢¡¿àãõêñÑöüäÖÜÄß"); + "øåáÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄß"); } else #endif { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index c01c05c8..60a1e0da 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -140,7 +140,7 @@ Gui::Gui(Graphics *graphics): speechFont = new gcn::ImageFont("graphics/gui/rpgfont_wider.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" - "áÁéÉíÍóÓúÚç_¥£¢¡¿àãõêñÑöüäÖÜÄßø" + "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßø" ); } catch (gcn::Exception e) diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 1ba09b98..f5302e95 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -66,21 +66,26 @@ StatusWindow::StatusWindow(): gpLabel->setPosition(lvlLabel->getX() + lvlLabel->getWidth() + 40, 3); hpLabel->setPosition(5, lvlLabel->getY() + lvlLabel->getHeight() + 5); hpBar = new ProgressBar(1.0f, - hpLabel->getX() + hpLabel->getWidth() + 5, hpLabel->getY(), 80, - 15, 0, 171, 34); - hpValueLabel->setPosition(hpBar->getX() + hpBar->getWidth() + 5, hpBar->getY()); - mpLabel->setPosition(5,hpLabel->getY() + hpLabel->getHeight() + 5); - mpBar = new ProgressBar(1.0f, hpBar->getX(), - mpLabel->getY(), 80, 15, 26, 102, 230); + hpLabel->getX() + hpLabel->getWidth() + 5, + hpLabel->getY(), 80, 15, 0, 171, 34); + hpValueLabel->setPosition(hpBar->getX() + hpBar->getWidth() + 5, + hpBar->getY()); + mpLabel->setPosition(5, hpLabel->getY() + hpLabel->getHeight() + 5); + mpBar = new ProgressBar(1.0f, + hpBar->getX(), + mpLabel->getY(), 80, 15, 26, 102, 230); mpValueLabel->setPosition(hpValueLabel->getX(), mpBar->getY()); xpLabel->setPosition(175, hpLabel->getY()); xpBar = new ProgressBar(1.0f, 205, xpLabel->getY(), 80, 15, - 143, 192, 211); + 143, 192, 211); xpValueLabel->setPosition(290, xpBar->getY()); jobXpLabel->setPosition(175, mpLabel->getY()); - jobXpBar = new ProgressBar(1.0f, 225, jobXpLabel->getY(), 60, 15, - 220, 135, 203); + jobXpBar = new ProgressBar(1.0f, + xpBar->getX() + xpBar->getWidth() - 60, + jobXpLabel->getY(), + 60, 15, + 220, 135, 203); jobValueLabel->setPosition(290, jobXpBar->getY()); add(lvlLabel); @@ -145,17 +150,22 @@ StatusWindow::StatusWindow(): statsButton[4]->setEventId("DEX"); statsButton[5]->setEventId("LUK"); + // Set position statsTitleLabel->setPosition(mpLabel->getX(), mpLabel->getY() + 23 ); statsTotalLabel->setPosition(110, statsTitleLabel->getY() + 15); - statsCostLabel->setPosition(170, statsTotalLabel->getY()); + int totalLabelY = statsTotalLabel->getY(); + statsCostLabel->setPosition(170, totalLabelY); + for (int i = 0; i < 6; i++) { statsLabel[i]->setPosition(5, statsTotalLabel->getY() + (i * 23) + 15); - statsDisplayLabel[i]->setPosition(115, statsTotalLabel->getY() + (i * 23) + 15); - statsButton[i]->setPosition(145, statsTotalLabel->getY() + (i * 23) + 10); - pointsLabel[i]->setPosition(175, statsTotalLabel->getY() + (i * 23) + 15); + statsDisplayLabel[i]->setPosition(115, + totalLabelY + (i * 23) + 15); + statsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10); + pointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15); } + remainingStatsPointsLabel->setPosition(5, pointsLabel[5]->getY() + 25); statsAttackLabel->setPosition(220, statsLabel[0]->getY()); @@ -342,7 +352,7 @@ void StatusWindow::update() updateText.str(""); updateText << "Remaining Status Points: " << statusPoints; - + pointsStr[0] << (int)player_info->STRUp; pointsStr[1] << (int)player_info->AGIUp; pointsStr[2] << (int)player_info->VITUp; @@ -415,7 +425,8 @@ void StatusWindow::update() statsReflexPoints->adjustSize(); // Update Second column widgets position - gpLabel->setPosition(lvlLabel->getX() + lvlLabel->getWidth() + 20, lvlLabel->getY()); + gpLabel->setPosition(lvlLabel->getX() + lvlLabel->getWidth() + 20, + lvlLabel->getY()); xpLabel->setPosition(hpValueLabel->getX() + hpValueLabel->getWidth() + 10, hpLabel->getY()); @@ -425,7 +436,8 @@ void StatusWindow::update() xpLabel->getY()); jobXpLabel->setPosition(xpLabel->getX(), mpLabel->getY()); - jobXpBar->setPosition(xpBar->getX(),jobXpLabel->getY()); + jobXpBar->setPosition(xpBar->getX() + xpBar->getWidth() - + jobXpBar->getWidth(), jobXpLabel->getY()); jobValueLabel->setPosition(290, jobXpLabel->getY()); } diff --git a/src/properties.h b/src/properties.h new file mode 100644 index 00000000..ccf8cd00 --- /dev/null +++ b/src/properties.h @@ -0,0 +1,84 @@ +/* + * 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 + * + * $Id$ + */ + +#ifndef _TMW_PROPERTIES_H_ +#define _TMW_PROPERTIES_H_ + +#include <map> +#include <string> + +/** + * A class holding a set of properties. + */ +class Properties +{ + public: + virtual + ~Properties() {} + + /** + * Get a map property. + * + * @return the value of the given property or an empty string when it + * doesn't exist. + */ + const std::string& + getProperty(const std::string &name) + { + const static std::string undefined = ""; + std::map<std::string, std::string>::const_iterator i = + properties.find(name); + + if (i != properties.end()) + { + return (*i).second; + } + else + { + return undefined; + } + } + + /** + * Returns whether a certain property is available. + */ + bool + hasProperty(const std::string &name) + { + return (properties.find(name) != properties.end()); + } + + /** + * Set a map property. + */ + void + setProperty(const std::string &name, const std::string &value) + { + properties[name] = value; + } + + private: + std::map<std::string, std::string> properties; +}; + +#endif diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp deleted file mode 100644 index 69090dcb..00000000 --- a/src/resources/iteminfo.cpp +++ /dev/null @@ -1,115 +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 - * - * $Id$ - */ - -#include "iteminfo.h" - -ItemInfo::ItemInfo() : - image(0), name(""), - description(""), type(0), - weight(0), slot(0) -{ -} - -ItemInfo::~ItemInfo() -{ -} - -void ItemInfo::setImage(short image) -{ - this->image = image; -} - -short ItemInfo::getImage() -{ - return image; -} - -void ItemInfo::setArt(short art) -{ - this->art = art; -} - -short ItemInfo::getArt() -{ - return art; -} - -void ItemInfo::setName(const std::string &name) -{ - this->name = name; -} - -std::string ItemInfo::getName() -{ - return name; -} - -void ItemInfo::setDescription(const std::string &description) -{ - this->description = description; -} - -std::string ItemInfo::getDescription() -{ - return description; -} - -void ItemInfo::setEffect(const std::string &effect) -{ - this->effect = effect; -} - -std::string ItemInfo::getEffect() -{ - return effect; -} - -void ItemInfo::setType(short type) -{ - this->type = type; -} - -short ItemInfo::getType() -{ - return type; -} - -void ItemInfo::setWeight(short weight) -{ - this->weight = weight; -} - -short ItemInfo::getWeight() -{ - return weight; -} - -void ItemInfo::setSlot(char slot) -{ - this->slot = slot; -} - -char ItemInfo::getSlot() -{ - return slot; -} diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index c515fd1c..54e7907b 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_ITEMINFO_H -#define _TMW_ITEMINFO_H +#ifndef _TMW_ITEMINFO_H_ +#define _TMW_ITEMINFO_H_ #include <string> diff --git a/src/sprite.h b/src/sprite.h new file mode 100644 index 00000000..2950f4e8 --- /dev/null +++ b/src/sprite.h @@ -0,0 +1,65 @@ +/* + * 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 + * + * $Id$ + */ + +#ifndef _TMW_SPRITE_H_ +#define _TMW_SPRITE_H_ + +class Graphics; + +/** + * A sprite is some visible object on a map. This abstract class defines the + * interface used by the map to sort and display the sprite. + */ +class Sprite +{ + public: + /** + * Destructor. + */ + virtual + ~Sprite() {} + + /** + * Draws the sprite to the given graphics context. + * + * Note: this function could be simplified if the graphics context + * would support setting a translation offset. It already does this + * partly with the clipping rectangle support. + */ + virtual void + draw(Graphics *graphics, int offsetX, int offsetY) = 0; + + /** + * Returns the pixel Y coordinate of the sprite. + */ + virtual int + getPixelY() const = 0; + + protected: + /** + * Constructor. + */ + Sprite() {} +}; + +#endif |