Commit abde0f51b3062c158fb52e9dfff23d21d3be03d1
- Diff rendering mode:
- inline
- side by side
|   | |||
| 3 | 3 | error.xml | |
| 4 | 4 | ) | |
| 5 | 5 | ||
| 6 | INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/sprits) | ||
| 6 | INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/sprites) |
src/being.cpp
(2 / 1)
|   | |||
| 1022 | 1022 | // we can go. | |
| 1023 | 1023 | int hairstyles = 1; | |
| 1024 | 1024 | ||
| 1025 | while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) != "error.xml") | ||
| 1025 | while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) != | ||
| 1026 | paths.getValue("spriteErrorFile", "error.xml")) | ||
| 1026 | 1027 | hairstyles++; | |
| 1027 | 1028 | ||
| 1028 | 1029 | mNumberOfHairstyles = hairstyles; |
src/being.h
(7 / 1)
|   | |||
| 113 | 113 | /** | |
| 114 | 114 | * Directions, to be used as bitmask values | |
| 115 | 115 | */ | |
| 116 | enum { DOWN = 1, LEFT = 2, UP = 4, RIGHT = 8 }; | ||
| 116 | enum BeingDirection | ||
| 117 | { | ||
| 118 | DOWN = 1, | ||
| 119 | LEFT = 2, | ||
| 120 | UP = 4, | ||
| 121 | RIGHT = 8 | ||
| 122 | }; | ||
| 117 | 123 | ||
| 118 | 124 | /** | |
| 119 | 125 | * Constructor. |
src/client.cpp
(4 / 0)
|   | |||
| 109 | 109 | ||
| 110 | 110 | Configuration config; /**< XML file configuration reader */ | |
| 111 | 111 | Configuration branding; /**< XML branding information reader */ | |
| 112 | Configuration paths; /**< XML default paths information reader */ | ||
| 112 | 113 | Logger *logger; /**< Log object */ | |
| 113 | 114 | KeyboardConfig keyboard; | |
| 114 | 115 | ||
| … | … | ||
| 727 | 727 | "zip", | |
| 728 | 728 | false); | |
| 729 | 729 | } | |
| 730 | |||
| 731 | // Read default paths file 'data/paths.xml' | ||
| 732 | paths.init("paths.xml", true); | ||
| 730 | 733 | ||
| 731 | 734 | // Load XML databases | |
| 732 | 735 | ColorDB::load(); |
src/configuration.cpp
(11 / 14)
|   | |||
| 137 | 137 | } | |
| 138 | 138 | } | |
| 139 | 139 | ||
| 140 | void Configuration::init(const std::string &filename) | ||
| 140 | void Configuration::init(const std::string &filename, bool useResManager) | ||
| 141 | 141 | { | |
| 142 | mConfigPath = filename; | ||
| 142 | XML::Document doc(filename, useResManager); | ||
| 143 | 143 | ||
| 144 | // Do not attempt to read config from non-existant file | ||
| 145 | FILE *testFile = fopen(filename.c_str(), "r"); | ||
| 146 | if (!testFile) | ||
| 144 | if (!doc.rootNode()) | ||
| 145 | { | ||
| 146 | logger->log("Couldn't open configuration file: %s", filename.c_str()); | ||
| 147 | 147 | return; | |
| 148 | } | ||
| 149 | |||
| 150 | if (useResManager) | ||
| 151 | mConfigPath = "PhysFS://" + filename; | ||
| 148 | 152 | else | |
| 149 | fclose(testFile); | ||
| 153 | mConfigPath = filename; | ||
| 150 | 154 | ||
| 151 | xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0); | ||
| 155 | xmlNodePtr rootNode = doc.rootNode(); | ||
| 152 | 156 | ||
| 153 | if (!doc) return; | ||
| 154 | |||
| 155 | xmlNodePtr rootNode = xmlDocGetRootElement(doc); | ||
| 156 | |||
| 157 | 157 | if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) | |
| 158 | 158 | { | |
| 159 | 159 | logger->log("Warning: No configuration file (%s)", filename.c_str()); | |
| 160 | xmlFreeDoc(doc); | ||
| 161 | 160 | return; | |
| 162 | 161 | } | |
| 163 | 162 | ||
| 164 | 163 | initFromXML(rootNode); | |
| 165 | |||
| 166 | xmlFreeDoc(doc); | ||
| 167 | 164 | } | |
| 168 | 165 | ||
| 169 | 166 | void ConfigurationObject::writeToXML(xmlTextWriterPtr writer) |
src/configuration.h
(5 / 3)
|   | |||
| 197 | 197 | /** | |
| 198 | 198 | * Reads config file and parse all options into memory. | |
| 199 | 199 | * | |
| 200 | * \param filename path to config file | ||
| 200 | * @param filename path to config file | ||
| 201 | * @param useResManager Make use of the resource manager. | ||
| 201 | 202 | */ | |
| 202 | void init(const std::string &filename); | ||
| 203 | void init(const std::string &filename, bool useResManager = false); | ||
| 203 | 204 | ||
| 204 | 205 | /** | |
| 205 | 206 | * Writes the current settings back to the config file. | |
| … | … | ||
| 245 | 245 | typedef ListenerMap::iterator ListenerMapIterator; | |
| 246 | 246 | ListenerMap mListenerMap; | |
| 247 | 247 | ||
| 248 | std::string mConfigPath; /**< Location of config file */ | ||
| 248 | std::string mConfigPath; /**< Location of config file */ | ||
| 249 | 249 | }; | |
| 250 | 250 | ||
| 251 | 251 | extern Configuration branding; | |
| 252 | 252 | extern Configuration config; | |
| 253 | extern Configuration paths; | ||
| 253 | 254 | ||
| 254 | 255 | #endif |
src/game.cpp
(2 / 1)
|   | |||
| 928 | 928 | ||
| 929 | 929 | mMapName = mapPath; | |
| 930 | 930 | ||
| 931 | std::string fullMap = "maps/" + mapPath + ".tmx"; | ||
| 931 | std::string fullMap = paths.getValue("maps", "maps/") | ||
| 932 | + mMapName + ".tmx"; | ||
| 932 | 933 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 933 | 934 | if (!resman->exists(fullMap)) | |
| 934 | 935 | fullMap += ".gz"; |
src/gui/gui.cpp
(1 / 0)
|   | |||
| 107 | 107 | const int fontSize = (int) config.getValue("fontSize", 11); | |
| 108 | 108 | std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf"); | |
| 109 | 109 | std::string path = resman->getPath(fontFile); | |
| 110 | |||
| 110 | 111 | try | |
| 111 | 112 | { | |
| 112 | 113 | mGuiFont = new TrueTypeFont(path, fontSize); |
src/gui/help.cpp
(5 / 1)
|   | |||
| 29 | 29 | #include "gui/widgets/scrollarea.h" | |
| 30 | 30 | ||
| 31 | 31 | #include "resources/resourcemanager.h" | |
| 32 | #include "configuration.h" | ||
| 32 | 33 | ||
| 33 | 34 | #include "utils/gettext.h" | |
| 34 | 35 | ||
| … | … | ||
| 94 | 94 | void HelpWindow::loadFile(const std::string &file) | |
| 95 | 95 | { | |
| 96 | 96 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 97 | std::string helpPath = branding.getValue("helpPath", ""); | ||
| 98 | if (helpPath.empty()) | ||
| 99 | helpPath = paths.getValue("help", "help/"); | ||
| 97 | 100 | std::vector<std::string> lines = | |
| 98 | resman->loadTextFile("help/" + file + ".txt"); | ||
| 101 | resman->loadTextFile(helpPath + file + ".txt"); | ||
| 99 | 102 | ||
| 100 | 103 | for (unsigned int i = 0; i < lines.size(); ++i) | |
| 101 | 104 | { |
src/gui/itempopup.cpp
(3 / 1)
|   | |||
| 102 | 102 | if (showImage) | |
| 103 | 103 | { | |
| 104 | 104 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 105 | Image *image = resman->getImage("graphics/items/" + item.getImageName()); | ||
| 105 | Image *image = resman->getImage( | ||
| 106 | paths.getValue("itemIcons", "graphics/items/") | ||
| 107 | + item.getImageName()); | ||
| 106 | 108 | mIcon->setImage(image); | |
| 107 | 109 | if (image) | |
| 108 | 110 | { |
src/gui/theme.cpp
(21 / 9)
|   | |||
| 40 | 40 | ||
| 41 | 41 | #include <algorithm> | |
| 42 | 42 | ||
| 43 | #define GUI_ROOT "graphics/gui/" | ||
| 44 | |||
| 43 | static std::string defaultThemePath; | ||
| 45 | 44 | std::string Theme::mThemePath; | |
| 46 | 45 | Theme *Theme::mInstance = 0; | |
| 47 | 46 | ||
| 47 | // Set the theme path... | ||
| 48 | static void initDefaultThemePath() | ||
| 49 | { | ||
| 50 | ResourceManager *resman = ResourceManager::getInstance(); | ||
| 51 | defaultThemePath = branding.getValue("guiThemePath", ""); | ||
| 52 | |||
| 53 | if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath)) | ||
| 54 | return; | ||
| 55 | else | ||
| 56 | defaultThemePath = "graphics/gui/"; | ||
| 57 | } | ||
| 58 | |||
| 48 | 59 | Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, | |
| 49 | 60 | const std::string &filePath, | |
| 50 | 61 | const std::string &name): | |
| … | … | ||
| 66 | 66 | mCloseImage(close), | |
| 67 | 67 | mStickyImageUp(stickyUp), | |
| 68 | 68 | mStickyImageDown(stickyDown) | |
| 69 | { | ||
| 70 | } | ||
| 69 | {} | ||
| 71 | 70 | ||
| 72 | 71 | Skin::~Skin() | |
| 73 | 72 | { | |
| … | … | ||
| 109 | 109 | mMinimumOpacity(-1.0f), | |
| 110 | 110 | mProgressColors(ProgressColors(THEME_PROG_END)) | |
| 111 | 111 | { | |
| 112 | initDefaultThemePath(); | ||
| 113 | |||
| 112 | 114 | config.addListener("guialpha", this); | |
| 113 | 115 | loadColors(); | |
| 114 | 116 | ||
| … | … | ||
| 325 | 325 | { | |
| 326 | 326 | if (!themePath.empty()) | |
| 327 | 327 | { | |
| 328 | themePath = GUI_ROOT + themePath; | ||
| 328 | themePath = defaultThemePath + themePath; | ||
| 329 | 329 | if (PHYSFS_exists(themePath.c_str())) | |
| 330 | 330 | { | |
| 331 | 331 | mThemePath = themePath; | |
| … | … | ||
| 343 | 343 | // Try theme from branding | |
| 344 | 344 | if (!tryThemePath(branding.getValue("theme", ""))) | |
| 345 | 345 | // Use default | |
| 346 | mThemePath = GUI_ROOT; | ||
| 346 | mThemePath = defaultThemePath; | ||
| 347 | 347 | ||
| 348 | 348 | instance()->loadColors(mThemePath); | |
| 349 | 349 | } | |
| … | … | ||
| 368 | 368 | return getThemePath() + "/" + path; | |
| 369 | 369 | ||
| 370 | 370 | // Backup | |
| 371 | return std::string(GUI_ROOT) + "/" + path; | ||
| 371 | return std::string(defaultThemePath) + "/" + path; | ||
| 372 | 372 | } | |
| 373 | 373 | ||
| 374 | 374 | Image *Theme::getImageFromTheme(const std::string &path) | |
| … | … | ||
| 520 | 520 | ||
| 521 | 521 | void Theme::loadColors(std::string file) | |
| 522 | 522 | { | |
| 523 | if (file == GUI_ROOT) | ||
| 523 | if (file == defaultThemePath) | ||
| 524 | 524 | return; // No need to reload | |
| 525 | 525 | ||
| 526 | 526 | if (file == "") | |
| 527 | file = GUI_ROOT; | ||
| 527 | file = defaultThemePath; | ||
| 528 | 528 | ||
| 529 | 529 | file += "/colors.xml"; | |
| 530 | 530 |
src/item.cpp
(8 / 3)
|   | |||
| 26 | 26 | #include "resources/image.h" | |
| 27 | 27 | #include "resources/iteminfo.h" | |
| 28 | 28 | #include "resources/resourcemanager.h" | |
| 29 | #include "configuration.h" | ||
| 29 | 30 | ||
| 30 | 31 | Item::Item(int id, int quantity, bool equipment, bool equipped): | |
| 31 | 32 | mImage(0), | |
| … | … | ||
| 58 | 58 | mDrawImage->decRef(); | |
| 59 | 59 | ||
| 60 | 60 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 61 | std::string imagePath = "graphics/items/" + getInfo().getImageName(); | ||
| 61 | std::string imagePath = paths.getValue("itemIcons", "graphics/items/") | ||
| 62 | + getInfo().getImageName(); | ||
| 62 | 63 | mImage = resman->getImage(imagePath); | |
| 63 | 64 | mDrawImage = resman->getImage(imagePath); | |
| 64 | 65 | ||
| 65 | 66 | if (!mImage) | |
| 66 | mImage = Theme::getImageFromTheme("unknown-item.png"); | ||
| 67 | mImage = Theme::getImageFromTheme(paths.getValue("unknownItemFile", | ||
| 68 | "unknown-item.png")); | ||
| 67 | 69 | ||
| 68 | 70 | if (!mDrawImage) | |
| 69 | mDrawImage = Theme::getImageFromTheme("unknown-item.png"); | ||
| 71 | mDrawImage = Theme::getImageFromTheme( | ||
| 72 | paths.getValue("unknownItemFile", | ||
| 73 | "unknown-item.png")); | ||
| 70 | 74 | } |
src/localplayer.cpp
(1 / 3)
|   | |||
| 1035 | 1035 | sound.playSfx(soundFile); | |
| 1036 | 1036 | } | |
| 1037 | 1037 | else | |
| 1038 | { | ||
| 1039 | sound.playSfx("sfx/fist-swish.ogg"); | ||
| 1040 | } | ||
| 1038 | sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg")); | ||
| 1041 | 1039 | ||
| 1042 | 1040 | Net::getPlayerHandler()->attack(target->getId()); | |
| 1043 | 1041 | if ((Net::getNetworkType() == ServerInfo::TMWATHENA) && !keep) |
src/monster.cpp
(6 / 2)
|   | |||
| 34 | 34 | ||
| 35 | 35 | #include "resources/monsterdb.h" | |
| 36 | 36 | #include "resources/monsterinfo.h" | |
| 37 | #include "configuration.h" | ||
| 37 | 38 | ||
| 38 | 39 | Monster::Monster(int id, int subtype, Map *map): | |
| 39 | 40 | Being(id, subtype, map), | |
| … | … | ||
| 133 | 133 | for (std::list<std::string>::const_iterator i = sprites.begin(); | |
| 134 | 134 | i != sprites.end(); i++) | |
| 135 | 135 | { | |
| 136 | std::string file = "graphics/sprites/" + *i; | ||
| 136 | std::string file = paths.getValue("sprites", | ||
| 137 | "graphics/sprites/") + *i; | ||
| 137 | 138 | mSprites.push_back(AnimatedSprite::load(file)); | |
| 138 | 139 | } | |
| 139 | 140 | ||
| 140 | 141 | // Ensure that something is shown | |
| 141 | 142 | if (mSprites.size() == 0) | |
| 142 | 143 | { | |
| 143 | mSprites.push_back(AnimatedSprite::load("graphics/sprites/error.xml")); | ||
| 144 | mSprites.push_back(AnimatedSprite::load( | ||
| 145 | paths.getValue("sprites", "graphics/sprites/") + | ||
| 146 | paths.getValue("spriteErrorFile", "error.xml") )); | ||
| 144 | 147 | } | |
| 145 | 148 | ||
| 146 | 149 | if (Particle::enabled) |
|   | |||
| 232 | 232 | } | |
| 233 | 233 | if (speed) | |
| 234 | 234 | { | |
| 235 | /** | ||
| 235 | /* | ||
| 236 | 236 | * The being's speed is transfered in tiles per second * 10 | |
| 237 | 237 | * to keep it transferable in a Byte. | |
| 238 | 238 | * We set it back to tiles per second and in a float. |
|   | |||
| 29 | 29 | #include "log.h" | |
| 30 | 30 | #include "particle.h" | |
| 31 | 31 | #include "npc.h" | |
| 32 | #include "configuration.h" | ||
| 32 | 33 | ||
| 33 | 34 | #include "gui/chat.h" | |
| 34 | 35 | #include "gui/gui.h" | |
| … | … | ||
| 142 | 142 | player_node->setLevel(msg.readInt16()); | |
| 143 | 143 | player_node->setCharacterPoints(msg.readInt16()); | |
| 144 | 144 | player_node->setCorrectionPoints(msg.readInt16()); | |
| 145 | Particle* effect = particleEngine->addEffect("graphics/particles/levelup.particle.xml", 0, 0); | ||
| 145 | Particle* effect = particleEngine->addEffect( | ||
| 146 | paths.getValue("particles", "graphics/particles/") | ||
| 147 | + paths.getValue("levelUpEffectFile", "levelup.particle.xml"), | ||
| 148 | 0, 0); | ||
| 146 | 149 | player_node->controlParticle(effect); | |
| 147 | 150 | } break; | |
| 148 | 151 |
src/npc.cpp
(3 / 1)
|   | |||
| 36 | 36 | #include "net/npchandler.h" | |
| 37 | 37 | ||
| 38 | 38 | #include "resources/npcdb.h" | |
| 39 | #include "configuration.h" | ||
| 39 | 40 | ||
| 40 | 41 | NPC::NPC(int id, int subtype, Map *map): | |
| 41 | 42 | Player(id, subtype, map, true) | |
| … | … | ||
| 69 | 69 | i != info.sprites.end(); | |
| 70 | 70 | i++) | |
| 71 | 71 | { | |
| 72 | std::string file = "graphics/sprites/" + (*i)->sprite; | ||
| 72 | std::string file = paths.getValue("sprites", | ||
| 73 | "graphics/sprites/") + (*i)->sprite; | ||
| 73 | 74 | int variant = (*i)->variant; | |
| 74 | 75 | mSprites.push_back(AnimatedSprite::load(file, variant)); | |
| 75 | 76 | mSpriteIDs.push_back(0); |
src/player.cpp
(6 / 4)
|   | |||
| 118 | 118 | default: break; | |
| 119 | 119 | } | |
| 120 | 120 | Particle *p; | |
| 121 | p = particleEngine->addEffect("graphics/particles/" + | ||
| 122 | particleEffect, 0, 0, rotation); | ||
| 121 | p = particleEngine->addEffect( | ||
| 122 | paths.getValue("particles", | ||
| 123 | "graphics/particles/") | ||
| 124 | + particleEffect, 0, 0, rotation); | ||
| 123 | 125 | controlParticle(p); | |
| 124 | 126 | } | |
| 125 | 127 | ||
| … | … | ||
| 195 | 195 | if (!color.empty()) | |
| 196 | 196 | filename += "|" + color; | |
| 197 | 197 | ||
| 198 | equipmentSprite = AnimatedSprite::load("graphics/sprites/" + | ||
| 199 | filename); | ||
| 198 | equipmentSprite = AnimatedSprite::load( | ||
| 199 | paths.getValue("sprites", "graphics/sprites/") + filename); | ||
| 200 | 200 | } | |
| 201 | 201 | ||
| 202 | 202 | if (equipmentSprite) |
src/resources/emotedb.cpp
(7 / 3)
|   | |||
| 24 | 24 | #include "log.h" | |
| 25 | 25 | ||
| 26 | 26 | #include "utils/xml.h" | |
| 27 | #include "configuration.h" | ||
| 27 | 28 | ||
| 28 | 29 | namespace | |
| 29 | 30 | { | |
| … | … | ||
| 42 | 42 | mLastEmote = 0; | |
| 43 | 43 | ||
| 44 | 44 | EmoteSprite *unknownSprite = new EmoteSprite; | |
| 45 | unknownSprite->sprite = AnimatedSprite::load("error.xml"); | ||
| 45 | unknownSprite->sprite = AnimatedSprite::load( | ||
| 46 | paths.getValue("spriteErrorFile", "error.xml") ); | ||
| 46 | 47 | unknownSprite->name = "unknown"; | |
| 47 | 48 | mUnknown.sprites.push_back(unknownSprite); | |
| 48 | 49 | ||
| … | … | ||
| 78 | 78 | if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) | |
| 79 | 79 | { | |
| 80 | 80 | EmoteSprite *currentSprite = new EmoteSprite; | |
| 81 | std::string file = "graphics/sprites/" + (std::string) | ||
| 82 | (const char*) spriteNode->xmlChildrenNode->content; | ||
| 81 | std::string file = paths.getValue("sprites", | ||
| 82 | "graphics/sprites/") | ||
| 83 | + (std::string) (const char*) | ||
| 84 | spriteNode->xmlChildrenNode->content; | ||
| 83 | 85 | currentSprite->sprite = AnimatedSprite::load(file, | |
| 84 | 86 | XML::getProperty(spriteNode, "variant", 0)); | |
| 85 | 87 | currentInfo->sprites.push_back(currentSprite); |
src/resources/itemdb.cpp
(4 / 2)
|   | |||
| 30 | 30 | #include "utils/gettext.h" | |
| 31 | 31 | #include "utils/stringutils.h" | |
| 32 | 32 | #include "utils/xml.h" | |
| 33 | #include "configuration.h" | ||
| 33 | 34 | ||
| 34 | 35 | #include <libxml/tree.h> | |
| 35 | 36 | ||
| … | … | ||
| 116 | 116 | mUnknown = new ItemInfo; | |
| 117 | 117 | mUnknown->setName(_("Unknown item")); | |
| 118 | 118 | mUnknown->setImageName(""); | |
| 119 | mUnknown->setSprite("error.xml", GENDER_MALE); | ||
| 120 | mUnknown->setSprite("error.xml", GENDER_FEMALE); | ||
| 119 | std::string errFile = paths.getValue("spriteErrorFile", "error.xml"); | ||
| 120 | mUnknown->setSprite(errFile, GENDER_MALE); | ||
| 121 | mUnknown->setSprite(errFile, GENDER_FEMALE); | ||
| 121 | 122 | ||
| 122 | 123 | XML::Document doc("items.xml"); | |
| 123 | 124 | xmlNodePtr rootNode = doc.rootNode(); |
src/resources/iteminfo.cpp
(2 / 1)
|   | |||
| 22 | 22 | #include "resources/iteminfo.h" | |
| 23 | 23 | ||
| 24 | 24 | #include "resources/itemdb.h" | |
| 25 | #include "configuration.h" | ||
| 25 | 26 | ||
| 26 | 27 | const std::string &ItemInfo::getSprite(Gender gender) const | |
| 27 | 28 | { | |
| … | … | ||
| 69 | 69 | ||
| 70 | 70 | void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename) | |
| 71 | 71 | { | |
| 72 | mSounds[event].push_back("sfx/" + filename); | ||
| 72 | mSounds[event].push_back(paths.getValue("sfx", "sfx/") + filename); | ||
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | 75 | const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const |
src/resources/mapreader.cpp
(4 / 1)
|   | |||
| 323 | 323 | if (config.getValue("showWarps", 1)) | |
| 324 | 324 | { | |
| 325 | 325 | map->addParticleEffect( | |
| 326 | "graphics/particles/warparea.particle.xml", | ||
| 326 | paths.getValue("particles", | ||
| 327 | "graphics/particles/") | ||
| 328 | + paths.getValue("portalEffectFile", | ||
| 329 | "warparea.particle.xml"), | ||
| 327 | 330 | objX, objY, objW, objH); | |
| 328 | 331 | } | |
| 329 | 332 | } |
src/resources/monsterdb.cpp
(2 / 1)
|   | |||
| 30 | 30 | #include "utils/xml.h" | |
| 31 | 31 | ||
| 32 | 32 | #include "net/net.h" | |
| 33 | #include "configuration.h" | ||
| 33 | 34 | ||
| 34 | 35 | #define OLD_TMWATHENA_OFFSET 1002 | |
| 35 | 36 | ||
| … | … | ||
| 46 | 46 | if (mLoaded) | |
| 47 | 47 | unload(); | |
| 48 | 48 | ||
| 49 | mUnknown.addSprite("error.xml"); | ||
| 49 | mUnknown.addSprite(paths.getValue("spriteErrorFile", "error.xml")); | ||
| 50 | 50 | ||
| 51 | 51 | logger->log("Initializing monster database..."); | |
| 52 | 52 |
|   | |||
| 23 | 23 | ||
| 24 | 24 | #include "utils/dtor.h" | |
| 25 | 25 | #include "utils/gettext.h" | |
| 26 | #include "configuration.h" | ||
| 26 | 27 | ||
| 27 | 28 | MonsterInfo::MonsterInfo(): | |
| 28 | 29 | mName(_("unnamed")), | |
| … | … | ||
| 46 | 46 | mSounds[event] = new std::vector<std::string>; | |
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | mSounds[event]->push_back("sfx/" + filename); | ||
| 49 | mSounds[event]->push_back(paths.getValue("sfx", "sfx/") | ||
| 50 | + filename); | ||
| 50 | 51 | } | |
| 51 | 52 | ||
| 52 | 53 | const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const |
src/resources/npcdb.cpp
(3 / 1)
|   | |||
| 24 | 24 | #include "log.h" | |
| 25 | 25 | ||
| 26 | 26 | #include "utils/xml.h" | |
| 27 | #include "configuration.h" | ||
| 27 | 28 | ||
| 28 | 29 | namespace | |
| 29 | 30 | { | |
| … | … | ||
| 39 | 39 | unload(); | |
| 40 | 40 | ||
| 41 | 41 | NPCsprite *unknownSprite = new NPCsprite; | |
| 42 | unknownSprite->sprite = "error.xml"; | ||
| 42 | unknownSprite->sprite = paths.getValue("spriteErrorFile", | ||
| 43 | "error.xml"); | ||
| 43 | 44 | unknownSprite->variant = 0; | |
| 44 | 45 | mUnknown.sprites.push_back(unknownSprite); | |
| 45 | 46 |
src/resources/spritedef.cpp
(9 / 3)
|   | |||
| 30 | 30 | #include "resources/imageset.h" | |
| 31 | 31 | #include "resources/resourcemanager.h" | |
| 32 | 32 | ||
| 33 | #include "configuration.h" | ||
| 34 | |||
| 33 | 35 | #include "utils/xml.h" | |
| 34 | 36 | ||
| 35 | 37 | #include <set> | |
| … | … | ||
| 63 | 63 | { | |
| 64 | 64 | logger->log("Error, failed to parse %s", animationFile.c_str()); | |
| 65 | 65 | ||
| 66 | if (animationFile != "graphics/sprites/error.xml") | ||
| 66 | std::string errorFile = paths.getValue("sprites", "graphics/sprites") | ||
| 67 | + paths.getValue("spriteErrorFile", | ||
| 68 | "error.xml"); | ||
| 69 | if (animationFile != errorFile) | ||
| 67 | 70 | { | |
| 68 | return load("graphics/sprites/error.xml", 0); | ||
| 71 | return load(errorFile, 0); | ||
| 69 | 72 | } | |
| 70 | 73 | else | |
| 71 | 74 | { | |
| … | … | ||
| 283 | 283 | if (filename.empty()) | |
| 284 | 284 | return; | |
| 285 | 285 | ||
| 286 | XML::Document doc("graphics/sprites/" + filename); | ||
| 286 | XML::Document doc(paths.getValue("sprites", "graphics/sprites/") | ||
| 287 | + filename); | ||
| 287 | 288 | xmlNodePtr rootNode = doc.rootNode(); | |
| 288 | 289 | ||
| 289 | 290 | if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) |
src/resources/wallpaper.cpp
(39 / 7)
|   | |||
| 21 | 21 | ||
| 22 | 22 | #include "resources/wallpaper.h" | |
| 23 | 23 | ||
| 24 | #include "resources/resourcemanager.h" | ||
| 24 | 25 | #include "log.h" | |
| 25 | 26 | ||
| 26 | 27 | #include "utils/stringutils.h" | |
| 28 | #include "configuration.h" | ||
| 27 | 29 | ||
| 28 | 30 | #include <physfs.h> | |
| 29 | 31 | ||
| … | … | ||
| 34 | 34 | #include <time.h> | |
| 35 | 35 | #include <vector> | |
| 36 | 36 | ||
| 37 | #define WALLPAPER_FOLDER "graphics/images/" | ||
| 38 | #define WALLPAPER_BASE "login_wallpaper.png" | ||
| 39 | |||
| 40 | 37 | struct WallpaperData | |
| 41 | 38 | { | |
| 42 | 39 | std::string filename; | |
| … | … | ||
| 44 | 44 | static std::vector<WallpaperData> wallpaperData; | |
| 45 | 45 | static bool haveBackup; // Is the backup (no size given) version available? | |
| 46 | 46 | ||
| 47 | static std::string wallpaperPath; | ||
| 48 | static std::string wallpaperFile; | ||
| 49 | |||
| 50 | // Search for the wallpaper path values sequentially.. | ||
| 51 | static void initDefaultWallpaperPaths() | ||
| 52 | { | ||
| 53 | ResourceManager *resman = ResourceManager::getInstance(); | ||
| 54 | |||
| 55 | // Init the path | ||
| 56 | wallpaperPath = branding.getValue("wallpapersPath", ""); | ||
| 57 | |||
| 58 | if (!wallpaperPath.empty() && resman->isDirectory(wallpaperPath)) | ||
| 59 | return; | ||
| 60 | else | ||
| 61 | wallpaperPath = paths.getValue("wallpapers", ""); | ||
| 62 | |||
| 63 | if (wallpaperPath.empty() || !resman->isDirectory(wallpaperPath)) | ||
| 64 | wallpaperPath = "graphics/images/"; | ||
| 65 | |||
| 66 | // Init the default file | ||
| 67 | wallpaperFile = branding.getValue("wallpaperFile", ""); | ||
| 68 | |||
| 69 | if (!wallpaperFile.empty() && resman->isDirectory(wallpaperFile)) | ||
| 70 | return; | ||
| 71 | else | ||
| 72 | wallpaperFile = paths.getValue("wallpaperFile", ""); | ||
| 73 | |||
| 74 | if (wallpaperFile.empty() || !resman->isDirectory(wallpaperFile)) | ||
| 75 | wallpaperFile = "login_wallpaper.png"; | ||
| 76 | } | ||
| 77 | |||
| 47 | 78 | bool wallpaperCompare(WallpaperData a, WallpaperData b) | |
| 48 | 79 | { | |
| 49 | 80 | int aa = a.width * a.height; | |
| … | … | ||
| 87 | 87 | { | |
| 88 | 88 | wallpaperData.clear(); | |
| 89 | 89 | ||
| 90 | char **imgs = PHYSFS_enumerateFiles(WALLPAPER_FOLDER); | ||
| 90 | initDefaultWallpaperPaths(); | ||
| 91 | 91 | ||
| 92 | char **imgs = PHYSFS_enumerateFiles(wallpaperPath.c_str()); | ||
| 93 | |||
| 92 | 94 | for (char **i = imgs; *i != NULL; i++) | |
| 93 | 95 | { | |
| 94 | 96 | int width; | |
| 95 | 97 | int height; | |
| 96 | 98 | ||
| 97 | 99 | // If the backup file is found, we tell it. | |
| 98 | if (strncmp (*i, WALLPAPER_BASE, strlen(*i)) == 0) | ||
| 100 | if (strncmp (*i, wallpaperFile.c_str(), strlen(*i)) == 0) | ||
| 99 | 101 | haveBackup = true; | |
| 100 | 102 | ||
| 101 | 103 | // If the image format is terminated by: "_<width>x<height>.png" | |
| … | … | ||
| 118 | 118 | if (sscanf(*i, filename.c_str(), &width, &height) == 2) | |
| 119 | 119 | { | |
| 120 | 120 | WallpaperData wp; | |
| 121 | wp.filename = WALLPAPER_FOLDER; | ||
| 121 | wp.filename = wallpaperPath; | ||
| 122 | 122 | wp.filename.append(*i); | |
| 123 | 123 | wp.width = width; | |
| 124 | 124 | wp.height = height; | |
| … | … | ||
| 164 | 164 | ||
| 165 | 165 | // Return the backup file if everything else failed... | |
| 166 | 166 | if (haveBackup) | |
| 167 | return std::string(WALLPAPER_FOLDER WALLPAPER_BASE); | ||
| 167 | return std::string(wallpaperPath + wallpaperFile); | ||
| 168 | 168 | ||
| 169 | 169 | // Return an empty string if everything else failed | |
| 170 | 170 | return std::string(); |
src/resources/wallpaper.h
(1 / 1)
|   | |||
| 37 | 37 | static void loadWallpapers(); | |
| 38 | 38 | ||
| 39 | 39 | /** | |
| 40 | * Returns the larget wallpaper for the given resolution, or the | ||
| 40 | * Returns the largest wallpaper for the given resolution, or the | ||
| 41 | 41 | * default wallpaper if none are found. | |
| 42 | 42 | * | |
| 43 | 43 | * @param width the desired width |
src/sound.cpp
(7 / 2)
|   | |||
| 27 | 27 | #include "resources/resourcemanager.h" | |
| 28 | 28 | #include "resources/soundeffect.h" | |
| 29 | 29 | ||
| 30 | #include "configuration.h" | ||
| 31 | |||
| 30 | 32 | Sound::Sound(): | |
| 31 | 33 | mInstalled(false), | |
| 32 | 34 | mSfxVolume(100), | |
| … | … | ||
| 151 | 151 | // it to a temporary physical file so that SDL_mixer can stream it. | |
| 152 | 152 | logger->log("Loading music \"%s\" from temporary file tempMusic.ogg", | |
| 153 | 153 | path.c_str()); | |
| 154 | bool success = resman->copyFile("music/" + filename, "tempMusic.ogg"); | ||
| 154 | bool success = resman->copyFile( | ||
| 155 | paths.getValue("music", "music/") | ||
| 156 | + filename, "tempMusic.ogg"); | ||
| 155 | 157 | if (success) | |
| 156 | 158 | path = resman->getPath("tempMusic.ogg"); | |
| 157 | 159 | else | |
| … | … | ||
| 239 | 239 | return; | |
| 240 | 240 | ||
| 241 | 241 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 242 | SoundEffect *sample = resman->getSoundEffect(path); | ||
| 242 | SoundEffect *sample = resman->getSoundEffect( | ||
| 243 | paths.getValue("sfx", "sfx/") + path); | ||
| 243 | 244 | if (sample) | |
| 244 | 245 | { | |
| 245 | 246 | logger->log("Sound::playSfx() Playing: %s", path.c_str()); |
src/statuseffect.cpp
(4 / 3)
|   | |||
| 28 | 28 | ||
| 29 | 29 | #include "utils/xml.h" | |
| 30 | 30 | ||
| 31 | #include "configuration.h" | ||
| 32 | |||
| 31 | 33 | #include <map> | |
| 32 | 34 | ||
| 33 | 35 | #define STATUS_EFFECTS_FILE "status-effects.xml" | |
| … | … | ||
| 70 | 70 | else | |
| 71 | 71 | { | |
| 72 | 72 | AnimatedSprite *sprite = AnimatedSprite::load( | |
| 73 | "graphics/sprites/" + mIcon); | ||
| 73 | paths.getValue("sprites", "graphics/sprites/") + mIcon); | ||
| 74 | 74 | if (false && sprite) | |
| 75 | 75 | { | |
| 76 | 76 | sprite->play(ACTION_DEFAULT); | |
| … | … | ||
| 125 | 125 | ||
| 126 | 126 | if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects")) | |
| 127 | 127 | { | |
| 128 | logger->log("Error loading status effects file: " | ||
| 129 | STATUS_EFFECTS_FILE); | ||
| 128 | logger->log("Error loading status effects file: " STATUS_EFFECTS_FILE); | ||
| 130 | 129 | return; | |
| 131 | 130 | } | |
| 132 | 131 |

