~sithlord48/makoureactor/trunk

113 by myst6re
Global reorganization:
1
/****************************************************************************
2
 ** Makou Reactor Final Fantasy VII Field Script Editor
317.3.3 by sithlord48
All src UTF-8
3
 ** Copyright (C) 2009-2012 Arzel Jérôme <myst6re@gmail.com>
113 by myst6re
Global reorganization:
4
 **
5
 ** This program is free software: you can redistribute it and/or modify
6
 ** it under the terms of the GNU General Public License as published by
7
 ** the Free Software Foundation, either version 3 of the License, or
8
 ** (at your option) any later version.
9
 **
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
 **
15
 ** You should have received a copy of the GNU General Public License
16
 ** along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 ****************************************************************************/
18
#include "WalkmeshManager.h"
118 by myst6re
Global reorganization:
19
#include "core/Config.h"
113 by myst6re
Global reorganization:
20
#include "Data.h"
21
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
22
WalkmeshManager::WalkmeshManager(QWidget *parent) :
113 by myst6re
Global reorganization:
23
	QDialog(parent, Qt::Tool),
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
24
    idFile(nullptr), caFile(nullptr), infFile(nullptr), scriptsAndTexts(nullptr)
113 by myst6re
Global reorganization:
25
{
317.3.26 by sithlord48
English for all strings
26
	setWindowTitle(tr("Walkmesh"));
113 by myst6re
Global reorganization:
27
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
28
	walkmesh = Config::value("OpenGL", true).toBool() ? new WalkmeshWidget() : nullptr;
113 by myst6re
Global reorganization:
29
	QWidget *walkmeshWidget = walkmesh ? walkmesh : new QWidget(this);
30
31
	slider1 = new QSlider(this);
32
	slider2 = new QSlider(this);
33
	slider3 = new QSlider(this);
34
35
	slider1->setRange(-180, 180);
36
	slider2->setRange(-180, 180);
37
	slider3->setRange(-180, 180);
38
39
	slider1->setValue(0);
40
	slider2->setValue(0);
41
	slider3->setValue(0);
42
317.3.26 by sithlord48
English for all strings
43
	QLabel *keyInfos = new QLabel(tr("Use the arrow keys to move the camera."));
113 by myst6re
Global reorganization:
44
	keyInfos->setTextFormat(Qt::PlainText);
45
	keyInfos->setWordWrap(true);
46
366 by myst6re
Adding possibility to add fields. Export to PSF. Adding some icons and ergonomic changes
47
	QPushButton *resetCamera = new QPushButton(tr("Reset Camera"));
113 by myst6re
Global reorganization:
48
335.1.99 by myst6re
Save 'show field models' state in config file
49
	showModels = new QCheckBox(tr("Show 3D models"));
50
	showModels->setChecked(Config::value("fieldModelsVisible", true).toBool());
155 by myst6re
New option in the walkmesh manager to show/hide models in the view.
51
113 by myst6re
Global reorganization:
52
	tabWidget = new QTabWidget(this);
317.3.26 by sithlord48
English for all strings
53
	tabWidget->addTab(buildCameraPage(), tr("Camera"));
113 by myst6re
Global reorganization:
54
	tabWidget->addTab(buildWalkmeshPage(), tr("Walkmesh"));
317.3.26 by sithlord48
English for all strings
55
	tabWidget->addTab(buildGatewaysPage(), tr("Gateways"));
56
	tabWidget->addTab(buildDoorsPage(), tr("Doors"));
57
	tabWidget->addTab(buildArrowPage(), tr("Arrows"));
58
	tabWidget->addTab(buildCameraRangePage(), tr("Camera range"));
59
	tabWidget->addTab(buildMiscPage(), tr("Miscellaneous"));
113 by myst6re
Global reorganization:
60
61
	QGridLayout *layout = new QGridLayout(this);
155 by myst6re
New option in the walkmesh manager to show/hide models in the view.
62
	layout->addWidget(walkmeshWidget, 0, 0, 4, 1);
113 by myst6re
Global reorganization:
63
	layout->addWidget(slider1, 0, 1);
64
	layout->addWidget(slider2, 0, 2);
65
	layout->addWidget(slider3, 0, 3);
66
	layout->addWidget(keyInfos, 1, 1, 1, 3);
67
	layout->addWidget(resetCamera, 2, 1, 1, 3);
155 by myst6re
New option in the walkmesh manager to show/hide models in the view.
68
	layout->addWidget(showModels, 3, 1, 1, 3);
69
	layout->addWidget(tabWidget, 4, 0, 1, 4);
113 by myst6re
Global reorganization:
70
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
71
	if (walkmesh) {
113 by myst6re
Global reorganization:
72
		connect(slider1, SIGNAL(valueChanged(int)), walkmesh, SLOT(setXRotation(int)));
73
		connect(slider2, SIGNAL(valueChanged(int)), walkmesh, SLOT(setYRotation(int)));
74
		connect(slider3, SIGNAL(valueChanged(int)), walkmesh, SLOT(setZRotation(int)));
75
		connect(resetCamera, SIGNAL(clicked()), SLOT(resetCamera()));
155 by myst6re
New option in the walkmesh manager to show/hide models in the view.
76
		connect(showModels, SIGNAL(toggled(bool)), SLOT(setModelsVisible(bool)));
113 by myst6re
Global reorganization:
77
	}
78
}
79
80
void WalkmeshManager::resetCamera()
81
{
82
	slider1->blockSignals(true);
83
	slider2->blockSignals(true);
84
	slider3->blockSignals(true);
85
	slider1->setValue(0);
86
	slider2->setValue(0);
87
	slider3->setValue(0);
88
	slider1->blockSignals(false);
89
	slider2->blockSignals(false);
90
	slider3->blockSignals(false);
91
	walkmesh->resetCamera();
92
}
93
155 by myst6re
New option in the walkmesh manager to show/hide models in the view.
94
void WalkmeshManager::setModelsVisible(bool show)
95
{
96
	walkmesh->setModelsVisible(show);
97
}
98
113 by myst6re
Global reorganization:
99
QWidget *WalkmeshManager::buildCameraPage()
100
{
101
	QWidget *ret = new QWidget(this);
102
103
	ListWidget *listWidget = new ListWidget(ret);
317.3.26 by sithlord48
English for all strings
104
	listWidget->addAction(ListWidget::Add, tr("Add camera"), this, SLOT(addCamera()));
105
	listWidget->addAction(ListWidget::Rem, tr("Remove camera"), this, SLOT(removeCamera()));
113 by myst6re
Global reorganization:
106
107
	caToolbar = listWidget->toolBar();
108
	camList = listWidget->listWidget();
109
110
	caVectorXEdit = new VertexWidget(ret);
111
	caVectorYEdit = new VertexWidget(ret);
112
	caVectorZEdit = new VertexWidget(ret);
113
114
	caSpaceXEdit = new QDoubleSpinBox(ret);
115
	qreal maxInt = qPow(2,31);
116
	caSpaceXEdit->setRange(-maxInt, maxInt);
117
	caSpaceXEdit->setDecimals(0);
118
	caSpaceYEdit = new QDoubleSpinBox(ret);
119
	caSpaceYEdit->setRange(-maxInt, maxInt);
120
	caSpaceYEdit->setDecimals(0);
121
	caSpaceZEdit = new QDoubleSpinBox(ret);
122
	caSpaceZEdit->setRange(-maxInt, maxInt);
123
	caSpaceZEdit->setDecimals(0);
124
125
	caZoomEdit = new QSpinBox(ret);
126
	caZoomEdit->setRange(-32768, 32767);
127
128
	QGridLayout *caLayout = new QGridLayout(ret);
129
	caLayout->addWidget(listWidget, 0, 0, 8, 1);
317.3.26 by sithlord48
English for all strings
130
	caLayout->addWidget(new QLabel(tr("Zoom:")), 0, 1, 1, 3);
113 by myst6re
Global reorganization:
131
	caLayout->addWidget(caZoomEdit, 0, 4, 1, 2);
317.3.26 by sithlord48
English for all strings
132
	caLayout->addWidget(new QLabel(tr("Camera axis:")), 1, 1, 1, 6);
113 by myst6re
Global reorganization:
133
	caLayout->addWidget(caVectorXEdit, 2, 1, 1, 6);
134
	caLayout->addWidget(caVectorYEdit, 3, 1, 1, 6);
135
	caLayout->addWidget(caVectorZEdit, 4, 1, 1, 6);
317.3.26 by sithlord48
English for all strings
136
	caLayout->addWidget(new QLabel(tr("Camera position:")), 5, 1, 1, 6);
113 by myst6re
Global reorganization:
137
	caLayout->addWidget(new QLabel(tr("X")), 6, 1);
138
	caLayout->addWidget(caSpaceXEdit, 6, 2);
139
	caLayout->addWidget(new QLabel(tr("Y")), 6, 3);
140
	caLayout->addWidget(caSpaceYEdit, 6, 4);
141
	caLayout->addWidget(new QLabel(tr("Z")), 6, 5);
142
	caLayout->addWidget(caSpaceZEdit, 6, 6);
143
	caLayout->setRowStretch(7, 1);
144
	caLayout->setColumnStretch(2, 1);
145
	caLayout->setColumnStretch(4, 1);
146
	caLayout->setColumnStretch(6, 1);
147
148
	connect(camList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentCamera(int)));
