-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindow.cpp
More file actions
399 lines (342 loc) · 8.06 KB
/
Copy pathwindow.cpp
File metadata and controls
399 lines (342 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
/**
* Atlas - Volumetric terrain editor
* Copyright (C) 2012-2015 Ondřej Záruba
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "window.h"
Window::Window(QObject *parent): QObject(parent)
{
m_projectOpen=false;
m_project=NULL;
m_welcome=NULL;
m_workspace=NULL;
m_projectLoader=NULL;
window=NULL;
#ifdef OS_ANDROID
m_gamepad=true;
#else
m_gamepad=false;
#endif
m_wireframe=false;
m_lightVisible=true;
m_shadow=true;
m_fullscreen=false;
m_renderVr=false;
#if defined(Q_OS_ANDROID)
m_homeFolder=QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#elif defined(Q_OS_LINUX)
m_homeFolder=QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#elif defined(Q_OS_WIN)
m_homeFolder=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
#endif
m_terrainVisible=true;
m_modelVisible=true;
m_oceanVisible=true;
}
Window::~Window()
{
m_workspace->unloadProject();
}
bool Window::init(QQuickWindow *window, QOpenGLContext *main_context, Assets * assets)
{
this->window=window;
this->assets=assets;
this->main_context=main_context;
connect(window,SIGNAL(closing(QQuickCloseEvent*)),this,SLOT(close(QQuickCloseEvent*)));
showWelcome();
return true;
}
void Window::projectLoaded(Project *project)
{
if(project!=NULL)
{
project->assets=assets;
window->alert(0);
m_workspace->setProject(project);
setProjectOpen(true);
showWorkspace();
}
else
{
setProjectOpen(false);
showWelcome();
}
setProject(project);
}
void Window::createProject(const QString &path, const QString &name, const QString &author, int width, int height, int depth)
{
closeProject();
showLoading();
m_projectLoader->createProject(path,name,author,width,height,depth);
}
void Window::undo()
{
m_workspace->undo();
}
void Window::redo()
{
m_workspace->redo();
}
void Window::close(QQuickCloseEvent*)
{
m_workspace->unloadProject();
delete m_project;
setProject(NULL);
}
void Window::openProject(const QUrl &file_path)
{
openProject(file_path.toLocalFile());
}
void Window::openProject(const QString &file_name)
{
QFileInfo info(file_name);
if(info.exists())
{
showLoading();
m_projectLoader->openProject(file_name,main_context);
}
else
{
cerr<<"Unable to open project "<<file_name<<endl;
}
}
bool Window::isProjectOpen() const
{
return m_projectOpen;
}
bool Window::isGamepad() const
{
return m_gamepad;
}
bool Window::isWireframe() const
{
return m_wireframe;
}
bool Window::isFullscreen() const
{
return m_fullscreen;
}
bool Window::isLightVisible() const
{
return m_lightVisible;
}
bool Window::isShadow() const
{
return m_shadow;
}
QUrl Window::homeFolder() const
{
return m_homeFolder;
}
Project *Window::project() const
{
return m_project;
}
Workspace *Window::workspace() const
{
return m_workspace;
}
Welcome *Window::welcome() const
{
return m_welcome;
}
ProjectLoader *Window::projectLoader() const
{
return m_projectLoader;
}
bool Window::renderVr() const
{
return m_renderVr;
}
bool Window::terrainVisible() const
{
return m_terrainVisible;
}
bool Window::modelVisible() const
{
return m_modelVisible;
}
bool Window::oceanVisible() const
{
return m_oceanVisible;
}
void Window::saveAll()
{
cout<<"saving project..."<<endl;
m_projectLoader->saveProject();
cout<<"project saved"<<endl;
}
void Window::saveAs(const QUrl &save_url)
{
m_projectLoader->saveProjectAs(save_url);
}
void Window::action_map_export()
{
/*QString dir = QFileDialog::getExistingDirectory(this, tr("Export Directory"),
"~",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
//session.project->exportMap(dir);
if(session.project!=NULL)
{
WorldIO exp;
//exp.exportProject(dir);
}*/
}
void Window::closeProject()
{
m_workspace->unloadProject();
delete m_project;
setProject(NULL);
showWelcome();
setProjectOpen(false);
}
void Window::setProjectOpen(bool arg)
{
if (m_projectOpen != arg) {
m_projectOpen = arg;
emit projectOpenChanged(arg);
}
}
void Window::setGamepad(bool arg)
{
if (m_gamepad != arg) {
m_gamepad = arg;
emit gamepadChanged(arg);
}
}
void Window::setWireframe(bool arg)
{
if (m_wireframe != arg) {
m_workspace->showWireframe(m_wireframe);
m_wireframe = arg;
emit wireframeChanged(arg);
}
}
void Window::setFullscreen(bool arg)
{
if (m_fullscreen != arg && window!=NULL) {
m_fullscreen = arg;
if(m_fullscreen)
window->showFullScreen();
else
{
#ifdef OS_ANDROID
window->setWindowState(Qt::WindowMaximized);
#else
window->showNormal();
#endif
}
emit fullscreenChanged(arg);
}
}
void Window::setLightVisible(bool arg)
{
if (m_lightVisible != arg) {
m_lightVisible = arg;
m_workspace->showLight(m_lightVisible);
emit lightVisibleChanged(arg);
}
}
void Window::setShadow(bool arg)
{
if (m_shadow != arg) {
m_shadow = arg;
m_workspace->showShadow(m_shadow);
emit shadowChanged(arg);
}
}
void Window::setWorkspace(Workspace *arg)
{
if (m_workspace != arg) {
m_workspace = arg;
emit workspaceChanged(arg);
}
}
void Window::setWelcome(Welcome *arg)
{
if (m_welcome != arg) {
m_welcome = arg;
if(m_welcome!=NULL) m_welcome->load(this);
emit welcomeChanged(arg);
}
}
void Window::setProjectLoader(ProjectLoader *arg)
{
if (m_projectLoader != arg) {
m_projectLoader = arg;
if(m_projectLoader!=NULL) connect(m_projectLoader,SIGNAL(projectLoaded(Project*)),this,SLOT(projectLoaded(Project*)));
emit projectLoaderChanged(arg);
}
}
void Window::setRenderVr(bool arg)
{
if (m_renderVr != arg) {
m_renderVr = arg;
m_workspace->renderVr(m_renderVr);
emit renderVrChanged(arg);
}
}
void Window::setTerrainVisible(bool arg)
{
if (m_terrainVisible == arg)
return;
if(m_project!=NULL)
m_project->world.terrain.setVisible(arg);
m_terrainVisible = arg;
emit terrainVisibleChanged(arg);
}
void Window::setModelVisible(bool arg)
{
if (m_modelVisible == arg)
return;
if(m_project!=NULL)
m_project->world.model.setVisible(arg);
m_modelVisible = arg;
emit modelVisibleChanged(arg);
}
void Window::setOceanVisible(bool arg)
{
if (m_oceanVisible == arg)
return;
if(m_project!=NULL)
m_project->world.ocean.setVisible(arg);
m_oceanVisible = arg;
emit oceanVisibleChanged(arg);
}
void Window::setProject(Project *arg)
{
if (m_project != arg) {
m_project = arg;
emit projectChanged(arg);
}
}
void Window::showWorkspace()
{
m_welcome->setVisible(false);
m_workspace->setVisible(true);
m_projectLoader->setVisible(false);
}
void Window::showWelcome()
{
m_welcome->setVisible(true);
m_workspace->setVisible(false);
m_projectLoader->setVisible(false);
}
void Window::showLoading()
{
m_welcome->setVisible(false);
m_workspace->setVisible(false);
m_projectLoader->setVisible(true);
}