victoryconditions.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. * victoryconditions.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "victoryconditions.h"
  12. #include "ui_victoryconditions.h"
  13. #include "../mapcontroller.h"
  14. #include "../lib/CGeneralTextHandler.h"
  15. #include "../lib/constants/StringConstants.h"
  16. #include "../../lib/mapObjects/CGCreature.h"
  17. #include "../inspector/townbulidingswidget.h" //to convert BuildingID to string
  18. VictoryConditions::VictoryConditions(QWidget *parent) :
  19. AbstractSettings(parent),
  20. ui(new Ui::VictoryConditions)
  21. {
  22. ui->setupUi(this);
  23. }
  24. void VictoryConditions::initialize(MapController & c)
  25. {
  26. AbstractSettings::initialize(c);
  27. //victory message
  28. ui->victoryMessageEdit->setText(QString::fromStdString(controller->map()->victoryMessage.toString()));
  29. //victory conditions
  30. const std::array<std::string, 9> conditionStringsWin = {
  31. QT_TR_NOOP("No special victory"),
  32. QT_TR_NOOP("Capture artifact"),
  33. QT_TR_NOOP("Hire creatures"),
  34. QT_TR_NOOP("Accumulate resources"),
  35. QT_TR_NOOP("Construct building"),
  36. QT_TR_NOOP("Capture town"),
  37. QT_TR_NOOP("Defeat hero"),
  38. QT_TR_NOOP("Transport artifact"),
  39. QT_TR_NOOP("Kill monster")
  40. };
  41. for(auto & s : conditionStringsWin)
  42. {
  43. ui->victoryComboBox->addItem(QString::fromStdString(s));
  44. }
  45. ui->standardVictoryCheck->setChecked(false);
  46. ui->onlyForHumansCheck->setChecked(false);
  47. for(auto & ev : controller->map()->triggeredEvents)
  48. {
  49. if(ev.effect.type == EventEffect::VICTORY)
  50. {
  51. if(ev.identifier == "standardVictory")
  52. ui->standardVictoryCheck->setChecked(true);
  53. if(ev.identifier == "specialVictory")
  54. {
  55. auto readjson = ev.trigger.toJson(AbstractSettings::conditionToJson);
  56. auto linearNodes = linearJsonArray(readjson);
  57. for(auto & json : linearNodes)
  58. {
  59. switch(json["condition"].Integer())
  60. {
  61. case EventCondition::HAVE_ARTIFACT: {
  62. ui->victoryComboBox->setCurrentIndex(1);
  63. assert(victoryTypeWidget);
  64. victoryTypeWidget->setCurrentIndex(json["objectType"].Integer());
  65. break;
  66. }
  67. case EventCondition::HAVE_CREATURES: {
  68. ui->victoryComboBox->setCurrentIndex(2);
  69. assert(victoryTypeWidget);
  70. assert(victoryValueWidget);
  71. auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
  72. victoryTypeWidget->setCurrentIndex(idx);
  73. victoryValueWidget->setText(QString::number(json["value"].Integer()));
  74. break;
  75. }
  76. case EventCondition::HAVE_RESOURCES: {
  77. ui->victoryComboBox->setCurrentIndex(3);
  78. assert(victoryTypeWidget);
  79. assert(victoryValueWidget);
  80. auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
  81. victoryTypeWidget->setCurrentIndex(idx);
  82. victoryValueWidget->setText(QString::number(json["value"].Integer()));
  83. break;
  84. }
  85. case EventCondition::HAVE_BUILDING: {
  86. ui->victoryComboBox->setCurrentIndex(4);
  87. assert(victoryTypeWidget);
  88. assert(victorySelectWidget);
  89. auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
  90. victoryTypeWidget->setCurrentIndex(idx);
  91. int townIdx = getObjectByPos<const CGTownInstance>(*controller->map(), posFromJson(json["position"]));
  92. if(townIdx >= 0)
  93. {
  94. auto idx = victorySelectWidget->findData(townIdx);
  95. victorySelectWidget->setCurrentIndex(idx);
  96. }
  97. break;
  98. }
  99. case EventCondition::CONTROL: {
  100. ui->victoryComboBox->setCurrentIndex(5);
  101. assert(victoryTypeWidget);
  102. if(json["objectType"].Integer() == Obj::TOWN)
  103. {
  104. int townIdx = getObjectByPos<const CGTownInstance>(*controller->map(), posFromJson(json["position"]));
  105. if(townIdx >= 0)
  106. {
  107. auto idx = victoryTypeWidget->findData(townIdx);
  108. victoryTypeWidget->setCurrentIndex(idx);
  109. }
  110. }
  111. //TODO: support control other objects (dwellings, mines)
  112. break;
  113. }
  114. case EventCondition::DESTROY: {
  115. if(json["objectType"].Integer() == Obj::HERO)
  116. {
  117. ui->victoryComboBox->setCurrentIndex(6);
  118. assert(victoryTypeWidget);
  119. int heroIdx = getObjectByPos<const CGHeroInstance>(*controller->map(), posFromJson(json["position"]));
  120. if(heroIdx >= 0)
  121. {
  122. auto idx = victoryTypeWidget->findData(heroIdx);
  123. victoryTypeWidget->setCurrentIndex(idx);
  124. }
  125. }
  126. if(json["objectType"].Integer() == Obj::MONSTER)
  127. {
  128. ui->victoryComboBox->setCurrentIndex(8);
  129. assert(victoryTypeWidget);
  130. int monsterIdx = getObjectByPos<const CGCreature>(*controller->map(), posFromJson(json["position"]));
  131. if(monsterIdx >= 0)
  132. {
  133. auto idx = victoryTypeWidget->findData(monsterIdx);
  134. victoryTypeWidget->setCurrentIndex(idx);
  135. }
  136. }
  137. break;
  138. }
  139. case EventCondition::TRANSPORT: {
  140. ui->victoryComboBox->setCurrentIndex(7);
  141. assert(victoryTypeWidget);
  142. assert(victorySelectWidget);
  143. victoryTypeWidget->setCurrentIndex(json["objectType"].Integer());
  144. int townIdx = getObjectByPos<const CGTownInstance>(*controller->map(), posFromJson(json["position"]));
  145. if(townIdx >= 0)
  146. {
  147. auto idx = victorySelectWidget->findData(townIdx);
  148. victorySelectWidget->setCurrentIndex(idx);
  149. }
  150. break;
  151. }
  152. case EventCondition::IS_HUMAN: {
  153. ui->onlyForHumansCheck->setChecked(true);
  154. break;
  155. }
  156. };
  157. }
  158. }
  159. }
  160. }
  161. }
  162. void VictoryConditions::update()
  163. {
  164. //victory messages
  165. bool customMessage = true;
  166. //victory conditions
  167. EventCondition victoryCondition(EventCondition::STANDARD_WIN);
  168. //Victory condition - defeat all
  169. TriggeredEvent standardVictory;
  170. standardVictory.effect.type = EventEffect::VICTORY;
  171. standardVictory.effect.toOtherMessage.appendTextID("core.genrltxt.5");
  172. standardVictory.identifier = "standardVictory";
  173. standardVictory.description.clear(); // TODO: display in quest window
  174. standardVictory.onFulfill.appendTextID("core.genrltxt.659");
  175. standardVictory.trigger = EventExpression(victoryCondition);
  176. //VICTORY
  177. if(ui->victoryComboBox->currentIndex() == 0)
  178. {
  179. controller->map()->triggeredEvents.push_back(standardVictory);
  180. controller->map()->victoryIconIndex = 11;
  181. controller->map()->victoryMessage = MetaString::createFromTextID("core.vcdesc.0");
  182. customMessage = false;
  183. }
  184. else
  185. {
  186. int vicCondition = ui->victoryComboBox->currentIndex() - 1;
  187. TriggeredEvent specialVictory;
  188. specialVictory.effect.type = EventEffect::VICTORY;
  189. specialVictory.identifier = "specialVictory";
  190. specialVictory.description.clear(); // TODO: display in quest window
  191. controller->map()->victoryIconIndex = vicCondition;
  192. controller->map()->victoryMessage = MetaString::createFromTextID("core.vcdesc." + std::to_string(vicCondition + 1));
  193. customMessage = false;
  194. switch(vicCondition)
  195. {
  196. case 0: {
  197. EventCondition cond(EventCondition::HAVE_ARTIFACT);
  198. assert(victoryTypeWidget);
  199. cond.objectType = ArtifactID(victoryTypeWidget->currentData().toInt());
  200. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.281");
  201. specialVictory.onFulfill.appendTextID("core.genrltxt.280");
  202. specialVictory.trigger = EventExpression(cond);
  203. break;
  204. }
  205. case 1: {
  206. EventCondition cond(EventCondition::HAVE_CREATURES);
  207. assert(victoryTypeWidget);
  208. cond.objectType = CreatureID(victoryTypeWidget->currentData().toInt());
  209. cond.value = victoryValueWidget->text().toInt();
  210. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.277");
  211. specialVictory.onFulfill.appendTextID("core.genrltxt.276");
  212. specialVictory.trigger = EventExpression(cond);
  213. break;
  214. }
  215. case 2: {
  216. EventCondition cond(EventCondition::HAVE_RESOURCES);
  217. assert(victoryTypeWidget);
  218. cond.objectType = GameResID(victoryTypeWidget->currentData().toInt());
  219. cond.value = victoryValueWidget->text().toInt();
  220. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.279");
  221. specialVictory.onFulfill.appendTextID("core.genrltxt.278");
  222. specialVictory.trigger = EventExpression(cond);
  223. break;
  224. }
  225. case 3: {
  226. EventCondition cond(EventCondition::HAVE_BUILDING);
  227. assert(victoryTypeWidget);
  228. cond.objectType = BuildingID(victoryTypeWidget->currentData().toInt());
  229. int townIdx = victorySelectWidget->currentData().toInt();
  230. if(townIdx > -1)
  231. cond.position = controller->map()->objects[townIdx]->pos;
  232. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.283");
  233. specialVictory.onFulfill.appendTextID("core.genrltxt.282");
  234. specialVictory.trigger = EventExpression(cond);
  235. break;
  236. }
  237. case 4: {
  238. EventCondition cond(EventCondition::CONTROL);
  239. assert(victoryTypeWidget);
  240. cond.objectType = Obj(Obj::TOWN);
  241. int townIdx = victoryTypeWidget->currentData().toInt();
  242. cond.position = controller->map()->objects[townIdx]->pos;
  243. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.250");
  244. specialVictory.onFulfill.appendTextID("core.genrltxt.249");
  245. specialVictory.trigger = EventExpression(cond);
  246. break;
  247. }
  248. case 5: {
  249. EventCondition cond(EventCondition::DESTROY);
  250. assert(victoryTypeWidget);
  251. cond.objectType = Obj(Obj::HERO);
  252. int heroIdx = victoryTypeWidget->currentData().toInt();
  253. cond.position = controller->map()->objects[heroIdx]->pos;
  254. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.253");
  255. specialVictory.onFulfill.appendTextID("core.genrltxt.252");
  256. specialVictory.trigger = EventExpression(cond);
  257. break;
  258. }
  259. case 6: {
  260. EventCondition cond(EventCondition::TRANSPORT);
  261. assert(victoryTypeWidget);
  262. cond.objectType = ArtifactID(victoryTypeWidget->currentData().toInt());
  263. int townIdx = victorySelectWidget->currentData().toInt();
  264. if(townIdx > -1)
  265. cond.position = controller->map()->objects[townIdx]->pos;
  266. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.293");
  267. specialVictory.onFulfill.appendTextID("core.genrltxt.292");
  268. specialVictory.trigger = EventExpression(cond);
  269. break;
  270. }
  271. case 7: {
  272. EventCondition cond(EventCondition::DESTROY);
  273. assert(victoryTypeWidget);
  274. cond.objectType = Obj(Obj::MONSTER);
  275. int monsterIdx = victoryTypeWidget->currentData().toInt();
  276. cond.position = controller->map()->objects[monsterIdx]->pos;
  277. specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.287");
  278. specialVictory.onFulfill.appendTextID("core.genrltxt.286");
  279. specialVictory.trigger = EventExpression(cond);
  280. break;
  281. }
  282. }
  283. // if condition is human-only turn it into following construction: AllOf(human, condition)
  284. if(ui->onlyForHumansCheck->isChecked())
  285. {
  286. EventExpression::OperatorAll oper;
  287. EventCondition notAI(EventCondition::IS_HUMAN);
  288. notAI.value = 1;
  289. oper.expressions.push_back(notAI);
  290. oper.expressions.push_back(specialVictory.trigger.get());
  291. specialVictory.trigger = EventExpression(oper);
  292. }
  293. // if normal victory allowed - add one more quest
  294. if(ui->standardVictoryCheck->isChecked())
  295. {
  296. controller->map()->victoryMessage.appendRawString(" / ");
  297. controller->map()->victoryMessage.appendTextID("core.vcdesc.0");
  298. controller->map()->triggeredEvents.push_back(standardVictory);
  299. customMessage = false;
  300. }
  301. controller->map()->triggeredEvents.push_back(specialVictory);
  302. }
  303. if(customMessage)
  304. {
  305. controller->map()->victoryMessage = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "victoryMessage"), ui->victoryMessageEdit->text().toStdString()));
  306. }
  307. }
  308. VictoryConditions::~VictoryConditions()
  309. {
  310. delete ui;
  311. }
  312. void VictoryConditions::on_victoryComboBox_currentIndexChanged(int index)
  313. {
  314. delete victoryTypeWidget;
  315. delete victoryValueWidget;
  316. delete victorySelectWidget;
  317. delete pickObjectButton;
  318. victoryTypeWidget = nullptr;
  319. victoryValueWidget = nullptr;
  320. victorySelectWidget = nullptr;
  321. pickObjectButton = nullptr;
  322. if(index == 0)
  323. {
  324. ui->standardVictoryCheck->setChecked(true);
  325. ui->standardVictoryCheck->setEnabled(false);
  326. ui->onlyForHumansCheck->setChecked(false);
  327. ui->onlyForHumansCheck->setEnabled(false);
  328. return;
  329. }
  330. ui->onlyForHumansCheck->setEnabled(true);
  331. ui->standardVictoryCheck->setEnabled(true);
  332. int vicCondition = index - 1;
  333. switch(vicCondition)
  334. {
  335. case 0: { //EventCondition::HAVE_ARTIFACT
  336. victoryTypeWidget = new QComboBox;
  337. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  338. for(int i = 0; i < controller->map()->allowedArtifact.size(); ++i)
  339. victoryTypeWidget->addItem(QString::fromStdString(VLC->arth->objects[i]->getNameTranslated()), QVariant::fromValue(i));
  340. break;
  341. }
  342. case 1: { //EventCondition::HAVE_CREATURES
  343. victoryTypeWidget = new QComboBox;
  344. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  345. for(int i = 0; i < VLC->creh->objects.size(); ++i)
  346. victoryTypeWidget->addItem(QString::fromStdString(VLC->creh->objects[i]->getNamePluralTranslated()), QVariant::fromValue(i));
  347. victoryValueWidget = new QLineEdit;
  348. ui->victoryParamsLayout->addWidget(victoryValueWidget);
  349. victoryValueWidget->setText("1");
  350. break;
  351. }
  352. case 2: { //EventCondition::HAVE_RESOURCES
  353. victoryTypeWidget = new QComboBox;
  354. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  355. {
  356. for(int resType = 0; resType < GameConstants::RESOURCE_QUANTITY; ++resType)
  357. {
  358. auto resName = QString::fromStdString(GameConstants::RESOURCE_NAMES[resType]);
  359. victoryTypeWidget->addItem(resName, QVariant::fromValue(resType));
  360. }
  361. }
  362. victoryValueWidget = new QLineEdit;
  363. ui->victoryParamsLayout->addWidget(victoryValueWidget);
  364. victoryValueWidget->setText("1");
  365. break;
  366. }
  367. case 3: { //EventCondition::HAVE_BUILDING
  368. victoryTypeWidget = new QComboBox;
  369. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  370. auto * ctown = VLC->townh->randomTown;
  371. for(int bId : ctown->getAllBuildings())
  372. victoryTypeWidget->addItem(QString::fromStdString(defaultBuildingIdConversion(BuildingID(bId))), QVariant::fromValue(bId));
  373. victorySelectWidget = new QComboBox;
  374. ui->victoryParamsLayout->addWidget(victorySelectWidget);
  375. victorySelectWidget->addItem("Any town", QVariant::fromValue(-1));
  376. for(int i : getObjectIndexes<const CGTownInstance>(*controller->map()))
  377. victorySelectWidget->addItem(getTownName(*controller->map(), i).c_str(), QVariant::fromValue(i));
  378. pickObjectButton = new QToolButton;
  379. connect(pickObjectButton, &QToolButton::clicked, this, &VictoryConditions::onObjectSelect);
  380. ui->victoryParamsLayout->addWidget(pickObjectButton);
  381. break;
  382. }
  383. case 4: { //EventCondition::CONTROL (Obj::TOWN)
  384. victoryTypeWidget = new QComboBox;
  385. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  386. for(int i : getObjectIndexes<const CGTownInstance>(*controller->map()))
  387. victoryTypeWidget->addItem(tr(getTownName(*controller->map(), i).c_str()), QVariant::fromValue(i));
  388. pickObjectButton = new QToolButton;
  389. connect(pickObjectButton, &QToolButton::clicked, this, &VictoryConditions::onObjectSelect);
  390. ui->victoryParamsLayout->addWidget(pickObjectButton);
  391. break;
  392. }
  393. case 5: { //EventCondition::DESTROY (Obj::HERO)
  394. victoryTypeWidget = new QComboBox;
  395. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  396. for(int i : getObjectIndexes<const CGHeroInstance>(*controller->map()))
  397. victoryTypeWidget->addItem(tr(getHeroName(*controller->map(), i).c_str()), QVariant::fromValue(i));
  398. pickObjectButton = new QToolButton;
  399. connect(pickObjectButton, &QToolButton::clicked, this, &VictoryConditions::onObjectSelect);
  400. ui->victoryParamsLayout->addWidget(pickObjectButton);
  401. break;
  402. }
  403. case 6: { //EventCondition::TRANSPORT (Obj::ARTEFACT)
  404. victoryTypeWidget = new QComboBox;
  405. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  406. for(int i = 0; i < controller->map()->allowedArtifact.size(); ++i)
  407. victoryTypeWidget->addItem(QString::fromStdString(VLC->arth->objects[i]->getNameTranslated()), QVariant::fromValue(i));
  408. victorySelectWidget = new QComboBox;
  409. ui->victoryParamsLayout->addWidget(victorySelectWidget);
  410. for(int i : getObjectIndexes<const CGTownInstance>(*controller->map()))
  411. victorySelectWidget->addItem(tr(getTownName(*controller->map(), i).c_str()), QVariant::fromValue(i));
  412. pickObjectButton = new QToolButton;
  413. connect(pickObjectButton, &QToolButton::clicked, this, &VictoryConditions::onObjectSelect);
  414. ui->victoryParamsLayout->addWidget(pickObjectButton);
  415. break;
  416. }
  417. case 7: { //EventCondition::DESTROY (Obj::MONSTER)
  418. victoryTypeWidget = new QComboBox;
  419. ui->victoryParamsLayout->addWidget(victoryTypeWidget);
  420. for(int i : getObjectIndexes<const CGCreature>(*controller->map()))
  421. victoryTypeWidget->addItem(tr(getMonsterName(*controller->map(), i).c_str()), QVariant::fromValue(i));
  422. pickObjectButton = new QToolButton;
  423. connect(pickObjectButton, &QToolButton::clicked, this, &VictoryConditions::onObjectSelect);
  424. ui->victoryParamsLayout->addWidget(pickObjectButton);
  425. break;
  426. }
  427. }
  428. }
  429. void VictoryConditions::onObjectSelect()
  430. {
  431. int vicConditions = ui->victoryComboBox->currentIndex() - 1;
  432. for(int lvl : {0, 1})
  433. {
  434. auto & l = controller->scene(lvl)->objectPickerView;
  435. switch(vicConditions)
  436. {
  437. case 3: { //EventCondition::HAVE_BUILDING
  438. l.highlight<const CGTownInstance>();
  439. break;
  440. }
  441. case 4: { //EventCondition::CONTROL (Obj::TOWN)
  442. l.highlight<const CGTownInstance>();
  443. break;
  444. }
  445. case 5: { //EventCondition::DESTROY (Obj::HERO)
  446. l.highlight<const CGHeroInstance>();
  447. break;
  448. }
  449. case 6: { //EventCondition::TRANSPORT (Obj::ARTEFACT)
  450. l.highlight<const CGTownInstance>();
  451. break;
  452. }
  453. case 7: { //EventCondition::DESTROY (Obj::MONSTER)
  454. l.highlight<const CGCreature>();
  455. break;
  456. }
  457. default:
  458. return;
  459. }
  460. l.update();
  461. QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &VictoryConditions::onObjectPicked);
  462. }
  463. dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide();
  464. }
  465. void VictoryConditions::onObjectPicked(const CGObjectInstance * obj)
  466. {
  467. dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show();
  468. for(int lvl : {0, 1})
  469. {
  470. auto & l = controller->scene(lvl)->objectPickerView;
  471. l.clear();
  472. l.update();
  473. QObject::disconnect(&l, &ObjectPickerLayer::selectionMade, this, &VictoryConditions::onObjectPicked);
  474. }
  475. if(!obj) //discarded
  476. return;
  477. int vicConditions = ui->victoryComboBox->currentIndex() - 1;
  478. QComboBox * w = victoryTypeWidget;
  479. if(vicConditions == 3 || vicConditions == 6)
  480. w = victorySelectWidget;
  481. for(int i = 0; i < w->count(); ++i)
  482. {
  483. if(w->itemData(i).toInt() < 0)
  484. continue;
  485. auto data = controller->map()->objects.at(w->itemData(i).toInt());
  486. if(data == obj)
  487. {
  488. w->setCurrentIndex(i);
  489. break;
  490. }
  491. }
  492. }