149
150
	connect(caVectorXEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
151
	connect(caVectorYEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
152
	connect(caVectorZEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
153
154
	connect(caSpaceXEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
155
	connect(caSpaceYEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
156
	connect(caSpaceZEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
157
158
	connect(caZoomEdit, SIGNAL(valueChanged(int)), SLOT(editCaZoom(int)));
159
160
	return ret;
161
}
162
163
QWidget *WalkmeshManager::buildWalkmeshPage()
164
{
165
	QWidget *ret = new QWidget(this);
166
167
	ListWidget *listWidget = new ListWidget(ret);
317.3.26 by sithlord48
English for all strings
168
	listWidget->addAction(ListWidget::Add, tr("Add triangle"), this, SLOT(addTriangle()));
169
	listWidget->addAction(ListWidget::Rem, tr("Remove triangle"), this, SLOT(removeTriangle()));
113 by myst6re
Global reorganization:
170
171
	idToolbar = listWidget->toolBar();
172
	idList = listWidget->listWidget();
173
174
	idVertices[0] = new VertexWidget(ret);
175
	idVertices[1] = new VertexWidget(ret);
176
	idVertices[2] = new VertexWidget(ret);
177
178
	idAccess[0] = new QSpinBox(ret);
179
	idAccess[1] = new QSpinBox(ret);
180
	idAccess[2] = new QSpinBox(ret);
181
182
	idAccess[0]->setRange(-32768, 32767);
183
	idAccess[1]->setRange(-32768, 32767);
184
	idAccess[2]->setRange(-32768, 32767);
185
186
	QHBoxLayout *accessLayout0 = new QHBoxLayout;
317.3.26 by sithlord48
English for all strings
187
	accessLayout0->addWidget(new QLabel(tr("Triangle accessible via the line 1-2 :")));
113 by myst6re
Global reorganization:
188
	accessLayout0->addWidget(idAccess[0]);
189
190
	QHBoxLayout *accessLayout1 = new QHBoxLayout;
317.3.26 by sithlord48
English for all strings
191
	accessLayout1->addWidget(new QLabel(tr("Triangle accessible via the line 2-3 :")));
113 by myst6re
Global reorganization:
192
	accessLayout1->addWidget(idAccess[1]);
193
194
	QHBoxLayout *accessLayout2 = new QHBoxLayout;
317.3.26 by sithlord48
English for all strings
195
	accessLayout2->addWidget(new QLabel(tr("Triangle accessible via the line 3-1 :")));
113 by myst6re
Global reorganization:
196
	accessLayout2->addWidget(idAccess[2]);
197
198
	QGridLayout *layout = new QGridLayout(ret);
199
	layout->addWidget(listWidget, 0, 0, 7, 1, Qt::AlignLeft);
200
	layout->addWidget(new QLabel(tr("Point 1 :")), 0, 1);
201
	layout->addWidget(idVertices[0], 0, 2);
202
	layout->addWidget(new QLabel(tr("Point 2 :")), 1, 1);
203
	layout->addWidget(idVertices[1], 1, 2);
204
	layout->addWidget(new QLabel(tr("Point 3 :")), 2, 1);
205
	layout->addWidget(idVertices[2], 2, 2);
206
	layout->addLayout(accessLayout0, 3, 1, 1, 2);
207
	layout->addLayout(accessLayout1, 4, 1, 1, 2);
208
	layout->addLayout(accessLayout2, 5, 1, 1, 2);
209
	layout->setRowStretch(6, 1);
210
211
	connect(idList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentId(int)));
212
	connect(idVertices[0], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
213
	connect(idVertices[1], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
214
	connect(idVertices[2], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
215
	connect(idAccess[0], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
216
	connect(idAccess[1], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
217
	connect(idAccess[2], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
218
219
	return ret;
220
}
221
222
QWidget *WalkmeshManager::buildGatewaysPage()
223
{
224
	QWidget *ret = new QWidget(this);
225
226
	gateList = new QListWidget(ret);
227
	gateList->setFixedWidth(125);
228
317.3.26 by sithlord48
English for all strings
229
	gateEnabled = new QCheckBox(tr("Enable"), ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
230
231
	exitPoints[0] = new VertexWidget(ret);
232
	exitPoints[1] = new VertexWidget(ret);
335.1.100 by myst6re
Avoid confusion between Triangle ID and field ID
233
	entryPoint = new VertexWidget(QString(), QString(), tr("T"), ret);
113 by myst6re
Global reorganization:
234
235
	fieldId = new QSpinBox(ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
236
	fieldId->setRange(-32768, 32766);
113 by myst6re
Global reorganization:
237
128 by myst6re
WindowBinFile: jp font is now supported.
238
	exitDirection = new QSpinBox(ret);
239
	exitDirection->setRange(0, 255);
113 by myst6re
Global reorganization:
240
317.3.26 by sithlord48
English for all strings
241
	arrowDisplay = new QCheckBox(tr("Show an arrow"), ret);
113 by myst6re
Global reorganization:
242
	arrowDisplay->setIcon(QIcon(":/images/field-arrow-red.png"));
243
244
	QGridLayout *layout = new QGridLayout(ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
245
	layout->addWidget(gateList, 0, 0, 8, 1, Qt::AlignLeft);
246
	layout->addWidget(gateEnabled, 0, 1, 1, 2);
317.3.26 by sithlord48
English for all strings
247
	layout->addWidget(new QLabel(tr("Exit line:")), 1, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
248
	layout->addWidget(exitPoints[0], 1, 2);
249
	layout->addWidget(exitPoints[1], 2, 2);
317.3.26 by sithlord48
English for all strings
250
	layout->addWidget(new QLabel(tr("Destination point:")), 3, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
251
	layout->addWidget(entryPoint, 3, 2);
317.3.26 by sithlord48
English for all strings
252
	layout->addWidget(new QLabel(tr("Character orientation:")), 4, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
253
	layout->addWidget(exitDirection, 4, 2);
317.3.26 by sithlord48
English for all strings
254
	layout->addWidget(new QLabel(tr("Field ID:")), 5, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
255
	layout->addWidget(fieldId, 5, 2);
256
	layout->addWidget(arrowDisplay, 6, 1, 1, 2);
257
	layout->setRowStretch(7, 1);
113 by myst6re
Global reorganization:
258
259
	connect(gateList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentGateway(int)));
144 by myst6re
Added functions to retrieve model positions in scripts.
260
	connect(gateEnabled, SIGNAL(toggled(bool)), SLOT(editGateEnabled(bool)));
113 by myst6re
Global reorganization:
261
	connect(exitPoints[0], SIGNAL(valuesChanged(Vertex_s)), SLOT(editExitPoint(Vertex_s)));
262
	connect(exitPoints[1], SIGNAL(valuesChanged(Vertex_s)), SLOT(editExitPoint(Vertex_s)));
263
	connect(entryPoint, SIGNAL(valuesChanged(Vertex_s)), SLOT(editEntryPoint(Vertex_s)));
264
	connect(fieldId, SIGNAL(valueChanged(int)), SLOT(editFieldId(int)));
265
	connect(arrowDisplay, SIGNAL(toggled(bool)), SLOT(editArrowDisplay(bool)));
128 by myst6re
WindowBinFile: jp font is now supported.
266
	connect(exitDirection, SIGNAL(valueChanged(int)), SLOT(editExitDirection(int)));
113 by myst6re
Global reorganization:
267
268
	return ret;
269
}
270
271
QWidget *WalkmeshManager::buildDoorsPage()
272
{
273
	QWidget *ret = new QWidget(this);
274
275
	doorList = new QListWidget(ret);
276
	doorList->setFixedWidth(125);
277
317.3.26 by sithlord48
English for all strings
278
	doorEnabled = new QCheckBox(tr("Enable"), ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
279
280
	doorPosition[0] = new VertexWidget(ret);
281
	doorPosition[1] = new VertexWidget(ret);
113 by myst6re
Global reorganization:
282
283
	bgParamId = new QSpinBox(ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
284
	bgParamId->setRange(0, 254);
113 by myst6re
Global reorganization:
285
286
	bgStateId = new QSpinBox(ret);
287
	bgStateId->setRange(0, 255);
288
289
	doorBehavior = new QSpinBox(ret);
290
	doorBehavior->setRange(0, 255);
291
292
	doorSoundId = new QSpinBox(ret);
293
	doorSoundId->setRange(0, 255);
294
295
	QGridLayout *idsLayout = new QGridLayout;
317.3.26 by sithlord48
English for all strings
296
	idsLayout->addWidget(new QLabel(tr("Background parameter ID:")), 0, 0);
113 by myst6re
Global reorganization:
297
	idsLayout->addWidget(bgParamId, 0, 1);
317.3.26 by sithlord48
English for all strings
298
	idsLayout->addWidget(new QLabel(tr("Background state ID:")), 1, 0);
113 by myst6re
Global reorganization:
299
	idsLayout->addWidget(bgStateId, 1, 1);
317.3.26 by sithlord48
English for all strings
300
	idsLayout->addWidget(new QLabel(tr("Behavior:")), 2, 0);
113 by myst6re
Global reorganization:
301
	idsLayout->addWidget(doorBehavior, 2, 1);
317.3.26 by sithlord48
English for all strings
302
	idsLayout->addWidget(new QLabel(tr("Sound ID:")), 3, 0);
113 by myst6re
Global reorganization:
303
	idsLayout->addWidget(doorSoundId, 3, 1);
304
305
	QGridLayout *layout = new QGridLayout(ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
306
	layout->addWidget(doorList, 0, 0, 5, 1, Qt::AlignLeft);
307
	layout->addWidget(doorEnabled, 0, 1, 1, 2);
317.3.26 by sithlord48
English for all strings
308
	layout->addWidget(new QLabel(tr("Trigger Line Door:")), 1, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
309
	layout->addWidget(doorPosition[0], 1, 2);
310
	layout->addWidget(doorPosition[1], 2, 2);
311
	layout->addLayout(idsLayout, 3, 1, 1, 2);
312
	layout->setRowStretch(4, 1);
113 by myst6re
Global reorganization:
313
314
	connect(doorList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentDoor(int)));
144 by myst6re
Added functions to retrieve model positions in scripts.
315
	connect(doorEnabled, SIGNAL(toggled(bool)), SLOT(editDoorEnabled(bool)));
113 by myst6re
Global reorganization:
316
	connect(doorPosition[0], SIGNAL(valuesChanged(Vertex_s)), SLOT(editDoorPoint(Vertex_s)));
317
	connect(doorPosition[1], SIGNAL(valuesChanged(Vertex_s)), SLOT(editDoorPoint(Vertex_s)));
318
	connect(bgParamId, SIGNAL(valueChanged(int)), SLOT(editParamId(int)));
319
	connect(bgStateId, SIGNAL(valueChanged(int)), SLOT(editStateId(int)));
320
	connect(doorBehavior, SIGNAL(valueChanged(int)), SLOT(editBehavior(int)));
321
	connect(doorSoundId, SIGNAL(valueChanged(int)), SLOT(editSoundId(int)));
322
323
	return ret;
324
}
325
326
QWidget *WalkmeshManager::buildArrowPage()
327
{
328
	QWidget *ret = new QWidget(this);
329
330
	arrowList = new QListWidget(ret);
331
	arrowList->setFixedWidth(125);
332
333
	arrowX = new QDoubleSpinBox(ret);
334
	arrowX->setDecimals(0);
335
	arrowX->setRange(-pow(2, 31), pow(2, 31)-1);
336
337
	arrowY = new QDoubleSpinBox(ret);
338
	arrowY->setDecimals(0);
339
	arrowY->setRange(-pow(2, 31), pow(2, 31)-1);
340
341
	arrowZ = new QDoubleSpinBox(ret);
342
	arrowZ->setDecimals(0);
343
	arrowZ->setRange(-pow(2, 31), pow(2, 31)-1);
344
345
	arrowType = new QComboBox(ret);
346
	arrowType->addItem(tr("Invisible"), 0);
317.3.26 by sithlord48
English for all strings
347
	arrowType->addItem(QIcon(":/images/field-arrow-red.png"), tr("Red"), 1);
348
	arrowType->addItem(QIcon(":/images/field-arrow-green.png"), tr("Green"), 2);
113 by myst6re
Global reorganization:
349
350
	QHBoxLayout *posLayout = new QHBoxLayout;
144 by myst6re
Added functions to retrieve model positions in scripts.
351
	posLayout->addWidget(new QLabel(tr("X")));
113 by myst6re
Global reorganization:
352
	posLayout->addWidget(arrowX);
144 by myst6re
Added functions to retrieve model positions in scripts.
353
	posLayout->addWidget(new QLabel(tr("Y")));
113 by myst6re
Global reorganization:
354
	posLayout->addWidget(arrowY);
144 by myst6re
Added functions to retrieve model positions in scripts.
355
	posLayout->addWidget(new QLabel(tr("Z")));
113 by myst6re
Global reorganization:
356
	posLayout->addWidget(arrowZ);
144 by myst6re
Added functions to retrieve model positions in scripts.
357
	posLayout->setContentsMargins(QMargins());
113 by myst6re
Global reorganization:
358
359
	QGridLayout *layout = new QGridLayout(ret);
144 by myst6re
Added functions to retrieve model positions in scripts.
360
	layout->addWidget(arrowList, 0, 0, 3, 1, Qt::AlignLeft);
335.1.44 by myst6re
Translation fixes
361
	layout->addWidget(new QLabel(tr("Position:")), 0, 1);
317.3.26 by sithlord48
English for all strings
362
	layout->addWidget(new QLabel(tr("Type:")), 1, 1);
144 by myst6re
Added functions to retrieve model positions in scripts.
363
	layout->addLayout(posLayout, 0, 2);
364
	layout->addWidget(arrowType, 1, 2);
365
	layout->setRowStretch(2, 1);
201 by myst6re
Adjusting layout in walkmesh dialog (arrows page)
366
	layout->setColumnStretch(2, 1);
113 by myst6re
Global reorganization:
367
368
	connect(arrowList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentArrow(int)));
369
	connect(arrowX, SIGNAL(valueChanged(double)), SLOT(editArrowX(double)));
370
	connect(arrowY, SIGNAL(valueChanged(double)), SLOT(editArrowY(double)));
371
	connect(arrowZ, SIGNAL(valueChanged(double)), SLOT(editArrowZ(double)));
372
	connect(arrowType, SIGNAL(currentIndexChanged(int)), SLOT(editArrowType(int)));
373
374
	return ret;
375
}
376
377
QWidget *WalkmeshManager::buildCameraRangePage()
378
{
379
	QWidget *ret = new QWidget(this);
380
317.3.26 by sithlord48
English for all strings
381
	QGroupBox *group1 = new QGroupBox(tr("Camera range"), ret);
382
	QGroupBox *group2 = new QGroupBox(tr("Layer sizes (for layer animations)"), ret);
383
	QGroupBox *group3 = new QGroupBox(tr("Layer flags"), ret);
113 by myst6re
Global reorganization:
384
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
385
	for (int i=0; i<4; ++i) {
113 by myst6re
Global reorganization:
386
		rangeEdit[i] = new QSpinBox(group1);
387
		rangeEdit[i]->setRange(-32768, 32767);
388
		bgSizeEdit[i] = new QSpinBox(group2);
389
		bgSizeEdit[i]->setRange(-32768, 32767);
390
		bgFlagEdit[i] = new QSpinBox(group3);
391
		bgFlagEdit[i]->setRange(0, 255);
392
	}
393
	QGridLayout *layout1 = new QGridLayout(group1);
366 by myst6re
Adding possibility to add fields. Export to PSF. Adding some icons and ergonomic changes
394
	layout1->addWidget(new QLabel(tr("Top")), 0, 0);
113 by myst6re
Global reorganization:
395
	layout1->addWidget(rangeEdit[0], 0, 1);
366 by myst6re
Adding possibility to add fields. Export to PSF. Adding some icons and ergonomic changes
396
	layout1->addWidget(new QLabel(tr("Bottom")), 0, 2);
113 by myst6re
Global reorganization:
397
	layout1->addWidget(rangeEdit[1], 0, 3);
317.3.26 by sithlord48
English for all strings
398
	layout1->addWidget(new QLabel(tr("Right")), 1, 0);
113 by myst6re
Global reorganization:
399
	layout1->addWidget(rangeEdit[2], 1, 1);
317.3.26 by sithlord48
English for all strings
400
	layout1->addWidget(new QLabel(tr("Left")), 1, 2);
113 by myst6re
Global reorganization:
401
	layout1->addWidget(rangeEdit[3], 1, 3);
402
	layout1->setColumnStretch(0, 1);
403
	layout1->setColumnStretch(1, 1);
404
	layout1->setColumnStretch(2, 1);
405
	layout1->setColumnStretch(3, 1);
406
407
	QGridLayout *layout2 = new QGridLayout(group2);
317.3.26 by sithlord48
English for all strings
408
	layout2->addWidget(new QLabel(tr("Background layer 3 width")), 0, 0);
113 by myst6re
Global reorganization:
409
	layout2->addWidget(bgSizeEdit[0], 0, 1);
317.3.26 by sithlord48
English for all strings
410
	layout2->addWidget(new QLabel(tr("Background layer 3 height")), 0, 2);
113 by myst6re
Global reorganization:
411
	layout2->addWidget(bgSizeEdit[1], 0, 3);
317.3.26 by sithlord48
English for all strings
412
	layout2->addWidget(new QLabel(tr("Background layer 4 width")), 1, 0);
113 by myst6re
Global reorganization:
413
	layout2->addWidget(bgSizeEdit[2], 1, 1);
317.3.26 by sithlord48
English for all strings
414
	layout2->addWidget(new QLabel(tr("Background layer 4 height")), 1, 2);
113 by myst6re
Global reorganization:
415
	layout2->addWidget(bgSizeEdit[3], 1, 3);
416
	layout2->setRowStretch(2, 1);
417
	layout2->setColumnStretch(0, 1);
418
	layout2->setColumnStretch(1, 1);
419
	layout2->setColumnStretch(2, 1);
420
	layout2->setColumnStretch(3, 1);
421
422
	QGridLayout *layout3 = new QGridLayout(group3);
317.3.26 by sithlord48
English for all strings
423
	layout3->addWidget(new QLabel(tr("Layer 1")), 0, 0);
113 by myst6re
Global reorganization:
424
	layout3->addWidget(bgFlagEdit[0], 0, 1);
317.3.26 by sithlord48
English for all strings
425
	layout3->addWidget(new QLabel(tr("Layer 2")), 0, 2);
113 by myst6re
Global reorganization:
426
	layout3->addWidget(bgFlagEdit[1], 0, 3);
317.3.26 by sithlord48
English for all strings
427
	layout3->addWidget(new QLabel(tr("Layer 3")), 0, 4);
113 by myst6re
Global reorganization:
428
	layout3->addWidget(bgFlagEdit[2], 0, 5);
317.3.26 by sithlord48
English for all strings
429
	layout3->addWidget(new QLabel(tr("Layer 4")), 0, 6);
113 by myst6re
Global reorganization:
430
	layout3->addWidget(bgFlagEdit[3], 0, 7);
431
	layout3->setRowStretch(1, 1);
432
433
	QVBoxLayout *layout = new QVBoxLayout(ret);
434
	layout->addWidget(group1);
435
	layout->addWidget(group2);
436
	layout->addWidget(group3);
317.3.11 by sithlord48
fixes myst6re/makoureactor#8 myst6re/makoureactor#9
437
	//layout->addStretch();
113 by myst6re
Global reorganization:
438
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
439
	for (int i=0; i<4; ++i) {
113 by myst6re
Global reorganization:
440
		connect(rangeEdit[i], SIGNAL(valueChanged(int)), SLOT(editRange(int)));
441
		connect(bgSizeEdit[i], SIGNAL(valueChanged(int)), SLOT(editRange(int)));
442
		connect(bgFlagEdit[i], SIGNAL(valueChanged(int)), SLOT(editRange(int)));
443
	}
444
445
	return ret;
446
}
447
448
QWidget *WalkmeshManager::buildMiscPage()
449
{
450
	QWidget *ret = new QWidget(this);
451
452
	navigation = new OrientationWidget(ret);
453
	navigation2 = new QSpinBox(ret);
454
	navigation2->setRange(0, 255);
455
	navigation2->setWrapping(true);
456
457
	cameraFocusHeight = new QSpinBox(ret);
458
	cameraFocusHeight->setRange(-32768, 32767);
459
460
	unknown = new HexLineEdit(ret);
461
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
462
	mapScale = new QSpinBox(this);
463
	mapScale->setRange(0, 65535);
464
113 by myst6re
Global reorganization:
465
	QGridLayout *layout = new QGridLayout(ret);
317.3.26 by sithlord48
English for all strings
466
	layout->addWidget(new QLabel(tr("Movements orientation:")), 0, 0);
113 by myst6re
Global reorganization:
467
	layout->addWidget(navigation, 0, 1);
468
	layout->addWidget(navigation2, 0, 2);
317.3.26 by sithlord48
English for all strings
469
	layout->addWidget(new QLabel(tr("Camera Focus Height on the playable character:")), 1, 0);
113 by myst6re
Global reorganization:
470
	layout->addWidget(cameraFocusHeight, 1, 1, 1, 2);
317.3.26 by sithlord48
English for all strings
471
	layout->addWidget(new QLabel(tr("Unknown:")), 2, 0);
113 by myst6re
Global reorganization:
472
	layout->addWidget(unknown, 2, 1, 1, 2);
399 by myst6re
So much modifications at once :cry:
473
	layout->addWidget(new QLabel(tr("Field map scale:")), 3, 0);
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
474
	layout->addWidget(mapScale, 3, 1, 1, 2);
475
	layout->setRowStretch(4, 1);
113 by myst6re
Global reorganization:
476
477
	connect(navigation, SIGNAL(valueEdited(int)), navigation2, SLOT(setValue(int)));
478
	connect(navigation2, SIGNAL(valueChanged(int)), SLOT(editNavigation(int)));
479
	connect(cameraFocusHeight, SIGNAL(valueChanged(int)), SLOT(editCameraFocusHeight(int)));
480
	connect(unknown, SIGNAL(dataEdited(QByteArray)), SLOT(editUnknown(QByteArray)));
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
481
	connect(mapScale, SIGNAL(valueChanged(int)), SLOT(editMapScale(int)));
113 by myst6re
Global reorganization:
482
483
	return ret;
484
}
485
335.1.99 by myst6re
Save 'show field models' state in config file
486
void WalkmeshManager::saveConfig()
487
{
488
	Config::setValue("fieldModelsVisible", showModels->isChecked());
489
}
490
113 by myst6re
Global reorganization:
491
void WalkmeshManager::fill(Field *field, bool reload)
492
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
493
	if (!field || (!reload && field->inf() == infFile))	return;
113 by myst6re
Global reorganization:
494
495
	infFile = field->inf();
496
	idFile = field->walkmesh();
497
	caFile = field->camera();
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
498
	scriptsAndTexts = field->scriptsAndTexts();
113 by myst6re
Global reorganization:
499
335.1.99 by myst6re
Save 'show field models' state in config file
500
	walkmesh->setModelsVisible(showModels->isChecked());
501
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
502
	if (!idFile->isOpen() || !caFile->isOpen() || !infFile->isOpen()) {
317.3.26 by sithlord48
English for all strings
503
		QMessageBox::warning(this, tr("Opening error"), tr("Error opening walkmesh"));
113 by myst6re
Global reorganization:
504
	}
505
506
	int camCount = 0;
507
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
508
	if (walkmesh) {
144 by myst6re
Added functions to retrieve model positions in scripts.
509
		walkmesh->fill(field);
113 by myst6re
Global reorganization:
510
	}
511
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
512
	if (caFile->isOpen()) {
113 by myst6re
Global reorganization:
513
		camCount = caFile->cameraCount();
514
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
515
		if (camList->count() != camCount) {
113 by myst6re
Global reorganization:
516
			camList->blockSignals(true);
517
			camList->clear();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
518
			for (int i=0; i<camCount; ++i) {
317.3.26 by sithlord48
English for all strings
519
				camList->addItem(tr("Camera %1").arg(i));
113 by myst6re
Global reorganization:
520
			}
521
			camList->blockSignals(false);
522
		}
523
524
		setCurrentCamera(0);
525
	}
526
	tabWidget->widget(0)->setEnabled(caFile->isOpen() && camCount > 0);
527
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
528
	if (idFile->isOpen()) {
113 by myst6re
Global reorganization:
529
		int triangleCount = idFile->triangleCount();
530
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
531
		if (idList->count() != triangleCount) {
113 by myst6re
Global reorganization:
532
			idList->blockSignals(true);
533
			idList->clear();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
534
			for (int i=0; i<triangleCount; ++i) {
113 by myst6re
Global reorganization:
535
				idList->addItem(tr("Triangle %1").arg(i));
536
			}
537
			idList->blockSignals(false);
538
		}
539
		idList->setCurrentRow(0);
540
		setCurrentId(0);
541
	}
542
	tabWidget->widget(1)->setEnabled(idFile->isOpen());
543
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
544
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
545
		gateList->clear();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
546
		for (const Exit &gateway : infFile->exitLines()) {
547
			if (gateway.fieldID != 0x7FFF) {
391 by myst6re
Show unused fields
548
				gateList->addItem(QString("%1 (%2)").arg(Data::mapName(gateway.fieldID)).arg(gateway.fieldID));
113 by myst6re
Global reorganization:
549
			} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
550
				QListWidgetItem *item = new QListWidgetItem(tr("Unused"));
551
				item->setForeground(Qt::darkGray);
552
				gateList->addItem(item);
113 by myst6re
Global reorganization:
553
			}
554
		}
555
		gateList->setCurrentRow(0);
556
		setCurrentGateway(0);
557
558
		doorList->clear();
559
		int doorID = 0;
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
560
		for (const Trigger &trigger : infFile->triggers()) {
561
			if (trigger.background_parameter != 0xFF) {
317.3.26 by sithlord48
English for all strings
562
				doorList->addItem(tr("Door %1").arg(doorID));
113 by myst6re
Global reorganization:
563
			} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
564
				QListWidgetItem *item = new QListWidgetItem(tr("Unused"));
565
				item->setForeground(Qt::darkGray);
566
				doorList->addItem(item);
113 by myst6re
Global reorganization:
567
			}
568
			++doorID;
569
		}
570
		doorList->setCurrentRow(0);
571
		setCurrentDoor(0);
572
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
573
		if (!infFile->isJap()) {
113 by myst6re
Global reorganization:
574
			arrowList->clear();
575
			int arrowID = 0;
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
576
			for (const Arrow &arrow : infFile->arrows()) {
577
				if (arrow.type != 0) {
317.3.26 by sithlord48
English for all strings
578
					arrowList->addItem(tr("Arrow %1").arg(arrowID));
113 by myst6re
Global reorganization:
579
				} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
580
					QListWidgetItem *item = new QListWidgetItem(tr("Unused"));
581
					item->setForeground(Qt::darkGray);
582
					arrowList->addItem(item);
113 by myst6re
Global reorganization:
583
				}
584
				++arrowID;
585
			}
586
			arrowList->setCurrentRow(0);
587
			setCurrentArrow(0);
588
		}
589
		arrowDisplay->setVisible(!infFile->isJap());
590
591
		const Range &range1 = infFile->cameraRange();
592
593
		rangeEdit[0]->setValue(range1.top);
594
		rangeEdit[1]->setValue(range1.bottom);
595
		rangeEdit[2]->setValue(range1.right);
596
		rangeEdit[3]->setValue(range1.left);
597
598
		bgSizeEdit[0]->setValue(infFile->bgLayer3Width());
599
		bgSizeEdit[1]->setValue(infFile->bgLayer3Height());
600
		bgSizeEdit[2]->setValue(infFile->bgLayer4Width());
601
		bgSizeEdit[3]->setValue(infFile->bgLayer4Height());
602
603
		bgFlagEdit[0]->setValue(infFile->bgLayer1Flag());
604
		bgFlagEdit[1]->setValue(infFile->bgLayer2Flag());
605
		bgFlagEdit[2]->setValue(infFile->bgLayer3Flag());
606
		bgFlagEdit[3]->setValue(infFile->bgLayer4Flag());
607
608
		navigation->setValue(infFile->control());
609
		navigation2->setValue(infFile->control());
610
611
		cameraFocusHeight->setValue(infFile->cameraFocusHeight());
612
		unknown->setData(infFile->unknown());
613
	}
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
614
	navigation->setEnabled(infFile->isOpen());
615
	navigation2->setEnabled(infFile->isOpen());
616
	cameraFocusHeight->setEnabled(infFile->isOpen());
617
	unknown->setEnabled(infFile->isOpen());
618
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
619
	if (scriptsAndTexts->isOpen()) {
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
620
		mapScale->setValue(scriptsAndTexts->scale());
621
	}
622
	mapScale->setEnabled(scriptsAndTexts->isOpen());
623
113 by myst6re
Global reorganization:
624
	tabWidget->widget(2)->setEnabled(infFile->isOpen());
625
	tabWidget->widget(3)->setEnabled(infFile->isOpen());
626
	tabWidget->widget(4)->setEnabled(infFile->isOpen() && !infFile->isJap());
627
	tabWidget->widget(5)->setEnabled(infFile->isOpen());
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
628
	tabWidget->widget(6)->setEnabled(infFile->isOpen() || scriptsAndTexts->isOpen());
113 by myst6re
Global reorganization:
629
}
630
631
void WalkmeshManager::clear()
632
{
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
633
	infFile = nullptr;
634
	idFile = nullptr;
635
	caFile = nullptr;
636
	scriptsAndTexts = nullptr;
113 by myst6re
Global reorganization:
637
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
638
	if (walkmesh) {
113 by myst6re
Global reorganization:
639
		walkmesh->clear();
640
	}
641
}
642
643
int WalkmeshManager::currentCamera() const
644
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
645
	if (!caFile->isOpen())	return 0;
113 by myst6re
Global reorganization:
646
647
	int camID = camList->currentRow();
648
	return camID < 0 || camID >= caFile->cameraCount() ? 0 : camID;
649
}
650
651
void WalkmeshManager::setCurrentCamera(int camID)
652
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
653
	if (!caFile->isOpen() || camID < 0) {
113 by myst6re
Global reorganization:
654
		return;
655
	}
656
657
	bool hasCamera = camID < caFile->cameraCount();
658
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
659
	if (hasCamera) {
113 by myst6re
Global reorganization:
660
		const Camera &cam = caFile->camera(camID);
661
662
		caVectorXEdit->blockSignals(true);
663
		caVectorYEdit->blockSignals(true);
664
		caVectorZEdit->blockSignals(true);
665
		caSpaceXEdit->blockSignals(true);
666
		caSpaceYEdit->blockSignals(true);
667
		caSpaceZEdit->blockSignals(true);
668
		caZoomEdit->blockSignals(true);
669
670
		caVectorXEdit->setValues(cam.camera_axis[0]);
671
		caVectorYEdit->setValues(cam.camera_axis[1]);
672
		caVectorZEdit->setValues(cam.camera_axis[2]);
673
674
		caSpaceXEdit->setValue(cam.camera_position[0]);
675
		caSpaceYEdit->setValue(cam.camera_position[1]);
676
		caSpaceZEdit->setValue(cam.camera_position[2]);
677
678
		caZoomEdit->setValue(cam.camera_zoom);
679
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
680
		if (walkmesh)	walkmesh->setCurrentFieldCamera(camID);
113 by myst6re
Global reorganization:
681
		caVectorXEdit->blockSignals(false);
682
		caVectorYEdit->blockSignals(false);
683
		caVectorZEdit->blockSignals(false);
684
		caSpaceXEdit->blockSignals(false);
685
		caSpaceYEdit->blockSignals(false);
686
		caSpaceZEdit->blockSignals(false);
687
		caZoomEdit->blockSignals(false);
688
	}
689
690
	caVectorXEdit->setEnabled(hasCamera);
691
	caVectorYEdit->setEnabled(hasCamera);
692
	caVectorZEdit->setEnabled(hasCamera);
693
694
	caSpaceXEdit->setEnabled(hasCamera);
695
	caSpaceYEdit->setEnabled(hasCamera);
696
	caSpaceZEdit->setEnabled(hasCamera);
697
698
	caZoomEdit->setEnabled(hasCamera);
699
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
700
	if (camList->currentRow() != camID) {
113 by myst6re
Global reorganization:
701
		camList->blockSignals(true);
702
		camList->setCurrentRow(camID);
703
		camList->blockSignals(false);
704
	}
705
}
706
707
void WalkmeshManager::addCamera()
708
{
709
	int row = camList->currentRow();
710
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
711
	if (caFile->isOpen()) {
113 by myst6re
Global reorganization:
712
		Camera ca;
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
713
		if (row < caFile->cameraCount()) {
113 by myst6re
Global reorganization:
714
			ca = caFile->camera(row);
715
		} else {
716
			ca = Camera();
717
		}
718
		caFile->insertCamera(row+1, ca);
719
		camList->insertItem(row+1, tr("Camera %1").arg(row+1));
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
720
		for (int i=row+2; i<camList->count(); ++i) {
113 by myst6re
Global reorganization:
721
			camList->item(i)->setText(tr("Camera %1").arg(i));
722
		}
723
		camList->setCurrentRow(row+1);
724
725
		emit modified();
726
	}
727
}
728
729
void WalkmeshManager::removeCamera()
730
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
731
	if (caFile->cameraCount() < 2) return;
113 by myst6re
Global reorganization:
732
733
	int row = camList->currentRow();
734
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
735
	if (row < 0)		return;
113 by myst6re
Global reorganization:
736
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
737
	if (caFile->isOpen() && row < caFile->cameraCount()) {
738
		if (caFile->removeCamera(row)) {
113 by myst6re
Global reorganization:
739
			delete camList->item(row);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
740
			for (int i=row; i<camList->count(); ++i) {
113 by myst6re
Global reorganization:
741
				camList->item(i)->setText(tr("Camera %1").arg(i));
742
			}
743
			setCurrentCamera(row);
744
745
			emit modified();
746
		}
747
	}
748
}
749
750
void WalkmeshManager::editCaVector(const Vertex_s &values)
751
{
752
	QObject *s = sender();
753
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
754
	if (s == caVectorXEdit)			editCaVector(0, values);
755
	else if (s == caVectorYEdit)		editCaVector(1, values);
756
	else if (s == caVectorZEdit)		editCaVector(2, values);
113 by myst6re
Global reorganization:
757
}
758
759
void WalkmeshManager::editCaVector(int id, const Vertex_s &values)
760
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
761
	if (caFile->isOpen() && caFile->hasCamera()) {
113 by myst6re
Global reorganization:
762
		const int camID = currentCamera();
763
		Camera cam = caFile->camera(camID);
764
		Vertex_s oldV = cam.camera_axis[id];
765
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
766
		if (oldV.x != values.x || oldV.y != values.y || oldV.z != values.z) {
113 by myst6re
Global reorganization:
767
			cam.camera_axis[id] = values;
768
			caFile->setCamera(camID, cam);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
769
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
770
771
			emit modified();
772
		}
773
	}
774
}
775
776
void WalkmeshManager::editCaPos(double value)
777
{
778
	QObject *s = sender();
779
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
780
	if (s == caSpaceXEdit)			editCaPos(0, value);
781
	else if (s == caSpaceYEdit)		editCaPos(1, value);
782
	else if (s == caSpaceZEdit)		editCaPos(2, value);
113 by myst6re
Global reorganization:
783
}
784
785
void WalkmeshManager::editCaPos(int id, double value)
786
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
787
	if (caFile->isOpen() && caFile->hasCamera()) {
113 by myst6re
Global reorganization:
788
		const int camID = currentCamera();
789
		Camera cam = caFile->camera(camID);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
790
		if (cam.camera_position[id] != qint32(value)) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
791
			cam.camera_position[id] = qint32(value);
113 by myst6re
Global reorganization:
792
			caFile->setCamera(camID, cam);
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
793
			walkmesh->update();
113 by myst6re
Global reorganization:
794
795
			emit modified();
796
		}
797
	}
798
}
799
800
void WalkmeshManager::editCaZoom(int value)
801
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
802
	if (caFile->isOpen() && caFile->hasCamera()) {
113 by myst6re
Global reorganization:
803
		const int camID = currentCamera();
804
		Camera cam = caFile->camera(camID);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
805
		if (cam.camera_zoom != value) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
806
			cam.camera_zoom = quint16(value);
113 by myst6re
Global reorganization:
807
			caFile->setCamera(camID, cam);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
808
			if (walkmesh)	walkmesh->updatePerspective();
113 by myst6re
Global reorganization:
809
810
			emit modified();
811
		}
812
	}
813
}
814
815
void WalkmeshManager::setCurrentId(int i)
816
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
817
	if (!idFile->isOpen() || i < 0)	return;
113 by myst6re
Global reorganization:
818
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
819
	if (idFile->triangleCount() <= i)	return;
113 by myst6re
Global reorganization:
820
821
	const Triangle &triangle = idFile->triangle(i);
822
	const Access &access = idFile->access(i);
823
824
	idVertices[0]->setValues(IdFile::toVertex_s(triangle.vertices[0]));
825
	idVertices[1]->setValues(IdFile::toVertex_s(triangle.vertices[1]));
826
	idVertices[2]->setValues(IdFile::toVertex_s(triangle.vertices[2]));
827
828
	idAccess[0]->setValue(access.a[0]);
829
	idAccess[1]->setValue(access.a[1]);
830
	idAccess[2]->setValue(access.a[2]);
831
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
832
	if (walkmesh)	walkmesh->setSelectedTriangle(i);
113 by myst6re
Global reorganization:
833
}
834
835
void WalkmeshManager::addTriangle()
836
{
837
	int row = idList->currentRow();
838
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
839
	if (idFile->isOpen()) {
113 by myst6re
Global reorganization:
840
		Triangle tri;
841
		Access acc;
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
842
		if (row < idFile->triangleCount()) {
113 by myst6re
Global reorganization:
843
			tri = idFile->triangle(row);
844
			acc = idFile->access(row);
845
		} else {
846
			tri = Triangle();
847
			acc = Access();
848
		}
849
		idFile->insertTriangle(row+1, tri, acc);
850
		idList->insertItem(row+1, tr("Triangle %1").arg(row+1));
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
851
		for (int i=row+2; i<idList->count(); ++i) {
113 by myst6re
Global reorganization:
852
			idList->item(i)->setText(tr("Triangle %1").arg(i));
853
		}
854
		idList->setCurrentRow(row+1);
855
856
		emit modified();
857
	}
858
}
859
860
void WalkmeshManager::removeTriangle()
861
{
862
	int row = idList->currentRow();
863
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
864
	if (row < 0)		return;
113 by myst6re
Global reorganization:
865
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
866
	if (idFile->isOpen() && row < idFile->triangleCount()) {
113 by myst6re
Global reorganization:
867
		idFile->removeTriangle(row);
868
		delete idList->item(row);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
869
		for (int i=row; i<idList->count(); ++i) {
113 by myst6re
Global reorganization:
870
			idList->item(i)->setText(tr("Triangle %1").arg(i));
871
		}
872
		setCurrentId(row);
873
874
		emit modified();
875
	}
876
}
877
878
void WalkmeshManager::editIdTriangle(const Vertex_s &values)
879
{
880
	QObject *s = sender();
881
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
882
	if (s == idVertices[0])			editIdTriangle(0, values);
883
	else if (s == idVertices[1])		editIdTriangle(1, values);
884
	else if (s == idVertices[2])		editIdTriangle(2, values);
113 by myst6re
Global reorganization:
885
}
886
887
void WalkmeshManager::editIdTriangle(int id, const Vertex_s &values)
888
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
889
	if (idFile->isOpen()) {
113 by myst6re
Global reorganization:
890
		const int triangleID = idList->currentRow();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
891
		if (triangleID > -1 && triangleID < idFile->triangleCount()) {
113 by myst6re
Global reorganization:
892
			Triangle old = idFile->triangle(triangleID);
893
			Vertex_sr &oldV = old.vertices[id];
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
894
			if (oldV.x != values.x || oldV.y != values.y || oldV.z != values.z) {
113 by myst6re
Global reorganization:
895
				oldV = IdFile::fromVertex_s(values);
896
				idFile->setTriangle(triangleID, old);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
897
				if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
898
899
				emit modified();
900
			}
901
		}
902
	}
903
}
904
905
void WalkmeshManager::editIdAccess(int value)
906
{
907
	QObject *s = sender();
908
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
909
	if (s == idAccess[0])			editIdAccess(0, value);
910
	else if (s == idAccess[1])		editIdAccess(1, value);
911
	else if (s == idAccess[2])		editIdAccess(2, value);
113 by myst6re
Global reorganization:
912
}
913
914
void WalkmeshManager::editIdAccess(int id, int value)
915
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
916
	if (idFile->isOpen()) {
113 by myst6re
Global reorganization:
917
		const int triangleID = idList->currentRow();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
918
		if (triangleID > -1 && triangleID < idFile->triangleCount()) {
113 by myst6re
Global reorganization:
919
			Access old = idFile->access(triangleID);
920
			qint16 oldV = old.a[id];
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
921
			if (oldV != value) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
922
				old.a[id] = qint16(value);
113 by myst6re
Global reorganization:
923
				idFile->setAccess(triangleID, old);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
924
				if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
925
926
				emit modified();
927
			}
928
		}
929
	}
930
}
931
932
void WalkmeshManager::setCurrentGateway(int id)
933
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
934
	if (!infFile->isOpen() || id < 0 || 12 <= id)    return;
113 by myst6re
Global reorganization:
935
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
936
	const Exit &gateway = infFile->exitLine(quint8(id));
113 by myst6re
Global reorganization:
937
938
	exitPoints[0]->setValues(gateway.exit_line[0]);
939
	exitPoints[1]->setValues(gateway.exit_line[1]);
940
	entryPoint->setValues(gateway.destination);
144 by myst6re
Added functions to retrieve model positions in scripts.
941
	fieldId->blockSignals(true);
942
	gateEnabled->blockSignals(true);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
943
	if (gateway.fieldID == 0x7FFF) {
144 by myst6re
Added functions to retrieve model positions in scripts.
944
		gateEnabled->setChecked(false);
945
		fieldId->setValue(0);
946
	} else {
947
		gateEnabled->setChecked(true);
948
		fieldId->setValue(gateway.fieldID);
949
	}
950
	fieldId->blockSignals(false);
951
	gateEnabled->blockSignals(false);
952
	setGateEnabled(gateEnabled->isChecked());
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
953
	if (!infFile->isJap()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
954
		arrowDisplay->setChecked(infFile->arrowIsDisplayed(quint8(id)));
113 by myst6re
Global reorganization:
955
	}
956
128 by myst6re
WindowBinFile: jp font is now supported.
957
	exitDirection->setValue(gateway.dir);
113 by myst6re
Global reorganization:
958
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
959
	if (walkmesh)	walkmesh->setSelectedGate(id);
113 by myst6re
Global reorganization:
960
}
961
962
void WalkmeshManager::setCurrentDoor(int id)
963
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
964
	if (!infFile->isOpen() || id < 0 || 12 <= id)    return;
