Planeshift
eeditapp.h
Go to the documentation of this file.
1 /*
2  * Author: Andrew Robberts
3  *
4  * Copyright (C) 2004 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef EEDIT_APP_HEADER
21 #define EEDIT_APP_HEADER
22 
23 #include <csutil/sysfunc.h>
24 #include <csutil/csstring.h>
25 #include <csutil/ref.h>
26 #include <csutil/bitarray.h>
27 #include <csgeom/vector2.h>
28 #include <csgeom/vector3.h>
29 
30 #include "util/genericevent.h"
31 
32 struct iEngine;
33 struct iLoader;
34 struct iVFS;
35 struct iEvent;
36 struct iEventQueue;
37 struct iConfigManager;
38 struct iTextureManager;
39 struct iGraphics3D;
40 struct iGraphics2D;
41 struct iView;
42 struct iVirtualClock;
43 struct iMeshWrapper;
44 class csRandomFloatGen;
45 
46 class PawsManager;
47 class pawsMainWidget;
48 class pawsWidget;
49 class pawsEEdit;
50 
51 class EEditReporter;
54 
55 class psEffectManager;
57 
58 class eControlManager;
59 
67 {
68  CAM_NONE = 0,
69 
76 
78 };
79 
80 
81 class EEditApp
82 {
83 public:
84 
85  static const char * CONFIG_FILENAME;
86  static const char * APP_NAME;
87  static const char * WINDOW_CAPTION;
88  static const char * KEY_DEFS_FILENAME;
89  static const char * TEMP_EFFECTS_LIST;
90 
94  EEditApp(iObjectRegistry * obj_reg, EEditReporter * _reporter);
95 
99  ~EEditApp();
100 
106  void SevereError(const char* msg);
107 
113  bool Init();
114 
122  bool LoadWidget(const char * file);
123 
129  bool LoadWidgets();
130 
134  PawsManager* GetPaws() { return paws; }
135 
136 
142  bool HandleEvent (iEvent &event);
143 
147  void RefreshEffectList();
148 
152  bool UpdateEffect();
153 
160  bool RenderEffect(const csString &effectName);
161 
167  bool RenderCurrentEffect();
168 
174  bool ReloadCurrentEffect();
175 
181  bool TogglePauseEffect();
182 
188  bool CancelEffect();
189 
193  void CreateParticleSystem(const csString & name);
194 
201  bool ToggleToolbox(size_t toolbox);
202 
208  void ShowToolbox(size_t toolbox);
209 
215  void HideToolbox(size_t toolbox);
216 
223  bool IsToolboxVisible(size_t toolbox);
224 
231 
238 
245 
254  csPtr<iMeshWrapper> LoadCustomMesh(const csString & meshFile, const csString & name, csVector3 pos);
255 
262  bool LoadPositionMesh(const csString & meshFile);
263 
270  bool LoadTargetMesh(const csString & meshFile);
271 
277  void SetPositionAnim(size_t index);
278 
284  void SetTargetAnim(size_t index);
285 
292  void SetPositionData(const csVector3 & pos, float rot);
293 
300  void SetTargetData(const csVector3 & pos, float rot);
301 
308  void SetCamFlag(int flag, bool val);
309 
316  bool GetCamFlag(int flag);
317 
324  bool SetCurrEffect(const csString & name);
325 
331  csString GetCurrEffectName();
332 
338  csString GetCurrParticleSystemName();
339 
345  unsigned int GetCurrEffectID() { return currEffectID; }
346 
353 
360  bool LoadMap(const char * mapFile);
361 
367  csVector2 GetMousePointer();
368 
372  void Exit();
373 
374  iObjectRegistry * GetObjectRegistry() const;
375  csRef<iEngine> GetEngine() const;
376  csRef<iVFS> GetVFS() const;
377  csRef<iEventQueue> GetEventQueue() const;
378  csRef<iConfigManager> GetConfigManager() const;
379  csRef<iTextureManager> GetTextureManager() const;
380  csRef<iGraphics3D> GetGraphics3D() const;
381  csRef<iGraphics2D> GetGraphics2D() const;
382  csRef<iVirtualClock> GetVirtualClock() const;
383  csRef<iLoader> GetLoader() const;
384  EEditReporter * GetReporter() const;
385 
386  const char * GetConfigString(const char * key, const char * defaultValue) const;
387  void SetConfigString(const char * key, const char * value);
388 
389  float GetConfigFloat(const char * key, float defaultValue) const;
390  void SetConfigFloat(const char * key, float value);
391 
392  bool GetConfigBool(const char * key, bool defaultValue) const;
393  void SetConfigBool(const char * key, bool value);
394 
400  void ExecuteCommand(const char * cmd);
401 
402 private:
403 
411  bool CreateEffectPathList(const csString & path, bool clear=true);
412 
419  bool AppendEffectPathList(const csString & effectFile, const csString & sourcePath);
420 
424  void CreateShortcuts();
425 
429  void RegisterFactories();
430 
434  void Update();
435 
441  void TakeScreenshot(const csString & fileName);
442 
444  DeclareGenericEventHandler(EventHandler,EEditApp,"planeshift.eedit");
445  csRef<EventHandler> event_handler;
446 
447  EEditReporter * reporter;
448 
449  iObjectRegistry* object_reg;
450  csRef<iEngine> engine;
451  csRef<iVFS> vfs;
452  csRef<iEventQueue> queue;
453  csRef<iConfigManager> cfgmgr;
454  csRef<iTextureManager> txtmgr;
455  csRef<iGraphics3D> g3d;
456  csRef<iGraphics2D> g2d;
457  csRef<iVirtualClock> vc;
458  csRef<iLoader> loader;
459 
460  // PAWS
461  PawsManager * paws;
462  pawsMainWidget * mainWidget;
463 
464  pawsEEdit * editWindow;
465 
466  csString currEffectName;
467  csString currEffectLoc;
468 
470  bool drawScreen;
471 
472  EEditToolboxManager * toolboxManager;
473  EEditInputboxManager * inputboxManager;
474 
475  // effect stuff
476  csRef<psEffectManager> effectManager;
477  unsigned int currEffectID;
478  bool effectLoaded;
479 
481  csRef<iMeshWrapper> particleSystem;
482 
484  csRef<iMeshWrapper> pos_anchor;
485 
487  csRef<iMeshWrapper> tar_anchor;
488 
490  bool effectPaused;
491 
492  // camera flags
493  csBitArray camFlags;
494  float camYaw;
495  float camPitch;
496 
497  eControlManager * controlManager;
498 
499  struct EffectPath
500  {
501  EffectPath(const char * newName, const char * newPath) : name(newName), path(newPath) {}
502 
503  csString name;
504  csString path;
505  };
506  csArray<EffectPath> effectPaths;
507 
508  csVector2 mousePointer;
509 
510  csRef<psCal3DCallbackLoader> cal3DCallbackLoader;
511 
512  csRandomFloatGen * rand;
513 
514 };
515 
518 #endif
void SetPositionData(const csVector3 &pos, float rot)
Sets the position and rotation of the effect position anchor.
PawsManager * GetPaws()
Get Paws.
Definition: eeditapp.h:134
A csReporterListener for eedit.
Definition: eeditreporter.h:39
static const char * APP_NAME
Definition: eeditapp.h:86
static const char * CONFIG_FILENAME
Definition: eeditapp.h:85
bool IsToolboxVisible(size_t toolbox)
Checks if the toolbox is visible.
csRef< iVFS > GetVFS() const
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
~EEditApp()
Destructor.
bool CancelEffect()
Cancels rendering of the current effect.
bool GetConfigBool(const char *key, bool defaultValue) const
EEditApp(iObjectRegistry *obj_reg, EEditReporter *_reporter)
Constructor.
void SetConfigFloat(const char *key, float value)
csRef< iLoader > GetLoader() const
const char * GetConfigString(const char *key, const char *defaultValue) const
Main PlaneShift Window manager.
Definition: pawsmanager.h:82
csRef< iEngine > GetEngine() const
EEditReporter * GetReporter() const
EEditToolboxManager * GetToolboxManager()
Grabs the toolbox manager.
void CreateParticleSystem(const csString &name)
Create a particle system mesh.
csString GetCurrEffectName()
Gets the name current effect.
bool SetCurrEffect(const csString &name)
Sets the current effect.
bool LoadTargetMesh(const csString &meshFile)
Loads the target mesh indicator.
bool RenderEffect(const csString &effectName)
Reloads and renders the given effect.
void SetPositionAnim(size_t index)
Sets the animation of the position mesh.
static const char * WINDOW_CAPTION
Definition: eeditapp.h:87
bool SetDefaultActorPositions()
Sets the positions of the origin and target actors to defaults based on the map&#39;s camera...
bool Init()
Initializes some CS specific stuff, fills most of this classes global variables, and inits eedit spec...
csRef< iVirtualClock > GetVirtualClock() const
A stripped version of the cal3d callback loader used only for eedit.
csRef< iGraphics3D > GetGraphics3D() const
void SetTargetData(const csVector3 &pos, float rot)
Sets the position and rotation of the effect target anchor.
void ExecuteCommand(const char *cmd)
Executes a named command.
void Exit()
Exits the application.
csRef< iGraphics2D > GetGraphics2D() const
void RefreshEffectList()
Refreshes the list of effects.
csRef< iConfigManager > GetConfigManager() const
void SetConfigString(const char *key, const char *value)
csVector2 GetMousePointer()
Gets the location of the mouse pointer.
A class that manages the inputbox windows.
void ShowToolbox(size_t toolbox)
Ensures that the given toolbox is visible.
bool LoadWidgets()
Loads all the paws widgets (windows).
bool UpdateEffect()
Effect has been changed, so lets rerender it.
bool LoadMap(const char *mapFile)
Loads the given map file.
bool ReloadCurrentEffect()
Loads the current effect.
void SevereError(const char *msg)
Reports a severe error in the application.
The main or desktop widget.
A class that manages a group of toolbox windows.
static const char * TEMP_EFFECTS_LIST
Definition: eeditapp.h:89
bool LoadWidget(const char *file)
Loads a single paws widget.
csRef< iTextureManager > GetTextureManager() const
bool GetCamFlag(int flag)
Gets the value of the given camera flag.
csString GetCurrParticleSystemName()
Gets the name current particle system.
void SetCamFlag(int flag, bool val)
Sets the given camera flag.
bool RenderCurrentEffect()
Renders the current effect.
float GetConfigFloat(const char *key, float defaultValue) const
unsigned int GetCurrEffectID()
Gets the ID of the current effect.
Definition: eeditapp.h:345
iObjectRegistry * GetObjectRegistry() const
void SetConfigBool(const char *key, bool value)
bool LoadPositionMesh(const csString &meshFile)
Loads the position mesh indicator.
EEditInputboxManager * GetInputboxManager()
Grabs the inputbox manager.
csPtr< iMeshWrapper > LoadCustomMesh(const csString &meshFile, const csString &name, csVector3 pos)
Loads a mesh based on the name or filepath given.
CAM_FLAG
The camera flags.
Definition: eeditapp.h:66
bool HandleEvent(iEvent &event)
handles an event from the event handler
void SetTargetAnim(size_t index)
Sets the animation of the target mesh.
static const char * KEY_DEFS_FILENAME
Definition: eeditapp.h:88
csRef< iEventQueue > GetEventQueue() const
bool ToggleToolbox(size_t toolbox)
Toggles the visibility of the given toolbox.
psEffectManager * GetEffectManager()
Grabs the effect manager.
bool TogglePauseEffect()
Toggles the pause/resume state of the effect.
void HideToolbox(size_t toolbox)
Ensures that the given toolbox is hidden.