66 mapLayout->addWidget(imageButt, 0, 0, 1, 2); |
66 mapLayout->addWidget(imageButt, 0, 0, 1, 2); |
67 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
67 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
68 |
68 |
69 chooseMap = new QComboBox(mapWidget); |
69 chooseMap = new QComboBox(mapWidget); |
70 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
70 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
71 |
|
72 loadMapList(); |
|
73 connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(loadMapList())); |
|
74 |
|
75 connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int))); |
|
76 mapLayout->addWidget(chooseMap, 1, 1); |
|
77 |
|
78 QLabel * lblMap = new QLabel(tr("Map"), mapWidget); |
|
79 mapLayout->addWidget(lblMap, 1, 0); |
|
80 |
|
81 lblFilter = new QLabel(tr("Filter"), mapWidget); |
|
82 mapLayout->addWidget(lblFilter, 2, 0); |
|
83 |
|
84 cbTemplateFilter = new QComboBox(mapWidget); |
|
85 cbTemplateFilter->addItem(tr("All"), 0); |
|
86 cbTemplateFilter->addItem(tr("Small"), 1); |
|
87 cbTemplateFilter->addItem(tr("Medium"), 2); |
|
88 cbTemplateFilter->addItem(tr("Large"), 3); |
|
89 cbTemplateFilter->addItem(tr("Cavern"), 4); |
|
90 cbTemplateFilter->addItem(tr("Wacky"), 5); |
|
91 mapLayout->addWidget(cbTemplateFilter, 2, 1); |
|
92 |
|
93 connect(cbTemplateFilter, SIGNAL(activated(int)), this, SLOT(setTemplateFilter(int))); |
|
94 |
|
95 maze_size_label = new QLabel(tr("Type"), mapWidget); |
|
96 mapLayout->addWidget(maze_size_label, 2, 0); |
|
97 maze_size_label->hide(); |
|
98 cbMazeSize = new QComboBox(mapWidget); |
|
99 cbMazeSize->addItem(tr("Small tunnels"), 0); |
|
100 cbMazeSize->addItem(tr("Medium tunnels"), 1); |
|
101 cbMazeSize->addItem(tr("Large tunnels"), 2); |
|
102 cbMazeSize->addItem(tr("Small floating islands"), 3); |
|
103 cbMazeSize->addItem(tr("Medium floating islands"), 4); |
|
104 cbMazeSize->addItem(tr("Large floating islands"), 5); |
|
105 cbMazeSize->setCurrentIndex(1); |
|
106 |
|
107 mapLayout->addWidget(cbMazeSize, 2, 1); |
|
108 cbMazeSize->hide(); |
|
109 connect(cbMazeSize, SIGNAL(activated(int)), this, SLOT(setMazeSize(int))); |
|
110 |
|
111 gbThemes = new IconedGroupBox(mapWidget); |
|
112 gbThemes->setTitleTextPadding(80); |
|
113 gbThemes->setContentTopPadding(15); |
|
114 gbThemes->setTitle(tr("Themes")); |
|
115 |
|
116 //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
|
117 mapLayout->addWidget(gbThemes, 0, 2, 3, 1); |
|
118 |
|
119 QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
|
120 gbTLayout->setContentsMargins(0, 0, 0 ,0); |
|
121 gbTLayout->setSpacing(0); |
|
122 lvThemes = new QListView(mapWidget); |
|
123 lvThemes->setMinimumHeight(30); |
|
124 lvThemes->setFixedWidth(140); |
|
125 lvThemes->setModel(themesModel); |
|
126 lvThemes->setIconSize(QSize(16, 16)); |
|
127 lvThemes->setEditTriggers(QListView::NoEditTriggers); |
|
128 |
|
129 connect(lvThemes->selectionModel(), SIGNAL(currentRowChanged( const QModelIndex &, const QModelIndex &)), this, SLOT(themeSelected( const QModelIndex &, const QModelIndex &))); |
|
130 |
|
131 // override default style to tighten up theme scroller |
|
132 lvThemes->setStyleSheet(QString( |
|
133 "QListView{" |
|
134 "border: solid;" |
|
135 "border-width: 0px;" |
|
136 "border-radius: 0px;" |
|
137 "border-color: transparent;" |
|
138 "background-color: #0d0544;" |
|
139 "color: #ffcc00;" |
|
140 "font: bold 13px;" |
|
141 "}" |
|
142 ) |
|
143 ); |
|
144 |
|
145 gbTLayout->addWidget(lvThemes); |
|
146 lvThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
|
147 |
|
148 mapLayout->setSizeConstraint(QLayout::SetFixedSize); |
|
149 |
|
150 QWidget* seedWidget = new QWidget(this); |
|
151 mainLayout.addWidget(seedWidget, 1, 0); |
|
152 |
|
153 QGridLayout* seedLayout = new QGridLayout(seedWidget); |
|
154 seedLayout->setMargin(0); |
|
155 |
|
156 seedLabel = new QLabel(tr("Seed"), seedWidget); |
|
157 seedLayout->addWidget(seedLabel, 3, 0); |
|
158 seedEdit = new QLineEdit(seedWidget); |
|
159 seedEdit->setMaxLength(54); |
|
160 connect(seedEdit, SIGNAL(returnPressed()), this, SLOT(seedEdited())); |
|
161 seedLayout->addWidget(seedEdit, 3, 1); |
|
162 seedLayout->setColumnStretch(1, 5); |
|
163 seedSet = new QPushButton(seedWidget); |
|
164 seedSet->setText(QPushButton::tr("more")); |
|
165 connect(seedSet, SIGNAL(clicked()), this, SLOT(seedEdited())); |
|
166 seedLayout->setColumnStretch(2, 1); |
|
167 seedLayout->addWidget(seedSet, 3, 2); |
|
168 |
|
169 seedLabel->setVisible(false); |
|
170 seedEdit->setVisible(false); |
|
171 |
|
172 setRandomSeed(); |
|
173 setRandomTheme(); |
|
174 } |
|
175 |
|
176 void HWMapContainer::setImage(const QImage newImage) |
|
177 { |
|
178 QPixmap px(256, 128); |
|
179 QPixmap pxres(256, 128); |
|
180 QPainter p(&pxres); |
|
181 |
|
182 px.fill(Qt::yellow); |
|
183 QBitmap bm = QBitmap::fromImage(newImage); |
|
184 px.setMask(bm); |
|
185 |
|
186 QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
|
187 linearGrad.setColorAt(1, QColor(0, 0, 192)); |
|
188 linearGrad.setColorAt(0, QColor(66, 115, 225)); |
|
189 p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
|
190 p.drawPixmap(QPoint(0, 0), px); |
|
191 |
|
192 addInfoToPreview(pxres); |
|
193 //chooseMap->setCurrentIndex(mapgen); |
|
194 pMap = 0; |
|
195 } |
|
196 |
|
197 void HWMapContainer::setHHLimit(int newHHLimit) |
|
198 { |
|
199 hhLimit = newHHLimit; |
|
200 } |
|
201 |
|
202 void HWMapContainer::mapChanged(int index) |
|
203 { |
|
204 switch(index) |
|
205 { |
|
206 case MAPGEN_REGULAR: |
|
207 mapgen = MAPGEN_REGULAR; |
|
208 updatePreview(); |
|
209 gbThemes->show(); |
|
210 lblFilter->show(); |
|
211 cbTemplateFilter->show(); |
|
212 maze_size_label->hide(); |
|
213 cbMazeSize->hide(); |
|
214 emit mapChanged("+rnd+"); |
|
215 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
216 break; |
|
217 case MAPGEN_MAZE: |
|
218 mapgen = MAPGEN_MAZE; |
|
219 updatePreview(); |
|
220 gbThemes->show(); |
|
221 lblFilter->hide(); |
|
222 cbTemplateFilter->hide(); |
|
223 maze_size_label->show(); |
|
224 cbMazeSize->show(); |
|
225 emit mapChanged("+maze+"); |
|
226 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
227 break; |
|
228 case MAPGEN_DRAWN: |
|
229 mapgen = MAPGEN_DRAWN; |
|
230 updatePreview(); |
|
231 gbThemes->show(); |
|
232 lblFilter->hide(); |
|
233 cbTemplateFilter->hide(); |
|
234 maze_size_label->hide(); |
|
235 cbMazeSize->hide(); |
|
236 emit mapChanged("+drawn+"); |
|
237 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
238 break; |
|
239 default: |
|
240 mapgen = MAPGEN_MAP; |
|
241 updatePreview(); |
|
242 gbThemes->hide(); |
|
243 lblFilter->hide(); |
|
244 cbTemplateFilter->hide(); |
|
245 maze_size_label->hide(); |
|
246 cbMazeSize->hide(); |
|
247 emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); |
|
248 } |
|
249 |
|
250 emit mapgenChanged(mapgen); |
|
251 } |
|
252 |
|
253 // Should this add text to identify map size? |
|
254 void HWMapContainer::addInfoToPreview(QPixmap image) |
|
255 { |
|
256 QPixmap finalImage = QPixmap(image.size()); |
|
257 finalImage.fill(QColor(0, 0, 0, 0)); |
|
258 |
|
259 QPainter p(&finalImage); |
|
260 p.drawPixmap(image.rect(), image); |
|
261 //p.setPen(QColor(0xf4,0x9e,0xe9)); |
|
262 p.setPen(QColor(0xff,0xcc,0x00)); |
|
263 p.setBrush(QColor(0, 0, 0)); |
|
264 p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
|
265 p.setFont(QFont("MS Shell Dlg", 10)); |
|
266 p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
|
267 p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
268 |
|
269 imageButt->setIcon(finalImage); |
|
270 imageButt->setIconSize(image.size()); |
|
271 } |
|
272 |
|
273 void HWMapContainer::askForGeneratedPreview() |
|
274 { |
|
275 if (pMap) |
|
276 { |
|
277 disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
|
278 disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
|
279 pMap = 0; |
|
280 } |
|
281 |
|
282 pMap = new HWMap(); |
|
283 connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
|
284 connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
|
285 pMap->getImage(m_seed, |
|
286 getTemplateFilter(), |
|
287 get_mapgen(), |
|
288 getMazeSize(), |
|
289 getDrawnMapData() |
|
290 ); |
|
291 } |
|
292 |
|
293 void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) |
|
294 { |
|
295 QString theme = current.data().toString(); |
|
296 QList<QVariant> mapInfo; |
|
297 mapInfo.push_back(QString("+rnd+")); |
|
298 mapInfo.push_back(theme); |
|
299 mapInfo.push_back(18); |
|
300 mapInfo.push_back(false); |
|
301 chooseMap->setItemData(0, mapInfo); |
|
302 mapInfo[0] = QString("+maze+"); |
|
303 chooseMap->setItemData(1, mapInfo); |
|
304 mapInfo[0] = QString("+drawn+"); |
|
305 chooseMap->setItemData(2, mapInfo); |
|
306 |
|
307 gbThemes->setIcon(qVariantValue<QIcon>(current.data(Qt::UserRole))); |
|
308 emit themeChanged(theme); |
|
309 } |
|
310 |
|
311 QString HWMapContainer::getCurrentSeed() const |
|
312 { |
|
313 return m_seed; |
|
314 } |
|
315 |
|
316 QString HWMapContainer::getCurrentMap() const |
|
317 { |
|
318 if(chooseMap->currentIndex() < MAPGEN_MAP) return QString(); |
|
319 return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
|
320 } |
|
321 |
|
322 QString HWMapContainer::getCurrentTheme() const |
|
323 { |
|
324 return chooseMap->itemData(chooseMap->currentIndex()).toList()[1].toString(); |
|
325 } |
|
326 |
|
327 bool HWMapContainer::getCurrentIsMission() const |
|
328 { |
|
329 if(!chooseMap->currentIndex()) return false; |
|
330 return chooseMap->itemData(chooseMap->currentIndex()).toList()[3].toBool(); |
|
331 } |
|
332 |
|
333 int HWMapContainer::getCurrentHHLimit() const |
|
334 { |
|
335 return hhLimit; |
|
336 } |
|
337 |
|
338 QString HWMapContainer::getCurrentScheme() const |
|
339 { |
|
340 return chooseMap->itemData(chooseMap->currentIndex()).toList()[4].toString(); |
|
341 } |
|
342 |
|
343 QString HWMapContainer::getCurrentWeapons() const |
|
344 { |
|
345 return chooseMap->itemData(chooseMap->currentIndex()).toList()[5].toString(); |
|
346 } |
|
347 |
|
348 quint32 HWMapContainer::getTemplateFilter() const |
|
349 { |
|
350 return cbTemplateFilter->itemData(cbTemplateFilter->currentIndex()).toInt(); |
|
351 } |
|
352 |
|
353 void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
|
354 { |
|
355 Q_UNUSED(event); |
|
356 //imageButt->setIconSize(imageButt->size()); |
|
357 } |
|
358 |
|
359 void HWMapContainer::intSetSeed(const QString & seed) |
|
360 { |
|
361 m_seed = seed; |
|
362 if (seed != seedEdit->text()) |
|
363 seedEdit->setText(seed); |
|
364 } |
|
365 |
|
366 void HWMapContainer::setSeed(const QString & seed) |
|
367 { |
|
368 intSetSeed(seed); |
|
369 if (chooseMap->currentIndex() < MAPGEN_DRAWN) |
|
370 updatePreview(); |
|
371 } |
|
372 |
|
373 void HWMapContainer::intSetMap(const QString & map) |
|
374 { |
|
375 int id = 0; |
|
376 for(int i = 0; i < chooseMap->count(); i++) |
|
377 if(!chooseMap->itemData(i).isNull() && chooseMap->itemData(i).toList()[0].toString() == map) |
|
378 { |
|
379 id = i; |
|
380 break; |
|
381 } |
|
382 |
|
383 if(id > 0) |
|
384 { |
|
385 if (pMap) |
|
386 { |
|
387 disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
|
388 disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
|
389 pMap = 0; |
|
390 } |
|
391 chooseMap->setCurrentIndex(id); |
|
392 } |
|
393 } |
|
394 |
|
395 void HWMapContainer::setMap(const QString &map) |
|
396 { |
|
397 intSetMap(map); |
|
398 updatePreview(); |
|
399 } |
|
400 |
|
401 void HWMapContainer::setTheme(const QString & theme) |
|
402 { |
|
403 QModelIndexList mdl = themesModel->match(themesModel->index(0), Qt::DisplayRole, theme); |
|
404 |
|
405 if(mdl.size()) |
|
406 lvThemes->setCurrentIndex(mdl.at(0)); |
|
407 } |
|
408 |
|
409 void HWMapContainer::setRandomMap() |
|
410 { |
|
411 setRandomSeed(); |
|
412 switch(chooseMap->currentIndex()) |
|
413 { |
|
414 case MAPGEN_REGULAR: |
|
415 case MAPGEN_MAZE: |
|
416 setRandomTheme(); |
|
417 break; |
|
418 case MAPGEN_DRAWN: |
|
419 emit drawMapRequested(); |
|
420 break; |
|
421 default: |
|
422 if(chooseMap->currentIndex() <= numMissions + MAPGEN_MAP + 1) |
|
423 setRandomMission(); |
|
424 else |
|
425 setRandomStatic(); |
|
426 break; |
|
427 } |
|
428 } |
|
429 |
|
430 void HWMapContainer::setRandomStatic() |
|
431 { |
|
432 int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); |
|
433 chooseMap->setCurrentIndex(i); |
|
434 mapChanged(i); |
|
435 } |
|
436 |
|
437 void HWMapContainer::setRandomMission() |
|
438 { |
|
439 int i = MAPGEN_MAP + 2 + rand() % numMissions; |
|
440 chooseMap->setCurrentIndex(i); |
|
441 mapChanged(i); |
|
442 } |
|
443 |
|
444 void HWMapContainer::setRandomSeed() |
|
445 { |
|
446 m_seed = QUuid::createUuid().toString(); |
|
447 seedEdit->setText(m_seed); |
|
448 emit seedChanged(m_seed); |
|
449 if (chooseMap->currentIndex() < MAPGEN_MAP) |
|
450 updatePreview(); |
|
451 } |
|
452 |
|
453 void HWMapContainer::setRandomTheme() |
|
454 { |
|
455 if(!themesModel->rowCount()) return; |
|
456 quint32 themeNum = rand() % themesModel->rowCount(); |
|
457 lvThemes->setCurrentIndex(themesModel->index(themeNum)); |
|
458 } |
|
459 |
|
460 void HWMapContainer::intSetTemplateFilter(int filter) |
|
461 { |
|
462 cbTemplateFilter->setCurrentIndex(filter); |
|
463 emit newTemplateFilter(filter); |
|
464 } |
|
465 |
|
466 void HWMapContainer::setTemplateFilter(int filter) |
|
467 { |
|
468 intSetTemplateFilter(filter); |
|
469 updatePreview(); |
|
470 } |
|
471 |
|
472 MapGenerator HWMapContainer::get_mapgen(void) const |
|
473 { |
|
474 return mapgen; |
|
475 } |
|
476 |
|
477 int HWMapContainer::getMazeSize(void) const |
|
478 { |
|
479 return cbMazeSize->currentIndex(); |
|
480 } |
|
481 |
|
482 void HWMapContainer::intSetMazeSize(int size) |
|
483 { |
|
484 cbMazeSize->setCurrentIndex(size); |
|
485 emit mazeSizeChanged(size); |
|
486 } |
|
487 |
|
488 void HWMapContainer::setMazeSize(int size) |
|
489 { |
|
490 intSetMazeSize(size); |
|
491 updatePreview(); |
|
492 } |
|
493 |
|
494 void HWMapContainer::intSetMapgen(MapGenerator m) |
|
495 { |
|
496 mapgen = m; |
|
497 |
|
498 if(m != MAPGEN_MAP) |
|
499 chooseMap->setCurrentIndex(m); |
|
500 |
|
501 emit mapgenChanged(m); |
|
502 } |
|
503 |
|
504 void HWMapContainer::setMapgen(MapGenerator m) |
|
505 { |
|
506 intSetMapgen(m); |
|
507 updatePreview(); |
|
508 } |
|
509 |
|
510 void HWMapContainer::setDrawnMapData(const QByteArray & ar) |
|
511 { |
|
512 drawMapScene.decode(ar); |
|
513 updatePreview(); |
|
514 } |
|
515 |
|
516 QByteArray HWMapContainer::getDrawnMapData() |
|
517 { |
|
518 return drawMapScene.encode(); |
|
519 } |
|
520 |
|
521 void HWMapContainer::seedEdited() |
|
522 { |
|
523 if (seedLabel->isVisible() == false ) |
|
524 { |
|
525 seedLabel->setVisible(true); |
|
526 seedEdit->setVisible(true); |
|
527 seedSet->setText(tr("Set")); |
|
528 return; |
|
529 } |
|
530 |
|
531 if (seedEdit->text().isEmpty()) |
|
532 seedEdit->setText(m_seed); |
|
533 else |
|
534 { |
|
535 setSeed(seedEdit->text()); |
|
536 emit seedChanged(seedEdit->text()); |
|
537 } |
|
538 } |
|
539 |
|
540 DrawMapScene * HWMapContainer::getDrawMapScene() |
|
541 { |
|
542 return &drawMapScene; |
|
543 } |
|
544 |
|
545 void HWMapContainer::mapDrawingFinished() |
|
546 { |
|
547 emit drawnMapChanged(getDrawnMapData()); |
|
548 |
|
549 updatePreview(); |
|
550 } |
|
551 |
|
552 void HWMapContainer::updatePreview() |
|
553 { |
|
554 int curIndex = chooseMap->currentIndex(); |
|
555 |
|
556 switch(curIndex) |
|
557 { |
|
558 case MAPGEN_REGULAR: |
|
559 askForGeneratedPreview(); |
|
560 break; |
|
561 case MAPGEN_MAZE: |
|
562 askForGeneratedPreview(); |
|
563 break; |
|
564 case MAPGEN_DRAWN: |
|
565 askForGeneratedPreview(); |
|
566 break; |
|
567 default: |
|
568 QPixmap mapImage; |
|
569 QFile tmpfile; |
|
570 tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
|
571 if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
|
572 if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) |
|
573 { |
|
574 imageButt->setIcon(QIcon()); |
|
575 return; |
|
576 } |
|
577 |
|
578 hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt(); |
|
579 addInfoToPreview(mapImage); |
|
580 } |
|
581 } |
|
582 |
|
583 void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl) |
|
584 { |
|
585 intSetMap(map); |
|
586 intSetMapgen(m); |
|
587 intSetMazeSize(mazesize); |
|
588 intSetSeed(seed); |
|
589 intSetTemplateFilter(tmpl); |
|
590 |
|
591 updatePreview(); |
|
592 } |
|
593 |
|
594 |
|
595 void HWMapContainer::loadMapList() |
|
596 { |
|
597 // TODO: convert to model |
|
598 |
|
599 // remember previous selection |
|
600 QString selMap = getCurrentMap(); |
|
601 |
|
602 chooseMap->clear(); |
|
603 |
71 chooseMap->addItem( |
604 chooseMap->addItem( |
72 // FIXME - need real icons. Disabling until then |
605 // FIXME - need real icons. Disabling until then |
73 //QIcon(":/res/mapRandom.png"), |
606 //QIcon(":/res/mapRandom.png"), |
74 QComboBox::tr("generated map...")); |
607 QComboBox::tr("generated map...")); |
75 chooseMap->addItem( |
608 chooseMap->addItem( |
76 // FIXME - need real icons. Disabling until then |
609 // FIXME - need real icons. Disabling until then |
77 //QIcon(":/res/mapMaze.png"), |
610 //QIcon(":/res/mapMaze.png"), |
78 QComboBox::tr("generated maze...")); |
611 QComboBox::tr("generated maze...")); |
79 |
612 |
80 chooseMap->addItem(QComboBox::tr("hand drawn map...")); |
613 chooseMap->addItem(QComboBox::tr("hand drawn map...")); |
|
614 |
81 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
615 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
82 |
|
83 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
616 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
84 |
617 |
85 int missionindex = chooseMap->count(); |
618 int missionindex = chooseMap->count(); |
86 numMissions = 0; |
619 numMissions = 0; |
87 QFile mapLuaFile; |
620 QFile mapLuaFile; |
88 QFile mapCfgFile; |
621 QFile mapCfgFile; |
89 for (int i = 0; i < mapList->size(); ++i) |
622 |
90 { |
623 DataManager & dataMgr = DataManager::instance(); |
91 QString map = (*mapList)[i]; |
624 |
|
625 QStringList mapList = dataMgr.entryList( |
|
626 QString("Maps"), |
|
627 QDir::Dirs | QDir::NoDotAndDotDot |
|
628 ); |
|
629 |
|
630 foreach (QString map, mapList) |
|
631 { |
92 mapCfgFile.setFileName( |
632 mapCfgFile.setFileName( |
93 QString("%1/Data/Maps/%2/map.cfg") |
633 dataMgr.findFileForRead(QString("Maps/%1/map.cfg").arg(map))); |
94 .arg(cfgdir->absolutePath()) |
634 mapLuaFile.setFileName( |
95 .arg(map)); |
635 dataMgr.findFileForRead(QString("Maps/%1/map.lua").arg(map))); |
96 if (mapCfgFile.exists()) |
|
97 { |
|
98 mapLuaFile.setFileName( |
|
99 QString("%1/Data/Maps/%2/map.lua") |
|
100 .arg(cfgdir->absolutePath()) |
|
101 .arg(map)); |
|
102 } |
|
103 else |
|
104 { |
|
105 mapCfgFile.setFileName( |
|
106 QString("%1/Maps/%2/map.cfg") |
|
107 .arg(datadir->absolutePath()) |
|
108 .arg(map)); |
|
109 mapLuaFile.setFileName( |
|
110 QString("%1/Maps/%2/map.lua") |
|
111 .arg(datadir->absolutePath()) |
|
112 .arg(map)); |
|
113 } |
|
114 |
636 |
115 if (mapCfgFile.open(QFile::ReadOnly)) |
637 if (mapCfgFile.open(QFile::ReadOnly)) |
116 { |
638 { |
117 QString theme; |
639 QString theme; |
118 quint32 limit = 0; |
640 quint32 limit = 0; |
161 //QIcon(":/res/mapCustom.png"), |
683 //QIcon(":/res/mapCustom.png"), |
162 map, mapInfo); |
684 map, mapInfo); |
163 mapCfgFile.close(); |
685 mapCfgFile.close(); |
164 } |
686 } |
165 } |
687 } |
|
688 |
166 chooseMap->insertSeparator(missionindex); // separator between missions and maps |
689 chooseMap->insertSeparator(missionindex); // separator between missions and maps |
167 |
690 |
168 connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int))); |
691 // if a map was selected already let's reselect it after reloading the map list |
169 mapLayout->addWidget(chooseMap, 1, 1); |
692 if (!selMap.isEmpty()) { |
170 |
693 setMap(selMap); |
171 QLabel * lblMap = new QLabel(tr("Map"), mapWidget); |
694 } |
172 mapLayout->addWidget(lblMap, 1, 0); |
695 } |
173 |
|
174 lblFilter = new QLabel(tr("Filter"), mapWidget); |
|
175 mapLayout->addWidget(lblFilter, 2, 0); |
|
176 |
|
177 cbTemplateFilter = new QComboBox(mapWidget); |
|
178 cbTemplateFilter->addItem(tr("All"), 0); |
|
179 cbTemplateFilter->addItem(tr("Small"), 1); |
|
180 cbTemplateFilter->addItem(tr("Medium"), 2); |
|
181 cbTemplateFilter->addItem(tr("Large"), 3); |
|
182 cbTemplateFilter->addItem(tr("Cavern"), 4); |
|
183 cbTemplateFilter->addItem(tr("Wacky"), 5); |
|
184 mapLayout->addWidget(cbTemplateFilter, 2, 1); |
|
185 |
|
186 connect(cbTemplateFilter, SIGNAL(activated(int)), this, SLOT(setTemplateFilter(int))); |
|
187 |
|
188 maze_size_label = new QLabel(tr("Type"), mapWidget); |
|
189 mapLayout->addWidget(maze_size_label, 2, 0); |
|
190 maze_size_label->hide(); |
|
191 cbMazeSize = new QComboBox(mapWidget); |
|
192 cbMazeSize->addItem(tr("Small tunnels"), 0); |
|
193 cbMazeSize->addItem(tr("Medium tunnels"), 1); |
|
194 cbMazeSize->addItem(tr("Large tunnels"), 2); |
|
195 cbMazeSize->addItem(tr("Small floating islands"), 3); |
|
196 cbMazeSize->addItem(tr("Medium floating islands"), 4); |
|
197 cbMazeSize->addItem(tr("Large floating islands"), 5); |
|
198 cbMazeSize->setCurrentIndex(1); |
|
199 |
|
200 mapLayout->addWidget(cbMazeSize, 2, 1); |
|
201 cbMazeSize->hide(); |
|
202 connect(cbMazeSize, SIGNAL(activated(int)), this, SLOT(setMazeSize(int))); |
|
203 |
|
204 gbThemes = new IconedGroupBox(mapWidget); |
|
205 gbThemes->setTitleTextPadding(80); |
|
206 gbThemes->setContentTopPadding(15); |
|
207 gbThemes->setTitle(tr("Themes")); |
|
208 |
|
209 //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
|
210 mapLayout->addWidget(gbThemes, 0, 2, 3, 1); |
|
211 |
|
212 QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
|
213 gbTLayout->setContentsMargins(0, 0, 0 ,0); |
|
214 gbTLayout->setSpacing(0); |
|
215 lvThemes = new QListView(mapWidget); |
|
216 lvThemes->setMinimumHeight(30); |
|
217 lvThemes->setFixedWidth(140); |
|
218 lvThemes->setModel(themesModel); |
|
219 lvThemes->setIconSize(QSize(16, 16)); |
|
220 lvThemes->setEditTriggers(QListView::NoEditTriggers); |
|
221 |
|
222 connect(lvThemes->selectionModel(), SIGNAL(currentRowChanged( const QModelIndex &, const QModelIndex &)), this, SLOT(themeSelected( const QModelIndex &, const QModelIndex &))); |
|
223 |
|
224 // override default style to tighten up theme scroller |
|
225 lvThemes->setStyleSheet(QString( |
|
226 "QListView{" |
|
227 "border: solid;" |
|
228 "border-width: 0px;" |
|
229 "border-radius: 0px;" |
|
230 "border-color: transparent;" |
|
231 "background-color: #0d0544;" |
|
232 "color: #ffcc00;" |
|
233 "font: bold 13px;" |
|
234 "}" |
|
235 ) |
|
236 ); |
|
237 |
|
238 gbTLayout->addWidget(lvThemes); |
|
239 lvThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
|
240 |
|
241 mapLayout->setSizeConstraint(QLayout::SetFixedSize); |
|
242 |
|
243 QWidget* seedWidget = new QWidget(this); |
|
244 mainLayout.addWidget(seedWidget, 1, 0); |
|
245 |
|
246 QGridLayout* seedLayout = new QGridLayout(seedWidget); |
|
247 seedLayout->setMargin(0); |
|
248 |
|
249 seedLabel = new QLabel(tr("Seed"), seedWidget); |
|
250 seedLayout->addWidget(seedLabel, 3, 0); |
|
251 seedEdit = new QLineEdit(seedWidget); |
|
252 seedEdit->setMaxLength(54); |
|
253 connect(seedEdit, SIGNAL(returnPressed()), this, SLOT(seedEdited())); |
|
254 seedLayout->addWidget(seedEdit, 3, 1); |
|
255 seedLayout->setColumnStretch(1, 5); |
|
256 seedSet = new QPushButton(seedWidget); |
|
257 seedSet->setText(QPushButton::tr("more")); |
|
258 connect(seedSet, SIGNAL(clicked()), this, SLOT(seedEdited())); |
|
259 seedLayout->setColumnStretch(2, 1); |
|
260 seedLayout->addWidget(seedSet, 3, 2); |
|
261 |
|
262 seedLabel->setVisible(false); |
|
263 seedEdit->setVisible(false); |
|
264 |
|
265 setRandomSeed(); |
|
266 setRandomTheme(); |
|
267 } |
|
268 |
|
269 void HWMapContainer::setImage(const QImage newImage) |
|
270 { |
|
271 QPixmap px(256, 128); |
|
272 QPixmap pxres(256, 128); |
|
273 QPainter p(&pxres); |
|
274 |
|
275 px.fill(Qt::yellow); |
|
276 QBitmap bm = QBitmap::fromImage(newImage); |
|
277 px.setMask(bm); |
|
278 |
|
279 QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
|
280 linearGrad.setColorAt(1, QColor(0, 0, 192)); |
|
281 linearGrad.setColorAt(0, QColor(66, 115, 225)); |
|
282 p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
|
283 p.drawPixmap(QPoint(0, 0), px); |
|
284 |
|
285 addInfoToPreview(pxres); |
|
286 //chooseMap->setCurrentIndex(mapgen); |
|
287 pMap = 0; |
|
288 } |
|
289 |
|
290 void HWMapContainer::setHHLimit(int newHHLimit) |
|
291 { |
|
292 hhLimit = newHHLimit; |
|
293 } |
|
294 |
|
295 void HWMapContainer::mapChanged(int index) |
|
296 { |
|
297 switch(index) |
|
298 { |
|
299 case MAPGEN_REGULAR: |
|
300 mapgen = MAPGEN_REGULAR; |
|
301 updatePreview(); |
|
302 gbThemes->show(); |
|
303 lblFilter->show(); |
|
304 cbTemplateFilter->show(); |
|
305 maze_size_label->hide(); |
|
306 cbMazeSize->hide(); |
|
307 emit mapChanged("+rnd+"); |
|
308 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
309 break; |
|
310 case MAPGEN_MAZE: |
|
311 mapgen = MAPGEN_MAZE; |
|
312 updatePreview(); |
|
313 gbThemes->show(); |
|
314 lblFilter->hide(); |
|
315 cbTemplateFilter->hide(); |
|
316 maze_size_label->show(); |
|
317 cbMazeSize->show(); |
|
318 emit mapChanged("+maze+"); |
|
319 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
320 break; |
|
321 case MAPGEN_DRAWN: |
|
322 mapgen = MAPGEN_DRAWN; |
|
323 updatePreview(); |
|
324 gbThemes->show(); |
|
325 lblFilter->hide(); |
|
326 cbTemplateFilter->hide(); |
|
327 maze_size_label->hide(); |
|
328 cbMazeSize->hide(); |
|
329 emit mapChanged("+drawn+"); |
|
330 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
331 break; |
|
332 default: |
|
333 mapgen = MAPGEN_MAP; |
|
334 updatePreview(); |
|
335 gbThemes->hide(); |
|
336 lblFilter->hide(); |
|
337 cbTemplateFilter->hide(); |
|
338 maze_size_label->hide(); |
|
339 cbMazeSize->hide(); |
|
340 emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); |
|
341 } |
|
342 |
|
343 emit mapgenChanged(mapgen); |
|
344 } |
|
345 |
|
346 // Should this add text to identify map size? |
|
347 void HWMapContainer::addInfoToPreview(QPixmap image) |
|
348 { |
|
349 QPixmap finalImage = QPixmap(image.size()); |
|
350 finalImage.fill(QColor(0, 0, 0, 0)); |
|
351 |
|
352 QPainter p(&finalImage); |
|
353 p.drawPixmap(image.rect(), image); |
|
354 //p.setPen(QColor(0xf4,0x9e,0xe9)); |
|
355 p.setPen(QColor(0xff,0xcc,0x00)); |
|
356 p.setBrush(QColor(0, 0, 0)); |
|
357 p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
|
358 p.setFont(QFont("MS Shell Dlg", 10)); |
|
359 p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
|
360 p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
361 |
|
362 imageButt->setIcon(finalImage); |
|
363 imageButt->setIconSize(image.size()); |
|
364 } |
|
365 |
|
366 void HWMapContainer::askForGeneratedPreview() |
|
367 { |
|
368 if (pMap) |
|
369 { |
|
370 disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
|
371 disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
|
372 pMap = 0; |
|
373 } |
|
374 |
|
375 pMap = new HWMap(); |
|
376 connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
|
377 connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
|
378 pMap->getImage(m_seed, |
|
379 getTemplateFilter(), |
|
380 get_mapgen(), |
|
381 getMazeSize(), |
|
382 getDrawnMapData() |
|
383 ); |
|
384 } |
|
385 |
|
386 void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) |
|
387 { |
|
388 QString theme = current.data().toString(); |
|
389 QList<QVariant> mapInfo; |
|
390 mapInfo.push_back(QString("+rnd+")); |
|
391 mapInfo.push_back(theme); |
|
392 mapInfo.push_back(18); |
|
393 mapInfo.push_back(false); |
|
394 chooseMap->setItemData(0, mapInfo); |
|
395 mapInfo[0] = QString("+maze+"); |
|
396 chooseMap->setItemData(1, mapInfo); |
|
397 mapInfo[0] = QString("+drawn+"); |
|
398 chooseMap->setItemData(2, mapInfo); |
|
399 |
|
400 gbThemes->setIcon(qVariantValue<QIcon>(current.data(Qt::UserRole))); |
|
401 emit themeChanged(theme); |
|
402 } |
|
403 |
|
404 QString HWMapContainer::getCurrentSeed() const |
|
405 { |
|
406 return m_seed; |
|
407 } |
|
408 |
|
409 QString HWMapContainer::getCurrentMap() const |
|
410 { |
|
411 if(chooseMap->currentIndex() < MAPGEN_MAP) return QString(); |
|
412 return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
|
413 } |
|
414 |
|
415 QString HWMapContainer::getCurrentTheme() const |
|
416 { |
|
417 return chooseMap->itemData(chooseMap->currentIndex()).toList()[1].toString(); |
|
418 } |
|
419 |
|
420 bool HWMapContainer::getCurrentIsMission() const |
|
421 { |
|
422 if(!chooseMap->currentIndex()) return false; |
|
423 return chooseMap->itemData(chooseMap->currentIndex()).toList()[3].toBool(); |
|
424 } |
|
425 |
|
426 int HWMapContainer::getCurrentHHLimit() const |
|
427 { |
|
428 return hhLimit; |
|
429 } |
|
430 |
|
431 QString HWMapContainer::getCurrentScheme() const |
|
432 { |
|
433 return chooseMap->itemData(chooseMap->currentIndex()).toList()[4].toString(); |
|
434 } |
|
435 |
|
436 QString HWMapContainer::getCurrentWeapons() const |
|
437 { |
|
438 return chooseMap->itemData(chooseMap->currentIndex()).toList()[5].toString(); |
|
439 } |
|
440 |
|
441 quint32 HWMapContainer::getTemplateFilter() const |
|
442 { |
|
443 return cbTemplateFilter->itemData(cbTemplateFilter->currentIndex()).toInt(); |
|
444 } |
|
445 |
|
446 void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
|
447 { |
|
448 Q_UNUSED(event); |
|
449 //imageButt->setIconSize(imageButt->size()); |
|
450 } |
|
451 |
|
452 void HWMapContainer::intSetSeed(const QString & seed) |
|
453 { |
|
454 m_seed = seed; |
|
455 if (seed != seedEdit->text()) |
|
456 seedEdit->setText(seed); |
|
457 } |
|
458 |
|
459 void HWMapContainer::setSeed(const QString & seed) |
|
460 { |
|
461 intSetSeed(seed); |
|
462 if (chooseMap->currentIndex() < MAPGEN_DRAWN) |
|
463 updatePreview(); |
|
464 } |
|
465 |
|
466 void HWMapContainer::intSetMap(const QString & map) |
|
467 { |
|
468 int id = 0; |
|
469 for(int i = 0; i < chooseMap->count(); i++) |
|
470 if(!chooseMap->itemData(i).isNull() && chooseMap->itemData(i).toList()[0].toString() == map) |
|
471 { |
|
472 id = i; |
|
473 break; |
|
474 } |
|
475 |
|
476 if(id > 0) |
|
477 { |
|
478 if (pMap) |
|
479 { |
|
480 disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
|
481 disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
|
482 pMap = 0; |
|
483 } |
|
484 chooseMap->setCurrentIndex(id); |
|
485 } |
|
486 } |
|
487 |
|
488 void HWMapContainer::setMap(const QString &map) |
|
489 { |
|
490 intSetMap(map); |
|
491 updatePreview(); |
|
492 } |
|
493 |
|
494 void HWMapContainer::setTheme(const QString & theme) |
|
495 { |
|
496 QModelIndexList mdl = themesModel->match(themesModel->index(0), Qt::DisplayRole, theme); |
|
497 |
|
498 if(mdl.size()) |
|
499 lvThemes->setCurrentIndex(mdl.at(0)); |
|
500 } |
|
501 |
|
502 void HWMapContainer::setRandomMap() |
|
503 { |
|
504 setRandomSeed(); |
|
505 switch(chooseMap->currentIndex()) |
|
506 { |
|
507 case MAPGEN_REGULAR: |
|
508 case MAPGEN_MAZE: |
|
509 setRandomTheme(); |
|
510 break; |
|
511 case MAPGEN_DRAWN: |
|
512 emit drawMapRequested(); |
|
513 break; |
|
514 default: |
|
515 if(chooseMap->currentIndex() <= numMissions + MAPGEN_MAP + 1) |
|
516 setRandomMission(); |
|
517 else |
|
518 setRandomStatic(); |
|
519 break; |
|
520 } |
|
521 } |
|
522 |
|
523 void HWMapContainer::setRandomStatic() |
|
524 { |
|
525 int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); |
|
526 chooseMap->setCurrentIndex(i); |
|
527 mapChanged(i); |
|
528 } |
|
529 |
|
530 void HWMapContainer::setRandomMission() |
|
531 { |
|
532 int i = MAPGEN_MAP + 2 + rand() % numMissions; |
|
533 chooseMap->setCurrentIndex(i); |
|
534 mapChanged(i); |
|
535 } |
|
536 |
|
537 void HWMapContainer::setRandomSeed() |
|
538 { |
|
539 m_seed = QUuid::createUuid().toString(); |
|
540 seedEdit->setText(m_seed); |
|
541 emit seedChanged(m_seed); |
|
542 if (chooseMap->currentIndex() < MAPGEN_MAP) |
|
543 updatePreview(); |
|
544 } |
|
545 |
|
546 void HWMapContainer::setRandomTheme() |
|
547 { |
|
548 if(!themesModel->rowCount()) return; |
|
549 quint32 themeNum = rand() % themesModel->rowCount(); |
|
550 lvThemes->setCurrentIndex(themesModel->index(themeNum)); |
|
551 } |
|
552 |
|
553 void HWMapContainer::intSetTemplateFilter(int filter) |
|
554 { |
|
555 cbTemplateFilter->setCurrentIndex(filter); |
|
556 emit newTemplateFilter(filter); |
|
557 } |
|
558 |
|
559 void HWMapContainer::setTemplateFilter(int filter) |
|
560 { |
|
561 intSetTemplateFilter(filter); |
|
562 updatePreview(); |
|
563 } |
|
564 |
|
565 MapGenerator HWMapContainer::get_mapgen(void) const |
|
566 { |
|
567 return mapgen; |
|
568 } |
|
569 |
|
570 int HWMapContainer::getMazeSize(void) const |
|
571 { |
|
572 return cbMazeSize->currentIndex(); |
|
573 } |
|
574 |
|
575 void HWMapContainer::intSetMazeSize(int size) |
|
576 { |
|
577 cbMazeSize->setCurrentIndex(size); |
|
578 emit mazeSizeChanged(size); |
|
579 } |
|
580 |
|
581 void HWMapContainer::setMazeSize(int size) |
|
582 { |
|
583 intSetMazeSize(size); |
|
584 updatePreview(); |
|
585 } |
|
586 |
|
587 void HWMapContainer::intSetMapgen(MapGenerator m) |
|
588 { |
|
589 mapgen = m; |
|
590 |
|
591 if(m != MAPGEN_MAP) |
|
592 chooseMap->setCurrentIndex(m); |
|
593 |
|
594 emit mapgenChanged(m); |
|
595 } |
|
596 |
|
597 void HWMapContainer::setMapgen(MapGenerator m) |
|
598 { |
|
599 intSetMapgen(m); |
|
600 updatePreview(); |
|
601 } |
|
602 |
|
603 void HWMapContainer::setDrawnMapData(const QByteArray & ar) |
|
604 { |
|
605 drawMapScene.decode(ar); |
|
606 updatePreview(); |
|
607 } |
|
608 |
|
609 QByteArray HWMapContainer::getDrawnMapData() |
|
610 { |
|
611 return drawMapScene.encode(); |
|
612 } |
|
613 |
|
614 void HWMapContainer::seedEdited() |
|
615 { |
|
616 if (seedLabel->isVisible() == false ) |
|
617 { |
|
618 seedLabel->setVisible(true); |
|
619 seedEdit->setVisible(true); |
|
620 seedSet->setText(tr("Set")); |
|
621 return; |
|
622 } |
|
623 |
|
624 if (seedEdit->text().isEmpty()) |
|
625 seedEdit->setText(m_seed); |
|
626 else |
|
627 { |
|
628 setSeed(seedEdit->text()); |
|
629 emit seedChanged(seedEdit->text()); |
|
630 } |
|
631 } |
|
632 |
|
633 DrawMapScene * HWMapContainer::getDrawMapScene() |
|
634 { |
|
635 return &drawMapScene; |
|
636 } |
|
637 |
|
638 void HWMapContainer::mapDrawingFinished() |
|
639 { |
|
640 emit drawnMapChanged(getDrawnMapData()); |
|
641 |
|
642 updatePreview(); |
|
643 } |
|
644 |
|
645 void HWMapContainer::updatePreview() |
|
646 { |
|
647 int curIndex = chooseMap->currentIndex(); |
|
648 |
|
649 switch(curIndex) |
|
650 { |
|
651 case MAPGEN_REGULAR: |
|
652 askForGeneratedPreview(); |
|
653 break; |
|
654 case MAPGEN_MAZE: |
|
655 askForGeneratedPreview(); |
|
656 break; |
|
657 case MAPGEN_DRAWN: |
|
658 askForGeneratedPreview(); |
|
659 break; |
|
660 default: |
|
661 QPixmap mapImage; |
|
662 QFile tmpfile; |
|
663 tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
|
664 if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
|
665 if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) |
|
666 { |
|
667 imageButt->setIcon(QIcon()); |
|
668 return; |
|
669 } |
|
670 |
|
671 hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt(); |
|
672 addInfoToPreview(mapImage); |
|
673 } |
|
674 } |
|
675 |
|
676 void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl) |
|
677 { |
|
678 intSetMap(map); |
|
679 intSetMapgen(m); |
|
680 intSetMazeSize(mazesize); |
|
681 intSetSeed(seed); |
|
682 intSetTemplateFilter(tmpl); |
|
683 |
|
684 updatePreview(); |
|
685 } |
|