113 by myst6re
Global reorganization:
965
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
966
	const Trigger &trigger = infFile->trigger(quint8(id));
113 by myst6re
Global reorganization:
967
144 by myst6re
Added functions to retrieve model positions in scripts.
968
	doorEnabled->blockSignals(true);
969
	bgParamId->blockSignals(true);
970
	doorPosition[0]->blockSignals(true);
971
	doorPosition[1]->blockSignals(true);
972
	bgStateId->blockSignals(true);
973
	doorBehavior->blockSignals(true);
974
	doorSoundId->blockSignals(true);
975
113 by myst6re
Global reorganization:
976
	doorPosition[0]->setValues(trigger.trigger_line[0]);
977
	doorPosition[1]->setValues(trigger.trigger_line[1]);
144 by myst6re
Added functions to retrieve model positions in scripts.
978
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
979
	if (trigger.background_parameter == 0xFF) {
144 by myst6re
Added functions to retrieve model positions in scripts.
980
		doorEnabled->setChecked(false);
981
		bgParamId->setValue(0);
982
	} else {
983
		doorEnabled->setChecked(true);
984
		bgParamId->setValue(trigger.background_parameter);
985
	}
986
113 by myst6re
Global reorganization:
987
	bgStateId->setValue(trigger.background_state);
