diff --git a/src/projectM-engine/Preset.hpp b/src/projectM-engine/Preset.hpp index b8f007408..779cbb099 100644 --- a/src/projectM-engine/Preset.hpp +++ b/src/projectM-engine/Preset.hpp @@ -33,8 +33,6 @@ #include //#define PRESET_DEBUG 2 /* 0 for no debugging, 1 for normal, 2 for insane */ -#include "projectM.h" - #include "CustomShape.h" #include "CustomWave.h" #include "Expr.h" diff --git a/src/projectM-engine/PresetChooser.cpp b/src/projectM-engine/PresetChooser.cpp index cc4359fa8..b2397590e 100644 --- a/src/projectM-engine/PresetChooser.cpp +++ b/src/projectM-engine/PresetChooser.cpp @@ -12,5 +12,3 @@ #include "PresetChooser.hpp" - - diff --git a/src/projectM-engine/PresetChooser.hpp b/src/projectM-engine/PresetChooser.hpp index 6c7a9a347..34c5bbe8e 100644 --- a/src/projectM-engine/PresetChooser.hpp +++ b/src/projectM-engine/PresetChooser.hpp @@ -6,11 +6,13 @@ #ifndef PRESET_CHOOSER_HPP #define PRESET_CHOOSER_HPP -#include "Preset.hpp" -#include "projectM.h" -#include "PresetLoader.hpp" -#include +#include "Preset.hpp" + +#include "PresetLoader.hpp" + +#include +#include class PresetChooser { public: @@ -20,7 +22,7 @@ public: /// \note The preset loader is refreshed via events or otherwise outside this class's scope PresetChooser(const PresetLoader & presetLoader); - /// \brief A simple iterator class to traverse back and forth a preset directory + /// A simple iterator class to traverse back and forth a preset directory class PresetIterator { public: @@ -29,10 +31,10 @@ public: /** @brief Instantiate a preset iterator at the given starting position */ PresetIterator(std::size_t start); - /// \brief Move iterator forward + /// Move iterator forward void operator++(); - /// \brief Move iterator backword + /// Move iterator backword void operator--() ; bool operator !=(const PresetIterator & presetPos) const ; @@ -42,10 +44,10 @@ public: /// \brief Returns the indexing value used by the current iterator. std::size_t operator*() const; - /// \brief Allocate a new preset given this iterator's associated preset name + /// Allocate a new preset given this iterator's associated preset name std::auto_ptr allocate(const PresetInputs & presetInputs, PresetOutputs & presetOutputs); - /// \brief Set the chooser asocciated with this iterator + /// \ Set the chooser asocciated with this iterator void setChooser(const PresetChooser & chooser); private: @@ -134,7 +136,7 @@ inline bool PresetChooser::PresetIterator::operator !=(const PresetIterator & pr } inline std::auto_ptr PresetChooser::PresetIterator::allocate(const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { - return m_presetChooser->directoryIndex(m_currentIndex, presetInputs, presetOutputs); + return m_presetChooser->directoryIndex(m_currentIndex, presetInputs, presetOutputs); } inline float PresetChooser::UniformRandomFunctor::operator() (std::size_t index) const { diff --git a/src/projectM-engine/PresetLoader.cpp b/src/projectM-engine/PresetLoader.cpp index 19e906fda..1c94e52e8 100644 --- a/src/projectM-engine/PresetLoader.cpp +++ b/src/projectM-engine/PresetLoader.cpp @@ -10,6 +10,7 @@ // // #include "PresetLoader.hpp" +#include "Preset.hpp" #include #include extern "C" { diff --git a/src/projectM-engine/PresetLoader.hpp b/src/projectM-engine/PresetLoader.hpp index fead4ff0a..d9c731341 100644 --- a/src/projectM-engine/PresetLoader.hpp +++ b/src/projectM-engine/PresetLoader.hpp @@ -2,8 +2,14 @@ #define __PRESET_LOADER_HPP #include // used for path / filename stuff -#include "Preset.hpp" // used to allocate presets via loadDir + #include // for auto pointers +#include +#include +#include +class Preset; +class PresetInputs; +class PresetOutputs; class PresetLoader { public: @@ -11,11 +17,11 @@ class PresetLoader { static const std::string MILKDROP_FILE_EXTENSION; #ifdef LINUX - static const char PATH_SEPARTOR = '/'; + static const char PATH_SEPARATOR = '/'; #endif #ifdef MACOS - static const char PATH_SEPARTOR = '/'; + static const char PATH_SEPARATOR = '/'; #endif #ifdef WIN32 diff --git a/src/projectM-engine/console_interface.cpp b/src/projectM-engine/console_interface.cpp index f8a5d9552..2e44d7068 100755 --- a/src/projectM-engine/console_interface.cpp +++ b/src/projectM-engine/console_interface.cpp @@ -33,8 +33,6 @@ #include "BeatDetect.h" #include "PresetChooser.hpp" -PresetChooser::PresetIterator presetPos; -PresetChooser * activeChooser; interface_t current_interface;// = DEFAULT_INTERFACE; @@ -57,7 +55,7 @@ void refreshConsole() { break; default: break; - } + } } @@ -70,7 +68,7 @@ void projectM::key_handler( projectMEvent event, case PROJECTM_KEYDOWN: //default_key_handler(); - switch (current_interface) + switch (current_interface) { case MENU_INTERFACE: @@ -158,13 +156,13 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode case PROJECTM_K_n: // paranoia but could be useful if directory is empty /// @bug implement == operator - if (!(presetPos != activeChooser->end())) + if (!(m_presetPos != m_presetChooser->end())) return; - activeChooser->getNumPresets(); - ++presetPos; + m_presetChooser->getNumPresets(); + ++m_presetPos; /// @bug implement == operator - if (!(presetPos != activeChooser->end())) - --presetPos; + if (!(m_presetPos != m_presetChooser->end())) + --m_presetPos; break; case PROJECTM_K_r: // if (PresetSwitcher::switchPreset(RANDOM_NEXT, HARD_CUT) < 0) { @@ -173,8 +171,8 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode // } break; case PROJECTM_K_p: - if (presetPos != activeChooser->begin()) { - --presetPos; + if (m_presetPos != m_presetChooser->begin()) { + --m_presetPos; // ...mroe } diff --git a/src/projectM-engine/console_interface.h b/src/projectM-engine/console_interface.h index 5d077d2f6..ca9c5221d 100755 --- a/src/projectM-engine/console_interface.h +++ b/src/projectM-engine/console_interface.h @@ -32,7 +32,7 @@ void default_key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode); void refreshConsole(); #if defined(__CPLUSPLUS) && !defined(MACOS) -extern "C" void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier ); +xtern "C" void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier ); #else extern void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier ); #endif diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index f55c07bb7..cbf276b08 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -671,7 +671,10 @@ int projectM::initPresetTools() { m_presetChooser = 0; return PROJECTM_FAILURE; } - + + // Start the iterator + m_presetPos = m_presetChooser->begin(); + /* Done */ #ifdef PRESET_DEBUG printf("initPresetLoader: finished\n"); diff --git a/src/projectM-engine/projectM.h b/src/projectM-engine/projectM.h index d14564170..5641af053 100755 --- a/src/projectM-engine/projectM.h +++ b/src/projectM-engine/projectM.h @@ -71,14 +71,18 @@ //#include "Preset.hpp" #include "Renderer.hpp" +#include "PresetChooser.hpp" + //#include class BeatDetect; class Func; class Renderer; class Preset; -class PresetChooser; -class PresetLoader; + +class PresetLoader; +class PresetChooser; +#include //#include "SplayTree.hpp" #ifdef WIN32 @@ -238,12 +242,17 @@ public: int initPresetTools(); private: + // The current position of the directory iterator + PresetChooser::PresetIterator m_presetPos; + // Required by the preset chooser. Manages a loaded preset directory PresetLoader * m_presetLoader; // Provides accessor functions to choose presets PresetChooser * m_presetChooser; + // Currently loaded preset- will be fancier when smooth preset switching + std::auto_ptr m_activePreset; }; #endif /** !_PROJECTM_H */