summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/animation.h2
-rw-r--r--src/resources/image.cpp25
-rw-r--r--src/resources/mapreader.cpp24
-rw-r--r--src/resources/monsterdb.cpp21
-rw-r--r--src/resources/monsterinfo.h14
5 files changed, 72 insertions, 14 deletions
diff --git a/src/resources/animation.h b/src/resources/animation.h
index d0d11c69..aad93cda 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -54,7 +54,7 @@ class Animation
Animation();
/**
- * Appends a new animation at the end of the sequence
+ * Appends a new animation at the end of the sequence.
*/
void
addFrame(Image *image, unsigned int delay, int offsetX, int offsetY);
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index a27783d4..d7d4e64b 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -187,19 +187,22 @@ Image* Image::load(void *buffer, unsigned int bufferSize,
bool hasAlpha = false;
- // Figure out whether the image uses its alpha layer
- for (int i = 0; i < tmpImage->w * tmpImage->h; ++i)
+ if (tmpImage->format->BitsPerPixel == 32)
{
- Uint8 r, g, b, a;
- SDL_GetRGBA(
- ((Uint32*) tmpImage->pixels)[i],
- tmpImage->format,
- &r, &g, &b, &a);
-
- if (a != 255)
+ // Figure out whether the image uses its alpha layer
+ for (int i = 0; i < tmpImage->w * tmpImage->h; ++i)
{
- hasAlpha = true;
- break;
+ Uint8 r, g, b, a;
+ SDL_GetRGBA(
+ ((Uint32*) tmpImage->pixels)[i],
+ tmpImage->format,
+ &r, &g, &b, &a);
+
+ if (a != 255)
+ {
+ hasAlpha = true;
+ break;
+ }
}
}
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index fda8916d..2230cb6a 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -231,6 +231,30 @@ MapReader::readMap(xmlNodePtr node, const std::string &path)
{
readProperties(childNode, map);
}
+ else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup"))
+ {
+ for_each_xml_child_node(objectNode, childNode)
+ {
+ if (xmlStrEqual(objectNode->name, BAD_CAST "object"))
+ {
+ std::string objName = XML::getProperty(objectNode, "name", "");
+ std::string objType = XML::getProperty(objectNode, "type", "");
+ int objX = XML::getProperty(objectNode, "x", 0);
+ int objY = XML::getProperty(objectNode, "y", 0);
+
+ logger->log("- Loading object name: %s type: %s at %d:%d",
+ objName.c_str(), objType.c_str(), objX, objY);
+ if (objType == "PARTICLE_EFFECT")
+ {
+ map->addParticleEffect(objName, objX, objY);
+ }
+ else
+ {
+ logger->log(" Warning: Unknown object type");
+ }
+ }
+ }
+ }
}
map->initializeOverlays();
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index ac3ac3bc..89afc549 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -83,6 +83,27 @@ MonsterDB::load()
currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed"));
+ std::string targetCursor;
+ targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
+ if (targetCursor == "small")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_SMALL);
+ }
+ else if (targetCursor == "medium")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ }
+ else if (targetCursor == "large")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_LARGE);
+ }
+ else
+ {
+ logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s - using medium sized one",
+ targetCursor.c_str(), currentInfo->getName().c_str());
+ currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ }
+
//iterate <sprite>s and <sound>s
for_each_xml_child_node(spriteNode, monsterNode)
{
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
index 05d4c014..d2a0a2c8 100644
--- a/src/resources/monsterinfo.h
+++ b/src/resources/monsterinfo.h
@@ -28,6 +28,9 @@
#include <string>
#include <vector>
+#include "../being.h"
+
+
enum SoundEvent
{
EVENT_HIT,
@@ -62,7 +65,11 @@ class MonsterInfo
setSprite(std::string filename) { mSprite = filename; }
void
- addSound (SoundEvent event, std::string filename);
+ setTargetCursorSize(Being::TargetCursorSize targetCursorSize)
+ { mTargetCursorSize = targetCursorSize; }
+
+ void
+ addSound(SoundEvent event, std::string filename);
const std::string&
getName () const { return mName; };
@@ -70,13 +77,16 @@ class MonsterInfo
const std::string&
getSprite () const { return mSprite; };
+ const Being::TargetCursorSize
+ getTargetCursorSize() const { return mTargetCursorSize; }
+
std::string
getSound (SoundEvent event) const;
private:
std::string mName;
std::string mSprite;
-
+ Being::TargetCursorSize mTargetCursorSize;
std::map<SoundEvent, std::vector<std::string>* > mSounds;
};