988
	doorBehavior->setValue(trigger.behavior);
989
	doorSoundId->setValue(trigger.soundID);
990
144 by myst6re
Added functions to retrieve model positions in scripts.
991
	doorEnabled->blockSignals(false);
992
	bgParamId->blockSignals(false);
993
	doorPosition[0]->blockSignals(false);
994
	doorPosition[1]->blockSignals(false);
995
	bgStateId->blockSignals(false);
996
	doorBehavior->blockSignals(false);
997
	doorSoundId->blockSignals(false);
998
999
	setDoorEnabled(doorEnabled->isChecked());
1000
1001
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1002
	if (walkmesh)	walkmesh->setSelectedDoor(id);
113 by myst6re
Global reorganization:
1003
}
1004
1005
void WalkmeshManager::setCurrentArrow(int id)
1006
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1007
	if (!infFile->isOpen() || id < 0 || 12 <= id)    return;
113 by myst6re
Global reorganization:
1008
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1009
	const Arrow &arrow = infFile->arrow(quint8(id));
113 by myst6re
Global reorganization:
1010
1011
	arrowX->setValue(arrow.positionX);
1012
	arrowY->setValue(arrow.positionY);
1013
	arrowZ->setValue(arrow.positionZ);
1014
	int index = arrowType->findData(arrow.type);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1015
	if (index != -1) {
113 by myst6re
Global reorganization:
1016
		arrowType->setCurrentIndex(index);
1017
	} else {
1018
		arrowType->addItem(tr("?"), arrow.type);
1019
		arrowType->setCurrentIndex(arrowType->count()-1);
1020
	}
