| 274 | } |
| 275 | |
| 276 | void InstallView::onInstall() { |
| 277 | BString location = locationControl->getText(); |
| 278 | int containerIndex = containerControl->getSelection(); |
| 279 | BString containerName = containerNameControl->getText(); |
| 280 | int fileSystemVersionIndex = fileSystemVersionControl->getSelection(); |
| 281 | int windowsVersionIndex = windowsVersionControl->getSelection(); |
| 282 | int installType = installTypeControl->getSelection(); |
| 283 | |
| 284 | if (installType == INSTALL_TYPE_SETUP) { |
| 285 | if (!location.length()) { |
| 286 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_SETUP_FILE_MISSING); |
| 287 | } else if (!Fs::doesNativePathExist(location)) { |
| 288 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_SETUP_FILE_NOT_FOUND); |
| 289 | } else if (Fs::isNativePathDirectory(location)) { |
| 290 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_SETUP_FILE_NOT_FOUND); |
| 291 | } |
| 292 | } else if (installType == INSTALL_TYPE_DIR || installType == INSTALL_TYPE_MOUNT) { |
| 293 | location = Fs::trimTrailingSlash(location); |
| 294 | if (!location.length()) { |
| 295 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_DIR_MISSING); |
| 296 | } else if (!Fs::doesNativePathExist(location) || !Fs::isNativePathDirectory(location)) { |
| 297 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_DIR_NOT_FOUND); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | BoxedContainer* container = nullptr; |
| 302 | |
| 303 | if (this->errorMsg.isEmpty()) { |
| 304 | if (containerIndex != 0) { |
| 305 | container = BoxedwineData::getContainers()[containerIndex - 1]; |
| 306 | } else if (containerName.length() == 0) { |
| 307 | this->errorMsg = getTranslation(Msg::INSTALLVIEW_ERROR_CONTAINER_NAME_MISSING); |
| 308 | } |
| 309 | } |
| 310 | if (this->errorMsg.isEmpty()) { |
| 311 | GlobalSettings::startUpArgs = StartUpArgs(); // reset parameters |
| 312 | GlobalSettings::startUpArgs.setScale(GlobalSettings::getDefaultScale()); |
| 313 | GlobalSettings::startUpArgs.setVsync(GlobalSettings::getDefaultVsync()); |
| 314 | GlobalSettings::startUpArgs.setResolution(GlobalSettings::getDefaultResolution()); |
| 315 | GlobalSettings::setOpenGlTypeOnStartupArgs(GlobalSettings::getDefaultOpenGL()); |
| 316 | bool containerCreated = false; |
| 317 | if (!container) { |
| 318 | BString containerFilePath = GlobalSettings::createUniqueContainerPath(containerName); |
| 319 | if (!Fs::makeNativeDirs(containerFilePath)) { |
| 320 | this->errorMsgString = getTranslationWithFormat(Msg::INSTALLVIEW_ERROR_FAILED_TO_CREATE_CONTAINER_DIR, true, BString::copy(strerror(errno))); |
| 321 | this->errorMsg = this->errorMsgString; |
| 322 | return; |
| 323 | } |
| 324 | std::shared_ptr<FileSystemZip> fs = GlobalSettings::getFileSystemVersions()[fileSystemVersionIndex]; |
| 325 | container = BoxedContainer::createContainer(containerFilePath, containerName, fs); |
| 326 | container->setWindowsVersion(BoxedwineData::getWinVersions()[windowsVersionIndex]); |
| 327 | containerCreated = true; |
| 328 | } |
| 329 | container->launch(); // fill out startUpArgs specific to a container |
| 330 | if (GlobalSettings::isAutomationEnabled()) { |
| 331 | BString path = GlobalSettings::getAutomationFolder(container); |
| 332 | if (!Fs::doesNativePathExist(path)) { |
| 333 | Fs::makeNativeDirs(path); |
nothing calls this directly
no test coverage detected