| 9 | namespace Star { |
| 10 | |
| 11 | Animation::Animation(Json config, String const& directory) { |
| 12 | m_directory = directory; |
| 13 | if (m_directory.empty()) { |
| 14 | if (config.isType(Json::Type::String)) |
| 15 | m_directory = AssetPath::directory(config.toString()); |
| 16 | else |
| 17 | m_directory = "/"; |
| 18 | } |
| 19 | if (config.isNull()) |
| 20 | config = JsonObject(); |
| 21 | |
| 22 | config = Root::singleton().assets()->fetchJson(config); |
| 23 | |
| 24 | m_mode = AnimationModeNames.getLeft(config.getString("mode", "endAndDisappear")); |
| 25 | m_base = config.getString("frames", ""); |
| 26 | // If the base image has no index tag, then assume that the frame is appended |
| 27 | // to the end. |
| 28 | m_appendFrame = !m_base.contains("<index>"); |
| 29 | m_frameNumber = config.getInt("frameNumber", 1); |
| 30 | m_animationCycle = config.getFloat("animationCycle", 1.0); |
| 31 | m_animationTime = m_animationCycle * config.getFloat("loops", 1.0); |
| 32 | m_angle = config.getFloat("angle", 0.0f); |
| 33 | m_offset = jsonToVec2F(config.get("offset", JsonArray{0.0f, 0.0f})); |
| 34 | m_centered = config.getBool("centered", true); |
| 35 | m_processing = config.getString("processing", ""); |
| 36 | m_color = config.opt("color").apply(jsonToColor).value(Color::White); |
| 37 | m_variantOffset = Random::randInt(config.getInt("variants", 1) - 1) * m_frameNumber; |
| 38 | |
| 39 | reset(); |
| 40 | } |
| 41 | |
| 42 | void Animation::setAngle(float angle) { |
| 43 | m_angle = angle; |
nothing calls this directly
no test coverage detected