1021
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1022
	if (walkmesh)	walkmesh->setSelectedArrow(id);
113 by myst6re
Global reorganization:
1023
}
1024
1025
void WalkmeshManager::editExitPoint(const Vertex_s &values)
1026
{
1027
	QObject *s = sender();
1028
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1029
	if (s == exitPoints[0])			editExitPoint(0, values);
1030
	else if (s == exitPoints[1])		editExitPoint(1, values);
113 by myst6re
Global reorganization:
1031
}
1032
1033
void WalkmeshManager::editExitPoint(int id, const Vertex_s &values)
1034
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1035
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1036
		quint8 gateId = quint8(gateList->currentRow());
113 by myst6re
Global reorganization:
1037
		Exit old = infFile->exitLine(gateId);
1038
		Vertex_s oldVertex = old.exit_line[id];
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1039
		if (oldVertex.x != values.x || oldVertex.y != values.y || oldVertex.z != values.z) {
113 by myst6re
Global reorganization:
1040
			old.exit_line[id] = values;
1041
			infFile->setExitLine(gateId, old);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1042
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1043
1044
			emit modified();
1045
		}
1046
	}
1047
}
1048
1049
void WalkmeshManager::editEntryPoint(const Vertex_s &values)
1050
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1051
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1052
		quint8 gateId = quint8(gateList->currentRow());
