| 697 | } |
| 698 | |
| 699 | std::unique_ptr<Instance> selectInstance() |
| 700 | { |
| 701 | auto& m = InstanceManager::singleton(); |
| 702 | |
| 703 | // since there is no instance currently active, load plugins with a null |
| 704 | // OrganizerCore; see PluginContainer::initPlugin() |
| 705 | NexusInterface ni(nullptr); |
| 706 | PluginContainer pc(nullptr); |
| 707 | pc.loadPlugins(); |
| 708 | |
| 709 | if (m.hasAnyInstances()) { |
| 710 | // there is at least one instance available, show the instance manager |
| 711 | // dialog |
| 712 | InstanceManagerDialog dlg(pc); |
| 713 | |
| 714 | // the dialog normally restarts MO when an instance is selected, but this |
| 715 | // is not necessary here since MO hasn't really started yet |
| 716 | dlg.setRestartOnSelect(false); |
| 717 | |
| 718 | dlg.show(); |
| 719 | dlg.activateWindow(); |
| 720 | dlg.raise(); |
| 721 | |
| 722 | if (dlg.exec() != QDialog::Accepted) { |
| 723 | return {}; |
| 724 | } |
| 725 | |
| 726 | } else { |
| 727 | // no instances configured, ask the user to create one |
| 728 | CreateInstanceDialog dlg(pc, nullptr); |
| 729 | |
| 730 | if (dlg.exec() != QDialog::Accepted) { |
| 731 | return {}; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | // return the new instance or the selection |
| 736 | return m.currentInstance(); |
| 737 | } |
| 738 | |
| 739 | // shows the game selection page of the create instance dialog so the user can |
| 740 | // pick which game is managed by this instance |
no test coverage detected