RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
editorwindow.h
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #ifndef RIOENGINE_EDITOR_EDITORWINDOW_H_
31 #define RIOENGINE_EDITOR_EDITORWINDOW_H_
32 
33 #include <QStack>
34 #include <QString>
35 #include <QMainWindow>
38 
41 class QGameWindow;
42 
43 namespace Ui {
44 class EditorWindow;
45 }
46 
48  QObject* obj;
49  QString name;
50  QVariant value, oldValue;
51 
53  obj = NULL;
54  name = QString();
55  value = oldValue = QVariant();
56  }
57 };
58 
59 class EditorWindow : public QMainWindow {
60  Q_OBJECT
61 
62 public:
63  enum State { EDITING, PLAYING };
64 
65  explicit EditorWindow(QWidget *parent = 0);
66 
67  State currentState() const;
68 
70 
71  bool areResourcesLoaded();
72  void loadResourcesIfNeeded();
73 
74  void selectGameObjectHavingUID(uint gameobj_uid);
75  void selectGameObject(CGameObject* game_object);
76 
79 
80  void updateGUIState();
81  void clearSelection();
84  void removeChildFromInspector(QString child_name);
85  void addSceneFilenameToRecentSceneList(QString scene_filename);
86 
87  ~EditorWindow();
88 
89 protected:
90  virtual void closeEvent(QCloseEvent* event);
91 
92 private:
93  CGameObject* addNodeHavingId(std::string node_id);
94  const CGameObject* getSelectedGameObject();
95 
96  void setState(State);
97  void loadScene(QString filename);
98  void saveLayout();
99  void restoreLayout();
100  void setUpBulletToolbar();
101  void deployOrRemoveGameObjInDynamicsWorld(CGameObject* game_obj, bool deploy);
102  void createActionForDebugModeMenu(QMenu* menu, QString text, int bitmask, int option);
103  void regenerateBodyIfNeeded(CGameObject* game_object, QString property_name);
104  void addDefaultPlane();
105  void stopGame();
106  void showCreateGameObjectMenu();
107  void updateMemoryLeaksDetectionStatus();
108  void loadResources();
109 
110  std::string m_currentSceneFilename; // TODO change to QString?
111 
112  Ui::EditorWindow *ui;
113  State m_state;
114  QTimer* iTimer;
115  QPropertyBrowser* m_propertyBrowser;
116  QGLGameEditorViewport* m_glViewport;
117  QGameWindow* m_currentGameWindow;
118  PropertyChange m_lastPropertyChange;
119  QList<CGameObject> m_previousSceneGameObjects;
120  QStack<QString> m_recentScenes;
121  QTimer* m_timer;
122  QTimer* m_tmrBulletProfiler;
123 
124  bool m_isInitialized;
125  bool m_isEditingProperty;
126  bool m_ignoreOnInspectorActionPerformed;
127  bool m_isClosing;
128  bool m_memoryLeaksDetection;
129 
130 public slots:
131  void onGameWindowDestroyedCallback(QObject* obj = 0);
132  void propertyChanged(QObject * obj, QString property_name, QVariant value, QVariant old_value);
133  void selectGameObject(QString);
134  void onEditPropertyBegin();
135  void onEditPropertyEnd();
136 
137 protected slots:
138  void timeout(void);
139 
140  // TODO remove unused slots
141 private slots:
142  void on_actionNewScene_triggered();
143  void on_actionSave_Scene_2_triggered();
144  void on_actionExit_triggered();
145  void on_actionSave_As_triggered();
146  void on_actionAbout_triggered();
147  void on_actionReset_Camera_triggered();
148  void on_actionPlay_triggered();
149  void on_actionStop_triggered();
150  void on_actionCreate_new_triggered();
151  void on_actionDuplicate_triggered();
152  void on_actionRecalc_AABB_triggered();
153  void on_actionToggleCameraSpeed_triggered();
154  void on_menuRecent_scenes_aboutToShow();
155  void on_menuEdit_aboutToShow();
156  void on_actionUndo_triggered();
157  void on_actionRedo_triggered();
158  void on_actionShader_Designer_triggered();
159  void on_actionScale_triggered();
160  void on_actionTranslate_triggered();
161  void on_actionRotate_triggered();
162  void on_actionNone_triggered();
163  void on_actionUniform_Scale_triggered();
164  void on_actionMenuGlobal_triggered();
165  void on_actionMenuLocal_triggered();
166  void on_menuGAME_OBJECT_aboutToShow();
167  void on_actionAutoRecalc_AABB_on_resize_triggered(bool);
168  void on_actionMemory_Leaks_detection_triggered();
169  void on_actionDelete_triggered();
170  void on_actionQuery_bullet_profiler_triggered();
171  void on_actionOpen_triggered();
172 
173  void afterViewportInitializeGLCall(QGLGameViewport* game_viewport);
174  void onBulletProfilerTimeout();
175  void onInspectorActionPeformed(QObject* obj, QString property_name, QVariant value, QVariant old_value);
176  void onChangeBulletProfilerInterval(int value);
177  void onNewGameObjectSelected(uint selected_gameobj_uid);
178  void onModeButtonTriggered();
179  void onSelectedGameObjectTransformChanged(QGLGameEditorViewport::ManipulatorTypes selected_manipulator);
180  void onRecentSceneSelected();
181 };
182 
183 #endif // RIOENGINE_EDITOR_EDITORWINDOW_H_
void selectMostRecentGameObject()
Definition: about.h:6
QVariant oldValue
Definition: editorwindow.h:50
void setSelectedTransformMode(Transform::TransformMode transform_mode)
bool areResourcesLoaded()
void repopulatePropertyBrowser()
void selectGameObject(CGameObject *game_object)
void clearSelection()
void onEditPropertyBegin()
void onGameWindowDestroyedCallback(QObject *obj=0)
EditorWindow(QWidget *parent=0)
void setSelectedManipulatorType(QGLGameEditorViewport::ManipulatorTypes manipulator_type)
void timeout(void)
void loadResourcesIfNeeded()
static EditorWindow * currentInstance
Definition: editorwindow.h:69
QVariant value
Definition: editorwindow.h:50
void updateGUIState()
void onEditPropertyEnd()
void removeChildFromInspector(QString child_name)
void selectGameObjectHavingUID(uint gameobj_uid)
QObject * obj
Definition: editorwindow.h:48
void addSceneFilenameToRecentSceneList(QString scene_filename)
State currentState() const
void propertyChanged(QObject *obj, QString property_name, QVariant value, QVariant old_value)
virtual void closeEvent(QCloseEvent *event)