113 by myst6re
Global reorganization:
1053
		Exit old = infFile->exitLine(gateId);
1054
		Vertex_s oldVertex = old.destination;
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1055
		if (oldVertex.x != values.x || oldVertex.y != values.y || oldVertex.z != values.z) {
113 by myst6re
Global reorganization:
1056
			old.destination = values;
1057
			infFile->setExitLine(gateId, old);
1058
1059
			emit modified();
1060
		}
1061
	}
1062
}
1063
1064
void WalkmeshManager::editDoorPoint(const Vertex_s &values)
1065
{
1066
	QObject *s = sender();
1067
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1068
	if (s == doorPosition[0])			editDoorPoint(0, values);
1069
	else if (s == doorPosition[1])		editDoorPoint(1, values);
113 by myst6re
Global reorganization:
1070
}
1071
1072
void WalkmeshManager::editDoorPoint(int id, const Vertex_s &values)
1073
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1074
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1075
		quint8 gateId = quint8(gateList->currentRow());
113 by myst6re
Global reorganization:
1076
		Trigger old = infFile->trigger(gateId);
1077
		Vertex_s oldVertex = old.trigger_line[id];
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1078
		if (oldVertex.x != values.x || oldVertex.y != values.y || oldVertex.z != values.z) {
113 by myst6re
Global reorganization:
1079
			old.trigger_line[id] = values;
1080
			infFile->setTrigger(gateId, old);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1081
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1082
1083
			emit modified();
1084
		}
