diff --git a/src/libprojectM/MilkdropPresetFactory.cpp b/src/libprojectM/MilkdropPresetFactory.cpp index a6a402522..62413ac4a 100644 --- a/src/libprojectM/MilkdropPresetFactory.cpp +++ b/src/libprojectM/MilkdropPresetFactory.cpp @@ -23,13 +23,26 @@ #include "MilkdropPresetFactory.hpp" +#include "BuiltinFuncs.hpp" +#include "Eval.hpp" + +MilkdropPresetFactory::MilkdropPresetFactory(int gx, int gy) { + /* Initializes the builtin function database */ + BuiltinFuncs::init_builtin_func_db(); + + /* Initializes all infix operators */ + Eval::init_infix_ops(); -MilkdropPresetFactory::MilkdropPresetFactory(int gx, int gy) -{ _presetOutputs.Initialize(gx,gy); + } -MilkdropPresetFactory::~MilkdropPresetFactory() {} +MilkdropPresetFactory::~MilkdropPresetFactory() { + + Eval::destroy_infix_ops(); + BuiltinFuncs::destroy_builtin_func_db(); + +} std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { _presetOutputs.customWaves.clear(); diff --git a/src/libprojectM/PresetLoader.cpp b/src/libprojectM/PresetLoader.cpp index fcc1592fa..2c5bd02a3 100644 --- a/src/libprojectM/PresetLoader.cpp +++ b/src/libprojectM/PresetLoader.cpp @@ -35,8 +35,9 @@ extern "C" #include "Common.hpp" -PresetLoader::PresetLoader ( std::string dirname = std::string() ) :_dirname ( dirname ), _dir ( 0 ), _ratingsSum ( 0 ) +PresetLoader::PresetLoader (int gx, int gy, std::string dirname = std::string()) :_dirname ( dirname ), _dir ( 0 ), _ratingsSum ( 0 ) { + _presetFactoryManager.initialize(gx,gy); // Do one scan if ( _dirname != std::string() ) rescan(); diff --git a/src/libprojectM/PresetLoader.hpp b/src/libprojectM/PresetLoader.hpp index f7aada366..0eb07ec11 100644 --- a/src/libprojectM/PresetLoader.hpp +++ b/src/libprojectM/PresetLoader.hpp @@ -28,7 +28,7 @@ class PresetLoader { public: /// Initializes the preset loader with the target directory specified - PresetLoader(std::string dirname); + PresetLoader(int gx, int gy, std::string dirname); ~PresetLoader(); diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index 1e7a60fd3..be85b8b69 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -40,24 +40,16 @@ //#include #include #include "projectM.hpp" -#include "BuiltinFuncs.hpp" #include "BeatDetect.hpp" -#include "Eval.hpp" -#include "Param.hpp" -#include "Parser.hpp" #include "Preset.hpp" -#include "PerPixelEqn.hpp" #include "PresetMerge.hpp" //#include "menu.h" #include "PCM.hpp" //Sound data handler (buffering, FFT, etc.) -#include "CustomWave.hpp" -#include "CustomShape.hpp" #include "IdlePreset.hpp" #include #include "Renderer.hpp" -#include "PresetFrameIO.hpp" #include "PresetChooser.hpp" #include "ConfigFile.h" #include "TextureManager.hpp" @@ -65,16 +57,6 @@ #ifdef USE_THREADS #include "pthread.h" #endif -/* -DLLEXPORT projectM::projectM ( int gx, int gy, int fps, int texsize, int width, int height, std::string preset_url,std::string title_fonturl, std::string title_menuurl ) :beatDetect ( 0 ), renderer ( 0 ), settings.presetURL ( preset_url ), title_fontURL ( title_fonturl ), menu_fontURL ( menu_fontURL ), smoothFrame ( 0 ), m_presetQueuePos(0) -{ - presetURL = preset_url; - projectM_reset(); - projectM_init ( gx, gy, fps, texsize, width, height ); - projectM_resetGL ( width, height ); -} -*/ - projectM::~projectM() { @@ -463,7 +445,7 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, renderer->SetPipeline(presetOutputs); running = true; - initPresetTools(); + initPresetTools(gx, gy); #ifdef USE_THREADS pthread_mutex_init(&mutex, NULL); @@ -682,21 +664,15 @@ DLLEXPORT void projectM::projectM_setTitle ( std::string title ) } -int projectM::initPresetTools() +int projectM::initPresetTools(int gx, int gy) { - /* Initializes the builtin function database */ - BuiltinFuncs::init_builtin_func_db(); - - /* Initializes all infix operators */ - Eval::init_infix_ops(); - /* Set the seed to the current time in seconds */ srand ( time ( NULL ) ); std::string url = (m_flags & FLAG_DISABLE_PLAYLIST_LOAD) ? std::string() : settings().presetURL; - if ( ( m_presetLoader = new PresetLoader ( url) ) == 0 ) + if ( ( m_presetLoader = new PresetLoader ( gx, gy, url) ) == 0 ) { m_presetLoader = 0; std::cerr << "[projectM] error allocating preset loader" << std::endl; @@ -766,9 +742,6 @@ void projectM::destroyPresetTools() /// @slow might not be necessary m_presetLoader = 0; - Eval::destroy_infix_ops(); - BuiltinFuncs::destroy_builtin_func_db(); - } /// @bug queuePreset case isn't handled diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index e36c5d3be..99900ae20 100755 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -274,7 +274,7 @@ private: void projectM_initengine(); void projectM_resetengine(); /// Initializes preset loading / management libraries - int initPresetTools(); + int initPresetTools(int gx, int gy); /// Deinitialize all preset related tools. Usually done before projectM cleanup void destroyPresetTools();