Planeshift

eeditapp.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Robberts
00003  *
00004  * Copyright (C) 2004 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_APP_HEADER
00021 #define EEDIT_APP_HEADER
00022 
00023 #include <csutil/sysfunc.h>
00024 #include <csutil/csstring.h>
00025 #include <csutil/ref.h>
00026 #include <csutil/bitarray.h>
00027 #include <csgeom/vector2.h>
00028 #include <csgeom/vector3.h>
00029 
00030 #include "util/genericevent.h"
00031 
00032 struct iEngine;
00033 struct iLoader;
00034 struct iVFS;
00035 struct iEvent;
00036 struct iEventQueue;
00037 struct iConfigManager;
00038 struct iTextureManager;
00039 struct iGraphics3D;
00040 struct iGraphics2D;
00041 struct iView;
00042 struct iVirtualClock;
00043 struct iMeshWrapper;
00044 class csRandomFloatGen;
00045 
00046 class PawsManager;
00047 class pawsMainWidget;
00048 class pawsWidget;
00049 class pawsEEdit;
00050 
00051 class EEditReporter;
00052 class EEditToolboxManager;
00053 class EEditInputboxManager;
00054 
00055 class psEffectManager;
00056 class psCal3DCallbackLoader;
00057 
00058 class eControlManager;
00059 
00066 enum CAM_FLAG
00067 {
00068     CAM_NONE = 0,
00069     
00070     CAM_UP,
00071     CAM_RIGHT,
00072     CAM_DOWN,
00073     CAM_LEFT,
00074     CAM_FORWARD,
00075     CAM_BACK,
00076 
00077     CAM_COUNT
00078 };
00079 
00080 
00081 class EEditApp
00082 {
00083 public:
00084 
00085     static const char * CONFIG_FILENAME;
00086     static const char * APP_NAME;
00087     static const char * WINDOW_CAPTION;
00088     static const char * KEY_DEFS_FILENAME;
00089     static const char * TEMP_EFFECTS_LIST;
00090 
00094     EEditApp(iObjectRegistry * obj_reg, EEditReporter * _reporter);
00095 
00099     ~EEditApp();
00100 
00106     void SevereError(const char* msg);
00107 
00113     bool Init();
00114 
00122     bool LoadWidget(const char * file);
00123     
00129     bool LoadWidgets();
00130 
00134     PawsManager* GetPaws() { return paws; }
00135 
00136 
00142     bool HandleEvent (iEvent &event);
00143 
00147     void RefreshEffectList();
00148 
00152     bool UpdateEffect();
00153     
00160     bool RenderEffect(const csString &effectName);
00161 
00167     bool RenderCurrentEffect();
00168     
00174     bool ReloadCurrentEffect();
00175     
00181     bool TogglePauseEffect();
00182     
00188     bool CancelEffect();
00189 
00193     void CreateParticleSystem(const csString & name);
00194 
00201     bool ToggleToolbox(size_t toolbox);
00202 
00208     void ShowToolbox(size_t toolbox);
00209 
00215     void HideToolbox(size_t toolbox);
00216 
00223     bool IsToolboxVisible(size_t toolbox);
00224     
00230     EEditToolboxManager * GetToolboxManager();
00231   
00237     psEffectManager * GetEffectManager();
00238     
00244     EEditInputboxManager * GetInputboxManager();
00245     
00254     csPtr<iMeshWrapper> LoadCustomMesh(const csString & meshFile, const csString & name, csVector3 pos);
00255     
00262     bool LoadPositionMesh(const csString & meshFile);
00263 
00270     bool LoadTargetMesh(const csString & meshFile);
00271 
00277     void SetPositionAnim(size_t index);
00278     
00284     void SetTargetAnim(size_t index);
00285     
00292     void SetPositionData(const csVector3 & pos, float rot);
00293 
00300     void SetTargetData(const csVector3 & pos, float rot);
00301     
00308     void SetCamFlag(int flag, bool val);
00309 
00316     bool GetCamFlag(int flag);
00317 
00324     bool SetCurrEffect(const csString & name);
00325     
00331     csString GetCurrEffectName();
00332 
00338     csString GetCurrParticleSystemName();
00339 
00345     unsigned int GetCurrEffectID() { return currEffectID; }
00346 
00352     bool SetDefaultActorPositions();
00353 
00360     bool LoadMap(const char * mapFile);
00361 
00367     csVector2 GetMousePointer();
00368 
00372     void Exit();
00373 
00374     iObjectRegistry *       GetObjectRegistry() const;
00375     csRef<iEngine>          GetEngine() const;
00376     csRef<iVFS>             GetVFS() const;
00377     csRef<iEventQueue>      GetEventQueue() const;
00378     csRef<iConfigManager>   GetConfigManager() const;
00379     csRef<iTextureManager>  GetTextureManager() const;
00380     csRef<iGraphics3D>      GetGraphics3D() const;
00381     csRef<iGraphics2D>      GetGraphics2D() const;
00382     csRef<iVirtualClock>    GetVirtualClock() const;
00383     csRef<iLoader>          GetLoader() const;
00384     EEditReporter *         GetReporter() const;
00385 
00386     const char * GetConfigString(const char * key, const char * defaultValue) const;
00387     void         SetConfigString(const char * key, const char * value);
00388 
00389     float GetConfigFloat(const char * key, float defaultValue) const;
00390     void  SetConfigFloat(const char * key, float value);
00391 
00392     bool GetConfigBool(const char * key, bool defaultValue) const;
00393     void SetConfigBool(const char * key, bool value);
00394 
00400     void ExecuteCommand(const char * cmd);
00401 
00402 private:
00403 
00411     bool CreateEffectPathList(const csString & path, bool clear=true);
00412 
00419     bool AppendEffectPathList(const csString & effectFile, const csString & sourcePath);
00420     
00424     void CreateShortcuts();
00425 
00429     void RegisterFactories();
00430 
00434     void Update();
00435 
00441     void TakeScreenshot(const csString & fileName);
00442     
00444     DeclareGenericEventHandler(EventHandler,EEditApp,"planeshift.eedit");
00445     csRef<EventHandler> event_handler;
00446 
00447     EEditReporter *         reporter;
00448 
00449     iObjectRegistry*        object_reg;
00450     csRef<iEngine>          engine;
00451     csRef<iVFS>             vfs;
00452     csRef<iEventQueue>      queue;
00453     csRef<iConfigManager>   cfgmgr;
00454     csRef<iTextureManager>  txtmgr;
00455     csRef<iGraphics3D>      g3d;
00456     csRef<iGraphics2D>      g2d;
00457     csRef<iVirtualClock>    vc;
00458     csRef<iLoader>          loader;
00459 
00460     // PAWS
00461     PawsManager    * paws;
00462     pawsMainWidget * mainWidget;
00463 
00464     pawsEEdit            * editWindow;
00465 
00466     csString currEffectName;
00467     csString currEffectLoc;
00468     
00470     bool drawScreen;
00471    
00472     EEditToolboxManager * toolboxManager;
00473     EEditInputboxManager * inputboxManager;
00474     
00475     // effect stuff
00476     csRef<psEffectManager> effectManager;
00477     unsigned int currEffectID;
00478     bool effectLoaded;
00479 
00481     csRef<iMeshWrapper> particleSystem;
00482 
00484     csRef<iMeshWrapper> pos_anchor;
00485     
00487     csRef<iMeshWrapper> tar_anchor;
00488     
00490     bool effectPaused;
00491 
00492     // camera flags
00493     csBitArray camFlags;
00494     float camYaw;
00495     float camPitch;
00496 
00497     eControlManager * controlManager;
00498 
00499     struct EffectPath
00500     {
00501         EffectPath(const char * newName, const char * newPath) : name(newName), path(newPath) {}
00502         
00503         csString name;
00504         csString path;
00505     };
00506     csArray<EffectPath> effectPaths;
00507 
00508     csVector2 mousePointer;
00509 
00510     csRef<psCal3DCallbackLoader> cal3DCallbackLoader;
00511     
00512     csRandomFloatGen * rand;
00513 
00514 };
00515 
00518 #endif