1085
	}
1086
}
1087
128 by myst6re
WindowBinFile: jp font is now supported.
1088
void WalkmeshManager::editExitDirection(int dir)
113 by myst6re
Global reorganization:
1089
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1090
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1091
		quint8 gateId = quint8(gateList->currentRow());
113 by myst6re
Global reorganization:
1092
		Exit old = infFile->exitLine(gateId);
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1093
		old.dir_copy1 = old.dir_copy2 = old.dir_copy3 = old.dir = quint8(dir);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1094
		if (old.dir != infFile->exitLine(gateId).dir
128 by myst6re
WindowBinFile: jp font is now supported.
1095
				|| old.dir_copy1 != infFile->exitLine(gateId).dir_copy1
1096
				|| old.dir_copy2 != infFile->exitLine(gateId).dir_copy2
1097
				|| old.dir_copy3 != infFile->exitLine(gateId).dir_copy3) {
113 by myst6re
Global reorganization:
1098
			infFile->setExitLine(gateId, old);
1099
1100
			emit modified();
1101
		}
1102
	}
1103
}
1104
144 by myst6re
Added functions to retrieve model positions in scripts.
1105
void WalkmeshManager::setGateEnabled(bool enabled)
1106
{
1107
	exitDirection->setEnabled(enabled);
1108
	fieldId->setEnabled(enabled);
1109
	exitPoints[0]->setEnabled(enabled);
1110
	exitPoints[1]->setEnabled(enabled);
1111
	entryPoint->setEnabled(enabled);
1112
	arrowDisplay->setEnabled(enabled);
1113
}
1114
1115
void WalkmeshManager::editGateEnabled(bool enabled)
1116
{
1117
	setGateEnabled(enabled);
1118
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1119
	if (enabled) {
144 by myst6re
Added functions to retrieve model positions in scripts.
1120
		editFieldId(fieldId->value());
1121
	} else {
1122
		editFieldId(0x7FFF);
1123
	}
1124
}
1125
113 by myst6re
Global reorganization:
1126
void WalkmeshManager::editFieldId(int v)
1127
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1128
	if (infFile->isOpen()) {
1129
		if (!gateEnabled->isChecked()) {
144 by myst6re
Added functions to retrieve model positions in scripts.
1130
			v = 0x7FFF;
1131
		}
1132
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1133
		quint8 gateId = quint8(gateList->currentRow());
113 by myst6re
Global reorganization:
1134
		Exit old = infFile->exitLine(gateId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1135
		if (old.fieldID != v) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1136
			old.fieldID = quint16(v);
113 by myst6re
Global reorganization:
1137
			infFile->setExitLine(gateId, old);
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1138
			QListWidgetItem *item = gateList->currentItem();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1139
			if (v != 0x7FFF) {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1140
				item->setText(QString("%1 (%2)")
391 by myst6re
Show unused fields
1141
				                  .arg(Data::mapName(v))
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1142
				              .arg(v));
1143
				// Default foreground
1144
				item->setForeground(QListWidgetItem().foreground());
113 by myst6re
Global reorganization:
1145
			} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1146
				item->setText(tr("Unused"));
1147
				item->setForeground(Qt::darkGray);
113 by myst6re
Global reorganization:
1148
			}
1149
1150
			emit modified();
1151
		}
1152
	}
1153
}
1154
1155
void WalkmeshManager::editArrowDisplay(bool checked)
1156
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1157
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1158
		quint8 gateId = quint8(gateList->currentRow());
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1159
		if (infFile->arrowIsDisplayed(gateId) != checked) {
113 by myst6re
Global reorganization:
1160
			infFile->setArrowDiplay(gateId, checked);
1161
1162
			emit modified();
1163
		}
1164
	}
1165
}
1166
144 by myst6re
Added functions to retrieve model positions in scripts.
1167
void WalkmeshManager::setDoorEnabled(bool enabled)
1168
{
1169
	bgParamId->setEnabled(enabled);
1170
	bgStateId->setEnabled(enabled);
1171
	doorPosition[0]->setEnabled(enabled);
1172
	doorPosition[1]->setEnabled(enabled);
1173
	doorBehavior->setEnabled(enabled);
1174
	doorSoundId->setEnabled(enabled);
1175
}
1176
1177
void WalkmeshManager::editDoorEnabled(bool enabled)
1178
{
1179
	setDoorEnabled(enabled);
1180
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1181
	if (enabled) {
144 by myst6re
Added functions to retrieve model positions in scripts.
1182
		editParamId(fieldId->value());
1183
	} else {
1184
		editParamId(0xFF);
1185
	}
1186
}
1187
113 by myst6re
Global reorganization:
1188
void WalkmeshManager::editParamId(int v)
1189
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1190
	if (infFile->isOpen()) {
1191
		if (!doorEnabled->isChecked()) {
144 by myst6re
Added functions to retrieve model positions in scripts.
1192
			v = 0xFF;
1193
		}
1194
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1195
		quint8 gateId = quint8(doorList->currentRow());
113 by myst6re
Global reorganization:
1196
		Trigger old = infFile->trigger(gateId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1197
		if (old.background_parameter != v) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1198
			old.background_parameter = quint8(v);
113 by myst6re
Global reorganization:
1199
			infFile->setTrigger(gateId, old);
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1200
			QListWidgetItem *item = doorList->currentItem();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1201
			if (v != 0xFF) {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1202
				item->setText(tr("Door %1").arg(gateId));
1203
				// Default foreground
1204
				item->setForeground(QListWidgetItem().foreground());
113 by myst6re
Global reorganization:
1205
			} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1206
				item->setText(tr("Unused"));
1207
				item->setForeground(Qt::darkGray);
113 by myst6re
Global reorganization:
1208
			}
1209
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1210
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1211
			emit modified();
1212
		}
1213
	}
1214
}
1215
1216
void WalkmeshManager::editStateId(int v)
1217
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1218
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1219
		quint8 gateId = quint8(doorList->currentRow());
113 by myst6re
Global reorganization:
1220
		Trigger old = infFile->trigger(gateId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1221
		if (old.background_state != v) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1222
			old.background_state = quint8(v);
113 by myst6re
Global reorganization:
1223
			infFile->setTrigger(gateId, old);
1224
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1225
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1226
			emit modified();
1227
		}
1228
	}
1229
}
1230
1231
void WalkmeshManager::editBehavior(int v)
1232
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1233
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1234
		quint8 gateId = quint8(doorList->currentRow());
113 by myst6re
Global reorganization:
1235
		Trigger old = infFile->trigger(gateId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1236
		if (old.behavior != v) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1237
			old.behavior = quint8(v);
113 by myst6re
Global reorganization:
1238
			infFile->setTrigger(gateId, old);
1239
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1240
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1241
			emit modified();
1242
		}
1243
	}
1244
}
1245
1246
void WalkmeshManager::editSoundId(int v)
1247
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1248
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1249
		quint8 gateId = quint8(doorList->currentRow());
113 by myst6re
Global reorganization:
1250
		Trigger old = infFile->trigger(gateId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1251
		if (old.soundID != v) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1252
			old.soundID = quint8(v);
113 by myst6re
Global reorganization:
1253
			infFile->setTrigger(gateId, old);
1254
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1255
			if (walkmesh)	walkmesh->update();
113 by myst6re
Global reorganization:
1256
			emit modified();
1257
		}
