Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game
diff options
context:
space:
mode:
Diffstat (limited to 'source/game')
-rw-r--r--source/game/StarAnimation.cpp9
-rw-r--r--source/game/StarAnimation.hpp5
-rw-r--r--source/game/StarDrawable.cpp2
-rw-r--r--source/game/StarParticle.cpp20
-rw-r--r--source/game/StarParticle.hpp6
-rw-r--r--source/game/items/StarArmors.cpp2
6 files changed, 23 insertions, 21 deletions
diff --git a/source/game/StarAnimation.cpp b/source/game/StarAnimation.cpp
index be13975..7f3847c 100644
--- a/source/game/StarAnimation.cpp
+++ b/source/game/StarAnimation.cpp
@@ -43,14 +43,10 @@ void Animation::setAngle(float angle) {
m_angle = angle;
}
-void Animation::setProcessing(String processing) {
+void Animation::setProcessing(Directives processing) {
m_processing = move(processing);
}
-void Animation::addProcessing(String const& processing) {
- m_processing = String::joinWith("?", m_processing, processing);
-}
-
void Animation::setColor(Color color) {
m_color = color;
}
@@ -73,9 +69,8 @@ Drawable Animation::drawable(float pixelSize) const {
if (m_appendFrame)
baseFrame += ":" + toString(m_frame);
- baseFrame = String::joinWith("?", baseFrame, m_processing);
-
Drawable drawable = Drawable::makeImage(move(baseFrame), pixelSize, m_centered, m_offset);
+ drawable.imagePart().addDirectives(m_processing);
drawable.rotate(m_angle);
drawable.color = m_color;
return drawable;
diff --git a/source/game/StarAnimation.hpp b/source/game/StarAnimation.hpp
index 1294fd0..e4a2ece 100644
--- a/source/game/StarAnimation.hpp
+++ b/source/game/StarAnimation.hpp
@@ -15,8 +15,7 @@ public:
void setAngle(float angle);
- void setProcessing(String processing);
- void addProcessing(String const& processing);
+ void setProcessing(Directives processing);
void setColor(Color color);
@@ -44,7 +43,7 @@ private:
float m_angle;
Vec2F m_offset;
bool m_centered;
- String m_processing;
+ Directives m_processing;
Color m_color;
int m_variantOffset;
diff --git a/source/game/StarDrawable.cpp b/source/game/StarDrawable.cpp
index e259aa2..aeb8cb6 100644
--- a/source/game/StarDrawable.cpp
+++ b/source/game/StarDrawable.cpp
@@ -10,7 +10,7 @@
namespace Star {
Drawable::ImagePart& Drawable::ImagePart::addDirectives(Directives const& directives, bool keepImageCenterPosition) {
- if (!directives.entries || directives.entries->empty())
+ if (!directives)
return *this;
if (keepImageCenterPosition) {
diff --git a/source/game/StarParticle.cpp b/source/game/StarParticle.cpp
index 250b2a4..ad0c168 100644
--- a/source/game/StarParticle.cpp
+++ b/source/game/StarParticle.cpp
@@ -45,7 +45,6 @@ Particle::Particle() {
trail = false;
flippable = true;
flip = false;
- directives = "";
}
Particle::Particle(Json const& config, String const& path) {
@@ -69,6 +68,12 @@ Particle::Particle(Json const& config, String const& path) {
if (type == Type::Animated)
initializeAnimation();
+ auto pathEnd = string.find('?');
+ if (pathEnd == NPos)
+ directives = "";
+ else
+ directives.parse(string.substr(pathEnd));
+
if (config.contains("color"))
color = jsonToColor(config.get("color"));
@@ -96,9 +101,11 @@ Particle::Particle(Json const& config, String const& path) {
length = config.getFloat("length", 10.0f);
destructionAction = DestructionActionNames.getLeft(config.getString("destructionAction", "None"));
- destructionImage = config.getString("destructionImage", "");
+ String destructionImagePath = config.getString("destructionImage", "");
if (destructionAction == DestructionAction::Image)
- destructionImage = AssetPath::relativeTo(path, destructionImage);
+ destructionImagePath = AssetPath::relativeTo(path, destructionImagePath);
+ destructionImage = destructionImagePath;
+
destructionTime = config.getFloat("destructionTime", 0.0f);
timeToLive = config.getFloat("timeToLive", 0.0f);
@@ -113,7 +120,6 @@ Particle::Particle(Json const& config, String const& path) {
ignoreWind = config.getBool("ignoreWind", true);
trail = config.getBool("trail", false);
- directives = "";
}
Json Particle::toJson() const {
@@ -134,7 +140,7 @@ Json Particle::toJson() const {
{"angularVelocity", angularVelocity * 180.0f / Constants::pi},
{"length", length},
{"destructionAction", DestructionActionNames.getRight(destructionAction)},
- {"destructionImage", destructionImage},
+ {"destructionImage", AssetPath::join(destructionImage)},
{"destructionTime", destructionTime},
{"timeToLive", timeToLive},
{"layer", LayerNames.getRight(layer)},
@@ -221,7 +227,7 @@ void Particle::destructionUpdate() {
size = 1.0f;
color = Color::White;
type = Particle::Type::Textured;
- string = destructionImage;
+ image = destructionImage;
angularVelocity = 0.0f;
length = 0.0f;
rotation = 0.0f;
@@ -232,7 +238,7 @@ void Particle::destructionUpdate() {
void Particle::initializeAnimation() {
if (!animation) {
animation = Animation(AssetPath::removeDirectives(string));
- animation->addProcessing(AssetPath::getDirectives(string));
+ animation->setProcessing(directives);
}
}
diff --git a/source/game/StarParticle.hpp b/source/game/StarParticle.hpp
index 5dba0fa..b35cb0a 100644
--- a/source/game/StarParticle.hpp
+++ b/source/game/StarParticle.hpp
@@ -5,6 +5,7 @@
#include "StarColor.hpp"
#include "StarBiMap.hpp"
#include "StarAnimation.hpp"
+#include "StarAssetPath.hpp"
namespace Star {
@@ -75,6 +76,8 @@ struct Particle {
// Used differently depending on the type of the particle.
String string;
+ AssetPath image;
+ Directives directives;
Color color;
Color light;
@@ -95,7 +98,7 @@ struct Particle {
float length;
DestructionAction destructionAction;
- String destructionImage;
+ AssetPath destructionImage;
float destructionTime;
float timeToLive;
@@ -110,7 +113,6 @@ struct Particle {
bool trail;
Maybe<Animation> animation;
- String directives;
};
DataStream& operator<<(DataStream& ds, Particle const& particle);
diff --git a/source/game/items/StarArmors.cpp b/source/game/items/StarArmors.cpp
index 883f3b2..71f95a2 100644
--- a/source/game/items/StarArmors.cpp
+++ b/source/game/items/StarArmors.cpp
@@ -21,7 +21,7 @@ ArmorItem::ArmorItem(Json const& config, String const& directory, Json const& da
m_directives = instanceValue("directives", "").toString();
m_colorOptions = colorDirectivesFromConfig(config.getArray("colorOptions", JsonArray{""}));
- if (!m_directives.entries || m_directives.entries->empty())
+ if (!m_directives)
m_directives = "?" + m_colorOptions.wrap(instanceValue("colorIndex", 0).toUInt());
refreshIconDrawables();