Planeshift

eeditpartlisttoolbox.h

Go to the documentation of this file.
00001 /*
00002  * Author: Jorrit Tyberghein
00003  *
00004  * Copyright (C) 2010 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef EEDIT_PARTICLES_TOOLBOX_HEADER
00021 #define EEDIT_PARTICLES_TOOLBOX_HEADER
00022 
00023 #include "eedittoolbox.h"
00024 #include "paws/pawswidget.h"
00025 #include "paws/pawsspinbox.h"
00026 #include "paws/pawscombo.h"
00027 #include "paws/pawscheckbox.h"
00028 #include "paws/pawscrollbar.h"
00029 
00030 #include <csutil/weakref.h>
00031 #include <imesh/particles.h>
00032 
00033 class pawsButton;
00034 class pawsListBox;
00035 struct iEngine;
00036 struct iParticleEmitter;
00037 struct iParticleEffector;
00038 struct iMeshObjectFactory;
00039 struct ParticleParameterRow;
00040 
00045 struct ParameterData
00046 {
00047   csString type;
00048   csString text;
00049   csStringArray choices;
00050   float spinbox_min, spinbox_max, spinbox_step;
00051   ParameterData (csString type, float spinbox_min = 0, float spinbox_max = 1, float spinbox_step = .1) : 
00052     type (type), spinbox_min (spinbox_min), spinbox_max (spinbox_max), spinbox_step (spinbox_step)
00053   { }
00054 };
00055 
00056 
00059 class EEditParticleListToolbox : public EEditToolbox, public pawsWidget, public scfImplementation0<EEditParticleListToolbox>
00060 {
00061 public:
00062     EEditParticleListToolbox();
00064     EEditParticleListToolbox(const EEditParticleListToolbox& origin);
00065     virtual ~EEditParticleListToolbox();
00066 
00069     void FillList(iEngine* engine);
00070     void RefreshEditList();
00071     void FillParmList(iMeshObjectFactory* fact);
00072     void FillParmList(iParticleEmitter* emit);
00073     void FillParmList(iParticleEffector* eff);
00074     void RefreshParmList();
00075 
00076     void CreateNewEmit (const char* string);
00077     void CreateNewEffect (const char* string);
00078 
00079     // inheritted from EEditToolbox
00080     virtual void Update(unsigned int elapsed);
00081     virtual size_t GetType() const;
00082     virtual const char * GetName() const;
00083 
00084     // inheritted from pawsWidget
00085     virtual bool PostSetup(); 
00086     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00087     virtual bool OnButtonReleased( int button, int keyModifier, pawsWidget* widget);
00088     virtual void OnListAction(pawsListBox* selected, int status);
00089     virtual bool OnChange(pawsWidget* widget);
00090     virtual bool OnScroll(int dir, pawsScrollBar* widget);
00091     
00092 private:
00093     // used by pawsListBox to sort the listbox
00094     static int SortTextBox(pawsWidget * widgetA, pawsWidget * widgetB);
00095 
00096     void HideValues ();
00097     void ClearParmList ();
00098     void UpdateParticleValue();
00099     void SaveParticleSystem (const csString& name);
00100     void ReloadParticleSystem (const csString& name);
00101 
00102     csArray<iParticleEmitter*> emitters;
00103     csArray<iParticleEffector*> effectors;
00104     csRef<iEngine> engine;
00105 
00106     int updatingParticleValue;
00107     csWeakRef<iParticleSystemFactory> pfact;
00108     csWeakRef<iMeshObjectFactory> objectFactory;
00109 
00110 public:
00111     csPDelArray<ParticleParameterRow> parameterRows;
00112 
00113     pawsListBox  * partList;
00114     pawsListBox  * editList;
00115     pawsListBox  * parmList;
00116     pawsListBox  * valueList;
00117     pawsButton   * openPartButton;
00118     pawsButton   * refreshButton;
00119     pawsButton   * saveButton;
00120     pawsButton   * reloadButton;
00121     pawsSpinBox  * valueNumSpinBox;
00122     pawsSpinBox  * value2NumSpinBox;
00123     pawsSpinBox  * value3NumSpinBox;
00124     pawsComboBox * valueChoices;
00125     pawsCheckBox * valueBool;
00126     pawsCheckBox * valueBool2;
00127     pawsCheckBox * valueBool3;
00128     pawsCheckBox * valueBool4;
00129     pawsCheckBox * valueBool5;
00130     pawsScrollBar* valueScroll1;
00131     pawsScrollBar* valueScroll2;
00132     pawsScrollBar* valueScroll3;
00133     pawsScrollBar* valueScroll4;
00134     pawsButton   * addParButton;
00135     pawsButton   * delParButton;
00136     pawsButton   * addEmitButton;
00137     pawsButton   * addEffectorButton;
00138     pawsButton   * delEEButton;
00139 };
00140 
00141 CREATE_PAWS_FACTORY(EEditParticleListToolbox);
00142 
00145 #endif