1258
	}
1259
}
1260
1261
void WalkmeshManager::editArrowX(double value)
1262
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1263
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1264
		quint8 arrowId = quint8(arrowList->currentRow());
113 by myst6re
Global reorganization:
1265
		Arrow old = infFile->arrow(arrowId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1266
		if (old.positionX != qint32(value)) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1267
			old.positionX = qint32(value);
113 by myst6re
Global reorganization:
1268
			infFile->setArrow(arrowId, old);
1269
1270
			emit modified();
1271
		}
1272
	}
1273
}
1274
1275
void WalkmeshManager::editArrowY(double value)
1276
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1277
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1278
		quint8 arrowId = quint8(arrowList->currentRow());
113 by myst6re
Global reorganization:
1279
		Arrow old = infFile->arrow(arrowId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1280
		if (old.positionY != qint32(value)) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1281
			old.positionY = qint32(value);
113 by myst6re
Global reorganization:
1282
			infFile->setArrow(arrowId, old);
1283
1284
			emit modified();
1285
		}
1286
	}
1287
}
1288
1289
void WalkmeshManager::editArrowZ(double value)
1290
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1291
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1292
		quint8 arrowId = quint8(arrowList->currentRow());
113 by myst6re
Global reorganization:
1293
		Arrow old = infFile->arrow(arrowId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1294
		if (old.positionZ != qint32(value)) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1295
			old.positionZ = qint32(value);
113 by myst6re
Global reorganization:
1296
			infFile->setArrow(arrowId, old);
1297
1298
			emit modified();
1299
		}
1300
	}
1301
}
1302
1303
void WalkmeshManager::editArrowType(int index)
1304
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1305
	if (infFile->isOpen()) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1306
		quint8 arrowId = quint8(arrowList->currentRow());
113 by myst6re
Global reorganization:
1307
		quint32 value = arrowType->itemData(index).toUInt();
1308
		Arrow old = infFile->arrow(arrowId);
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1309
		if (old.type != value) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1310
			old.type = quint32(index);
113 by myst6re
Global reorganization:
1311
			infFile->setArrow(arrowId, old);
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1312
			QListWidgetItem *item = arrowList->currentItem();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1313
			if (index != 0) {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1314
				item->setText(tr("Arrow %1").arg(arrowId));
1315
				// Default foreground
1316
				item->setForeground(QListWidgetItem().foreground());
113 by myst6re
Global reorganization:
1317
			} else {
335.1.51 by myst6re
Set gray foreground for unused door/gateway/arrow entries
1318
				item->setText(tr("Unused"));
1319
				item->setForeground(Qt::darkGray);
113 by myst6re
Global reorganization:
1320
			}
1321
1322
			emit modified();
1323
		}
1324
	}
1325
}
1326
1327
void WalkmeshManager::editRange(int v)
1328
{
1329
	QObject *s = sender();
1330
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1331
	if (s == rangeEdit[0])			editRange(0, v);
1332
	else if (s == rangeEdit[1])		editRange(1, v);
1333
	else if (s == rangeEdit[2])		editRange(2, v);
1334
	else if (s == rangeEdit[3])		editRange(3, v);
1335
	else if (s == bgSizeEdit[0])		editBgSize(0, v);
1336
	else if (s == bgSizeEdit[1])		editBgSize(1, v);
1337
	else if (s == bgSizeEdit[2])		editBgSize(2, v);
1338
	else if (s == bgSizeEdit[3])		editBgSize(3, v);
1339
	else if (s == bgFlagEdit[0])		editBgFlag(0, v);
1340
	else if (s == bgFlagEdit[1])		editBgFlag(1, v);
1341
	else if (s == bgFlagEdit[2])		editBgFlag(2, v);
1342
	else if (s == bgFlagEdit[3])		editBgFlag(3, v);
113 by myst6re
Global reorganization:
1343
}
1344
1345
void WalkmeshManager::editRange(int id, int v)
1346
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1347
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1348
		Range old = infFile->cameraRange();
1349
		qint16 oldv=0;
1350
425 by myst6re
switch (
1351
		switch (id) {
113 by myst6re
Global reorganization:
1352
		case 0:	oldv = old.top;		break;
1353
		case 1:	oldv = old.bottom;	break;
1354
		case 2:	oldv = old.right;	break;
1355
		case 3:	oldv = old.left;	break;
1356
		}
1357
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1358
		if (oldv != v) {
425 by myst6re
switch (
1359
			switch (id) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1360
			case 0: old.top = qint16(v);    break;
1361
			case 1: old.bottom = qint16(v); break;
1362
			case 2: old.right = qint16(v);  break;
1363
			case 3: old.left = qint16(v);   break;
113 by myst6re
Global reorganization:
1364
			}
1365
			infFile->setCameraRange(old);
1366
1367
			emit modified();
1368
		}
1369
	}
1370
}
1371
1372
void WalkmeshManager::editBgSize(int id, int v)
1373
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1374
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1375
		qint16 oldv=0;
1376
425 by myst6re
switch (
1377
		switch (id) {
113 by myst6re
Global reorganization:
1378
		case 0:	oldv = infFile->bgLayer3Width();	break;
1379
		case 1:	oldv = infFile->bgLayer3Height();	break;
1380
		case 2:	oldv = infFile->bgLayer4Width();	break;
1381
		case 3:	oldv = infFile->bgLayer4Height();	break;
1382
		}
1383
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1384
		if (oldv != v) {
425 by myst6re
switch (
1385
			switch (id) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1386
			case 0: infFile->setBgLayer3Width(qint16(v));  break;
1387
			case 1: infFile->setBgLayer3Height(qint16(v)); break;
1388
			case 2: infFile->setBgLayer4Width(qint16(v));  break;
1389
			case 3: infFile->setBgLayer4Height(qint16(v)); break;
113 by myst6re
Global reorganization:
1390
			}
1391
1392
			emit modified();
1393
		}
1394
	}
1395
}
1396
1397
void WalkmeshManager::editBgFlag(int id, int v)
1398
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1399
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1400
		qint16 oldv=0;
1401
425 by myst6re
switch (
1402
		switch (id) {
113 by myst6re
Global reorganization:
1403
		case 0:	oldv = infFile->bgLayer1Flag();	break;
1404
		case 1:	oldv = infFile->bgLayer2Flag();	break;
1405
		case 2:	oldv = infFile->bgLayer3Flag();	break;
1406
		case 3:	oldv = infFile->bgLayer4Flag();	break;
1407
		}
1408
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1409
		if (oldv != v) {
425 by myst6re
switch (
1410
			switch (id) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1411
			case 0:	infFile->setBgLayer1Flag(quint8(v));	break;
1412
			case 1:	infFile->setBgLayer2Flag(quint8(v));	break;
1413
			case 2:	infFile->setBgLayer3Flag(quint8(v));	break;
1414
			case 3:	infFile->setBgLayer4Flag(quint8(v));	break;
113 by myst6re
Global reorganization:
1415
			}
1416
1417
			emit modified();
1418
		}
1419
	}
1420
}
1421
1422
void WalkmeshManager::editNavigation(int v)
1423
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1424
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1425
		int old = infFile->control();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1426
		if (old != v) {
113 by myst6re
Global reorganization:
1427
			navigation->setValue(v);
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1428
			infFile->setControl(quint8(v));
113 by myst6re
Global reorganization:
1429
1430
			emit modified();
1431
		}
1432
	}
1433
}
1434
1435
void WalkmeshManager::editCameraFocusHeight(int value)
1436
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1437
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1438
		int old = infFile->cameraFocusHeight();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1439
		if (old != value) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1440
			infFile->setCameraFocusHeight(qint16(value));
113 by myst6re
Global reorganization:
1441
			emit modified();
1442
		}
1443
	}
1444
}
1445
1446
void WalkmeshManager::editUnknown(const QByteArray &data)
1447
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1448
	if (infFile->isOpen()) {
113 by myst6re
Global reorganization:
1449
		QByteArray old = infFile->unknown();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1450
		if (old != data) {
113 by myst6re
Global reorganization:
1451
			infFile->setUnknown(data);
1452
			emit modified();
1453
		}
1454
	}
1455
}
1456
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
1457
void WalkmeshManager::editMapScale(int scale)
1458
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1459
	if (scriptsAndTexts->isOpen()) {
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
1460
		int old = scriptsAndTexts->scale();
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1461
		if (old != scale) {
356 by myst6re
Updating OpenGL widgets to Qt 5.4, with few optimizations on textures
1462
			scriptsAndTexts->setScale(quint16(scale));
317.2.4 by myst6re
Moving field scale from misc dialog to walkmesh dialog.
1463
			emit modified();
1464
		}
1465
	}
1466
}
1467
113 by myst6re
Global reorganization:
1468
void WalkmeshManager::focusInEvent(QFocusEvent *e)
1469
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1470
	if (walkmesh)	walkmesh->setFocus();
113 by myst6re
Global reorganization:
1471
	QWidget::focusInEvent(e);
1472
}
1473
1474
void WalkmeshManager::focusOutEvent(QFocusEvent *e)
1475
{
409 by myst6re
Fix style. Replacing obsolete foreach macro by standard for
1476
	if (walkmesh)	walkmesh->clearFocus();
113 by myst6re
Global reorganization:
1477
	QWidget::focusOutEvent(e);
1478
}