diff --git a/source/game/CMakeLists.txt b/source/game/CMakeLists.txt index c7399b1..1ff95ff 100644 --- a/source/game/CMakeLists.txt +++ b/source/game/CMakeLists.txt @@ -38,7 +38,6 @@ SET (star_game_HEADERS StarDamageManager.hpp StarDamageTypes.hpp StarDanceDatabase.hpp - StarDirectives.hpp StarDrawable.hpp StarDungeonGenerator.hpp StarDungeonImagePart.hpp @@ -297,7 +296,6 @@ SET (star_game_SOURCES StarDamageManager.cpp StarDamageTypes.cpp StarDanceDatabase.cpp - StarDirectives.cpp StarDrawable.cpp StarDungeonGenerator.cpp StarDungeonImagePart.cpp diff --git a/source/game/StarDirectives.cpp b/source/game/StarDirectives.cpp deleted file mode 100644 index 4dc661d..0000000 --- a/source/game/StarDirectives.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "StarImage.hpp" -#include "StarImageProcessing.hpp" -#include "StarDirectives.hpp" - -namespace Star { - -NestedDirectives::NestedDirectives() {} -NestedDirectives::NestedDirectives(String const& string) : m_root{ Leaf{ parseImageOperations(string), string} } {} - -void NestedDirectives::addBranch(const Branch& newBranch) { - convertToBranches(); - - m_root.value.get().emplace_back(newBranch); -} - -String NestedDirectives::toString() const { - String string; - buildString(string, m_root); - return string; -} - -void NestedDirectives::forEach() const { - -} - -Image NestedDirectives::apply(Image& image) const { - Image current = image; - - return current; -} - -void NestedDirectives::buildString(String& string, const Cell& cell) const { - if (auto leaf = cell.value.ptr()) - string += leaf->string; - else { - for (auto& branch : cell.value.get()) - buildString(string, *branch); - } -} - -void NestedDirectives::convertToBranches() { - if (m_root.value.is()) - return; - - Leaf& leaf = m_root.value.get(); - Branches newBranches; - newBranches.emplace_back(std::make_shared(move(leaf))); - m_root.value = move(newBranches); -} - -} \ No newline at end of file diff --git a/source/game/StarDirectives.hpp b/source/game/StarDirectives.hpp deleted file mode 100644 index 3540ee1..0000000 --- a/source/game/StarDirectives.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef STAR_DIRECTIVES_HPP -#define STAR_DIRECTIVES_HPP - -#include "StarImageProcessing.hpp" - -namespace Star { - -STAR_CLASS(NestedDirectives); - -// Attempt at reducing memory allocation and per-frame string parsing for extremely long directives -class NestedDirectives { -public: - struct Leaf { - List operations; - String string; - }; - - struct Cell; - typedef std::shared_ptr Branch; - typedef List Branches; - - struct Cell { - Variant value; - - Cell() : value(Leaf()) {}; - Cell(Leaf&& leaf) : value(move(leaf)) {}; - Cell(Branches&& branches) : value(move(branches)) {}; - Cell(const Leaf& leaf) : value(leaf) {}; - Cell(const Branches& branches) : value(branches) {}; - }; - - - NestedDirectives(); - NestedDirectives(String const& string); - - void addBranch(const Branch& newBranch); - const Branch& branch() const; - String toString() const; - void forEach() const; - Image apply(Image& image) const; -private: - void buildString(String& string, const Cell& cell) const; - void convertToBranches(); - - Cell m_root; -}; - -} - -#endif