| 801 | } |
| 802 | |
| 803 | SetupInstanceResults setupInstance(Instance& instance, PluginContainer& pc) |
| 804 | { |
| 805 | // set up the instance |
| 806 | const auto setupResult = instance.setup(pc); |
| 807 | |
| 808 | switch (setupResult) { |
| 809 | case Instance::SetupResults::Okay: { |
| 810 | // all good |
| 811 | return SetupInstanceResults::Okay; |
| 812 | } |
| 813 | |
| 814 | case Instance::SetupResults::BadIni: { |
| 815 | // unreadable ini, there's not much that can be done, select another |
| 816 | // instance |
| 817 | |
| 818 | reportError(QObject::tr("Cannot open instance '%1', failed to read INI file %2.") |
| 819 | .arg(instance.displayName()) |
| 820 | .arg(instance.iniPath())); |
| 821 | |
| 822 | return SetupInstanceResults::SelectAnother; |
| 823 | } |
| 824 | |
| 825 | case Instance::SetupResults::IniMissingGame: { |
| 826 | // both the game name and directory are missing from the ini; although |
| 827 | // this shouldn't happen, setup() is able to handle when either is |
| 828 | // missing, but not both |
| 829 | // |
| 830 | // ask the user for the game managed by this instance |
| 831 | |
| 832 | reportError( |
| 833 | QObject::tr( |
| 834 | "Cannot open instance '%1', the managed game was not found in the INI " |
| 835 | "file %2. Select the game managed by this instance.") |
| 836 | .arg(instance.displayName()) |
| 837 | .arg(instance.iniPath())); |
| 838 | |
| 839 | return selectGame(instance, pc); |
| 840 | } |
| 841 | |
| 842 | case Instance::SetupResults::PluginGone: { |
| 843 | // there is no plugin that can handle the game name/directory from the |
| 844 | // ini, so this instance is unusable |
| 845 | |
| 846 | reportError( |
| 847 | QObject::tr("Cannot open instance '%1', the game plugin '%2' doesn't exist. It " |
| 848 | "may have been deleted by an antivirus. Select another instance.") |
| 849 | .arg(instance.displayName()) |
| 850 | .arg(instance.gameName())); |
| 851 | |
| 852 | return SetupInstanceResults::SelectAnother; |
| 853 | } |
| 854 | |
| 855 | case Instance::SetupResults::GameGone: { |
| 856 | // the game directory doesn't exist or the plugin doesn't recognize it; |
| 857 | // ask the user for the game managed by this instance |
| 858 | |
| 859 | reportError( |
| 860 | QObject::tr( |
no test coverage detected