| 147 | } |
| 148 | |
| 149 | Instance::SetupResults Instance::setup(PluginContainer& plugins) |
| 150 | { |
| 151 | // read initial values from the ini |
| 152 | if (!readFromIni()) { |
| 153 | return SetupResults::BadIni; |
| 154 | } |
| 155 | |
| 156 | // getting game plugin |
| 157 | const auto r = getGamePlugin(plugins); |
| 158 | if (r != SetupResults::Okay) { |
| 159 | return r; |
| 160 | } |
| 161 | |
| 162 | // error if the variant missing and required by the plugin |
| 163 | if (m_gameVariant.isEmpty() && m_plugin->gameVariants().size() > 1) { |
| 164 | return SetupResults::MissingVariant; |
| 165 | } else { |
| 166 | m_plugin->setGameVariant(m_gameVariant); |
| 167 | } |
| 168 | |
| 169 | // update the ini in case anything was missing |
| 170 | updateIni(); |
| 171 | |
| 172 | // the game directory may be different than what the plugin detected, the user |
| 173 | // can change it in the settings and might have multiple versions of the game |
| 174 | // installed |
| 175 | m_plugin->setGamePath(m_gameDir); |
| 176 | |
| 177 | return SetupResults::Okay; |
| 178 | } |
| 179 | |
| 180 | void Instance::updateIni() |
| 181 | { |
no test coverage detected