diff --git a/code/CMakeModules/AndroidToolChain.cmake b/code/CMakeModules/AndroidToolChain.cmake index 81d9fe566..7135400e2 100644 --- a/code/CMakeModules/AndroidToolChain.cmake +++ b/code/CMakeModules/AndroidToolChain.cmake @@ -22,13 +22,8 @@ IF(NOT TARGET_CPU) SET(TARGET_CPU "armv7") ENDIF() -SET(ARMV7_HARD_FLOAT OFF) - IF(TARGET_CPU STREQUAL "armv7") SET(LIBRARY_ARCHITECTURE "armeabi-v7a") - IF(ARMV7_HARD_FLOAT) - SET(LIBRARY_ARCHITECTURE "${LIBRARY_ARCHITECTURE}-hard") - ENDIF() SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(TOOLCHAIN_ARCH "arm") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") @@ -123,6 +118,12 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER) ENDFOREACH() ENDIF() + # try prefixes without version + SET(_TOOLCHAIN_WITHOUT_VERSION "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}") + IF(EXISTS ${_TOOLCHAIN_WITHOUT_VERSION}) + LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS "default") + ENDIF() + IF(NOT ${_COMPILER}_TOOLCHAIN_VERSIONS) MESSAGE(FATAL_ERROR "No Android ${_COMPILER} toolchain found in default search path ${NDK_ROOT}/toolchains") ENDIF() @@ -136,7 +137,15 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER) LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION) ENDIF() - SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") + MESSAGE(STATUS "TOOLCHAIN_PREFIX = ${${_COMPILER}_TOOLCHAIN_VERSION}") + + IF("${${_COMPILER}_TOOLCHAIN_VERSION}" STREQUAL "default") + MESSAGE(STATUS "default") + SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}") + ELSE() + MESSAGE(STATUS "not default") + SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") + ENDIF() IF(NOT EXISTS "${${_COMPILER}_TOOLCHAIN_ROOT}") FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*") @@ -192,7 +201,7 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) MACRO(SET_TOOLCHAIN_BINARY_LLVM _NAME _BINARY) - SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE ) + SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE) ENDMACRO() MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY) @@ -214,6 +223,14 @@ IF(CLANG) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++) + + IF(NOT EXISTS "${CMAKE_ASM_COMPILER}") + SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as) + ENDIF() + + IF(NOT EXISTS "${CMAKE_AR}") + SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar) + ENDIF() ELSE() MESSAGE(STATUS "Using GCC compiler") diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake index bccfc0236..610045e33 100644 --- a/code/CMakeModules/iOSToolChain.cmake +++ b/code/CMakeModules/iOSToolChain.cmake @@ -177,26 +177,26 @@ ENDIF() # set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv7,armv7s and appears to be XCode's standard. # The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only IF(ARCHS) - SET(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE string "Build architecture for iOS") + SET(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS") ENDIF() # Set the find root to the iOS developer roots and to user defined paths -set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_IOS_PATH} CACHE string "iOS find search path root") +SET(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} ${CMAKE_SOURCE_DIR}/external $ENV{EXTERNAL_IOS_PATH} CACHE STRING "iOS find search path root") # default to searching for frameworks first -set (CMAKE_FIND_FRAMEWORK FIRST) +SET(CMAKE_FIND_FRAMEWORK FIRST) # set up the default search directories for frameworks -set (CMAKE_SYSTEM_FRAMEWORK_PATH +SET(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks ) # only search the iOS sdks, not the remainder of the host filesystem -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH include(CMakeFindBinUtils) diff --git a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp index fb8235063..c88a93b8f 100644 --- a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp +++ b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp @@ -137,8 +137,8 @@ NLMISC_COMMAND(fightDefaultRange, "Generic default fight range","") { if (args.size()==2) { - CBotProfileFightHeal::fightDefaultMinRange = (float)atof(args[0].c_str()); - CBotProfileFightHeal::fightDefaultMaxRange = (float)atof(args[1].c_str()); + NLMISC::fromString(args[0], CBotProfileFightHeal::fightDefaultMinRange); + NLMISC::fromString(args[1], CBotProfileFightHeal::fightDefaultMaxRange); } log.displayNL("Generic default fight range is [%f;%f]", CBotProfileFightHeal::fightDefaultMinRange, CBotProfileFightHeal::fightDefaultMaxRange); return true; diff --git a/code/ryzom/server/src/ai_service/continent_actions.cpp b/code/ryzom/server/src/ai_service/continent_actions.cpp index aaabf9b98..18780b3f5 100644 --- a/code/ryzom/server/src/ai_service/continent_actions.cpp +++ b/code/ryzom/server/src/ai_service/continent_actions.cpp @@ -219,7 +219,7 @@ DEFINE_ACTION(ContextRegion,CELLZNE) // if (args[i+1].get(str)) // { // if (!str.empty()) -// value=atof(str.c_str()); +// NLMISC::fromString(str, value); // } // levelEnergy.setLevelEnergyValue(value, i); // } @@ -241,7 +241,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ) if (args[i].get(str)) { if (!str.empty()) - value=atof(str.c_str()); + NLMISC::fromString(str, value); } groupFamily->setLevelEnergyValue(value, i); } @@ -268,7 +268,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ) // if (args[i+1].get(str)) // { // if (!str.empty()) -// value=atof(str.c_str()); +// NLMISC::fromString(str, value); // } // levelEnergy.setLevelEnergyValue(value, i); // } diff --git a/code/ryzom/server/src/ai_service/generic_logic_action.cpp b/code/ryzom/server/src/ai_service/generic_logic_action.cpp index 0b0e254b7..a7c01d5ef 100644 --- a/code/ryzom/server/src/ai_service/generic_logic_action.cpp +++ b/code/ryzom/server/src/ai_service/generic_logic_action.cpp @@ -1438,7 +1438,8 @@ public: // try to parse a constant value // var.Type = constant; -// double val = atof(str.c_str()); +// double val; +// NLMISC::fromString(str, val); // var.Value = float(val); // return true; } diff --git a/code/ryzom/server/src/ai_service/script_compiler.cpp b/code/ryzom/server/src/ai_service/script_compiler.cpp index 7fb49008f..8e28d0c9f 100644 --- a/code/ryzom/server/src/ai_service/script_compiler.cpp +++ b/code/ryzom/server/src/ai_service/script_compiler.cpp @@ -1488,7 +1488,8 @@ CCaseTracer::CCaseTracer(const CSmartPtr &tracer, const string & if (valChldTracer=chldTracer->getChildForName(s_kw_NUMBER)) { const string &strRef=valChldTracer->_TextValue; - const float f=(float)atof(strRef.c_str()); + float f; + NLMISC::fromString(strRef, f); _sortValue=*((size_t*)&f); break; } @@ -1954,7 +1955,8 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const NLMISC::fromString(param, index); --index; string &strRef=_childTracers[index]->_TextValue; - const float f=(float)atof(strRef.c_str()); + float f; + NLMISC::fromString(strRef, f); byteCode.push_back(*((size_t*)&f)); jumpTable.newCodeBlock(); break; diff --git a/code/ryzom/server/src/ai_service/script_parser.lex b/code/ryzom/server/src/ai_service/script_parser.lex index ccddc5a62..d5c4128a8 100644 --- a/code/ryzom/server/src/ai_service/script_parser.lex +++ b/code/ryzom/server/src/ai_service/script_parser.lex @@ -118,7 +118,8 @@ onchildren { return TOKEN_ONCHILDREN; } {double} { - const float f=(float)atof(yytext); + float f; + NLMISC::fromString(yytext, f); INIT(*((size_t*)&f)); return TOKEN_NUMBER; } diff --git a/code/ryzom/server/src/ai_service/script_parser_lex.cpp b/code/ryzom/server/src/ai_service/script_parser_lex.cpp index fcd16d8b9..cacd9ab78 100644 --- a/code/ryzom/server/src/ai_service/script_parser_lex.cpp +++ b/code/ryzom/server/src/ai_service/script_parser_lex.cpp @@ -4473,7 +4473,8 @@ case 23: YY_RULE_SETUP #line 120 "ai_service/script_parser.lex" { - const float f=(float)atof(yytext); + float f; + NLMISC::fromString(yytext, f); INIT(*((size_t*)&f)); return TOKEN_NUMBER; } diff --git a/code/ryzom/server/src/ai_service/script_vm.cpp b/code/ryzom/server/src/ai_service/script_vm.cpp index 14d0fc933..243110520 100644 --- a/code/ryzom/server/src/ai_service/script_vm.cpp +++ b/code/ryzom/server/src/ai_service/script_vm.cpp @@ -304,7 +304,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string &str=stack.top(); - f=(float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: @@ -406,7 +406,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string& str = stack.top(); - f = (float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: @@ -601,7 +601,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string& str = stack.top(); - f = (float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: diff --git a/code/ryzom/server/src/ai_service/sheets.cpp b/code/ryzom/server/src/ai_service/sheets.cpp index 57b26f4d2..24a56328e 100644 --- a/code/ryzom/server/src/ai_service/sheets.cpp +++ b/code/ryzom/server/src/ai_service/sheets.cpp @@ -1122,7 +1122,8 @@ NLMISC_COMMAND(setSheetProperty,"change a value read from a sheet"," leve } // get the value - float val = (float)atof(args[2].c_str()); + float val; + NLMISC::fromString(args[2], val); if (val==0 && args[2]!="0" && args[2]!="0.0") { log.displayNL("'%s' is not a valid value",args[2].c_str()); diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 91877eb9e..048074d4c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -127,7 +127,6 @@ bool CConfigFile::load(const QString &filename) profile.id = settings.value("id").toString(); profile.name = settings.value("name").toString(); - profile.account = settings.value("account").toString(); profile.server = settings.value("server").toString(); profile.executable = settings.value("executable").toString(); profile.arguments = settings.value("arguments").toString(); @@ -216,7 +215,6 @@ bool CConfigFile::save() const settings.setValue("id", profile.id); settings.setValue("name", profile.name); - settings.setValue("account", profile.account); settings.setValue("server", profile.server); settings.setValue("executable", profile.executable); settings.setValue("arguments", profile.arguments); @@ -577,13 +575,33 @@ bool CConfigFile::shouldCreateDesktopShortcut() const return profile.desktopShortcut && !QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk"); } -QString CConfigFile::getClientFullPath() const +QString CConfigFile::getProfileClientFullPath(int profileIndex) const { - QString path = getProfile().executable; + const CProfile &profile = getProfile(profileIndex); + + QString path = profile.executable; if (!path.isEmpty()) return path; - return getInstallationDirectory() + "/" + getServer().id + "/" + getServer().clientFilename; + return getServerClientFullPath(profile.server); +} + +QString CConfigFile::getServerClientFullPath(const QString &serverId) const +{ + const CServer &server = getServer(serverId); + + if (server.clientFilename.isEmpty()) return ""; + + return getInstallationDirectory() + "/" + server.id + "/" + server.clientFilename; +} + +QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) const +{ + const CServer &server = getServer(serverId); + + if (server.configurationFilename.isEmpty()) return ""; + + return getInstallationDirectory() + "/" + server.id + "/" + server.configurationFilename; } QString CConfigFile::getSrcServerClientBNPFullPath() const diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index aa3a61f8b..d95894fae 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -54,7 +54,6 @@ struct CProfile } QString id; - QString account; QString name; QString server; QString executable; @@ -172,7 +171,9 @@ public: QString getClientArch() const; - QString getClientFullPath() const; + QString getProfileClientFullPath(int profileIndex = -1) const; + QString getServerClientFullPath(const QString &serverId = "") const; + QString getServerConfigurationFullPath(const QString &serverId = "") const; QString getSrcServerClientBNPFullPath() const; diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp index e0fadd0d2..43b54b3f9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp @@ -123,6 +123,7 @@ void CFilesCopier::getFilesList(FilesToCopy &files) file.dst = dstPath; file.size = entry.size(); file.date = entry.lastModified().toTime_t(); + file.permissions = entry.permissions(); files << file; } @@ -141,6 +142,7 @@ void CFilesCopier::getFilesList(FilesToCopy &files) file.dst = m_destinationDirectory + "/" + fileInfo.fileName(); file.size = fileInfo.size(); file.date = fileInfo.lastModified().toTime_t(); + file.permissions = fileInfo.permissions(); files << file; } @@ -187,6 +189,11 @@ bool CFilesCopier::copyFiles(const FilesToCopy &files) return false; } + if (!QFile::setPermissions(file.dst, file.permissions)) + { + qDebug() << "Unable to change permissions of " << file.dst; + } + if (!NLMISC::CFile::setFileModificationDate(qToUtf8(file.dst), file.date)) { qDebug() << "Unable to change date of " << file.dst; diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h index 14dfe4054..8b505fb68 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h @@ -49,6 +49,7 @@ protected: QString dst; qint64 size; uint date; + QFile::Permissions permissions; }; typedef QList FilesToCopy; diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 34b8303b9..c60958479 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -41,6 +41,7 @@ CMainWindow::CMainWindow():QMainWindow() connect(actionProfiles, SIGNAL(triggered()), SLOT(onProfiles())); connect(actionUninstall, SIGNAL(triggered()), SLOT(onUninstall())); + connect(actionQuit, SIGNAL(triggered()), SLOT(onQuit())); connect(playButton, SIGNAL(clicked()), SLOT(onPlayClicked())); connect(configureButton, SIGNAL(clicked()), SLOT(onConfigureClicked())); @@ -80,16 +81,20 @@ void CMainWindow::onPlayClicked() if (profileIndex < 0) return; - CProfile profile = CConfigFile::getInstance()->getProfile(profileIndex); + CConfigFile *config = CConfigFile::getInstance(); - if (profile.executable.isEmpty()) return; + const CProfile &profile = config->getProfile(profileIndex); + + QString executable = config->getProfileClientFullPath(profileIndex); + + if (executable.isEmpty() || !QFile::exists(executable)) return; QStringList arguments; arguments << "-p"; - arguments << QString::number(profileIndex); + arguments << profile.id; arguments << profile.arguments.split(' '); - bool started = QProcess::startDetached(profile.executable, arguments); + bool started = QProcess::startDetached(executable, arguments); CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex); } @@ -100,19 +105,19 @@ void CMainWindow::onConfigureClicked() if (profileIndex < 0) return; - CProfile profile = CConfigFile::getInstance()->getProfile(profileIndex); + CConfigFile *config = CConfigFile::getInstance(); - if (profile.server.isEmpty()) return; + const CProfile &profile = config->getProfile(profileIndex); - CServer server = CConfigFile::getInstance()->getServer(profile.server); + QString executable = config->getServerConfigurationFullPath(profile.server); - if (server.configurationFilename.isEmpty()) return; + if (executable.isEmpty() || !QFile::exists(executable)) return; QStringList arguments; arguments << "-p"; - arguments << QString::number(profileIndex); + arguments << profile.id; - bool started = QProcess::startDetached(server.configurationFilename, arguments); + bool started = QProcess::startDetached(executable, arguments); CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex); } @@ -159,6 +164,11 @@ void CMainWindow::onUninstall() } } +void CMainWindow::onQuit() +{ + close(); +} + void CMainWindow::onAbout() { QString br("
"); diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h index fbd4ec1aa..e52d47cb1 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h @@ -43,6 +43,8 @@ public slots: void onProfiles(); void onUninstall(); + void onQuit(); + void onAbout(); void onAboutQt(); diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 81db90561..61649c587 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -590,7 +590,6 @@ bool COperationDialog::createDefaultProfile() CProfile profile; profile.id = "0"; - profile.executable = config->getClientFullPath(); profile.name = QString("Ryzom (%1)").arg(server.name); profile.server = server.id; profile.comments = "Default profile created by Ryzom Installer"; diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index d113ab2c2..ac126a1b6 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -32,6 +32,7 @@ CProfilesDialog::CProfilesDialog(QWidget *parent):QDialog(parent), m_currentProf connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile())); connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex))); connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked())); + connect(directoryButton, SIGNAL(clicked()), SLOT(onProfileDirectoryClicked())); m_model = new CProfilesModel(this); m_serversModel = new CServersModel(this); @@ -60,6 +61,7 @@ void CProfilesDialog::accept() void CProfilesDialog::onAddProfile() { + addProfile(); } void CProfilesDialog::onDeleteProfile() @@ -85,7 +87,6 @@ void CProfilesDialog::displayProfile(int index) bool enabled = index > -1; profileIdLabel->setEnabled(enabled); - accountEdit->setEnabled(enabled); nameEdit->setEnabled(enabled); serverComboBox->setEnabled(enabled); argumentsEdit->setEnabled(enabled); @@ -97,18 +98,29 @@ void CProfilesDialog::displayProfile(int index) const CProfile &profile = m_model->getProfiles()[index]; + QString executable = profile.executable; + + if (executable.isEmpty()) + { + executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server); + } + + QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id; + // update all widgets with content of profile profileIdLabel->setText(profile.id); - accountEdit->setText(profile.account); nameEdit->setText(profile.name); serverComboBox->setCurrentIndex(m_serversModel->getIndexFromServerID(profile.server)); - executablePathLabel->setText(QFileInfo(profile.executable).fileName()); + executablePathLabel->setText(QFileInfo(executable).fileName()); argumentsEdit->setText(profile.arguments); commentsEdit->setPlainText(profile.comments); - directoryPathLabel->setText(CConfigFile::getInstance()->getProfileDirectory()); + directoryPathLabel->setText(profileDirectory); desktopShortcutCheckBox->setChecked(profile.desktopShortcut); menuShortcutCheckBox->setChecked(profile.menuShortcut); + // disable click on button if directory doesn't exist + directoryButton->setEnabled(QFile::exists(profileDirectory)); + updateExecutableVersion(index); m_currentProfileIndex = index; @@ -116,11 +128,10 @@ void CProfilesDialog::displayProfile(int index) void CProfilesDialog::saveProfile(int index) { - if (index < 0) return; + if (index < 0 || index >= m_model->rowCount()) return; CProfile &profile = m_model->getProfiles()[index]; - profile.account = accountEdit->text(); profile.name = nameEdit->text(); profile.server = m_serversModel->getServerIDFromIndex(serverComboBox->currentIndex()); profile.arguments = argumentsEdit->text(); @@ -135,12 +146,62 @@ void CProfilesDialog::deleteProfile(int index) m_model->removeRow(index); - COperationDialog dialog; + // decrement profile index + --index; + + // select row and update content + profilesListView->setCurrentIndex(m_model->index(index, 0)); + displayProfile(index); + + // TODO: delete files for delete profile } void CProfilesDialog::addProfile() { - // TODO: browse all folders in AppData/Roaming/Ryzom + int index = m_model->rowCount(); + + // append the new profile + m_model->insertRow(index); + + CConfigFile *config = CConfigFile::getInstance(); + + CProfile &profile = m_model->getProfiles()[index]; + const CServer &server = config->getServer(config->getDefaultServerIndex()); + + int nextId = 0; + + // search an ID that doesn't correspond to an existing profile directory + while (QFile::exists(config->getProfileDirectory() + "/" + QString::number(nextId))) ++nextId; + + // increment this ID until not used in profiles + while(nextId < 100) + { + bool found = false; + + // search if this ID is already used in existing profiles + foreach(const CProfile &p, m_model->getProfiles()) + { + if (p.id == QString::number(nextId)) + { + found = true; + break; + } + } + + if (!found) break; + + // increment ID + ++nextId; + } + + // set default parameters + profile.id = QString::number(nextId); + profile.server = server.id; + + profilesListView->setCurrentIndex(m_model->index(index, 0)); + displayProfile(index); + + // TODO: copy files to new server if files don't exist } void CProfilesDialog::updateExecutableVersion(int index) @@ -154,19 +215,11 @@ void CProfilesDialog::updateExecutableVersion(int index) // file empty, use default one if (executable.isEmpty()) { - executable = CConfigFile::getInstance()->getInstallationDirectory() + "/" + profile.server + "/"; - -#if defined(Q_OS_WIN32) - executable += "ryzom_client_r.exe"; -#elif defined(Q_OS_APPLE) - executable += "Ryzom.app/Contents/MacOS/Ryzom"; -#else - executable += "ryzom_client"; -#endif + executable += CConfigFile::getInstance()->getServerClientFullPath(profile.server); } // file doesn't exist - if (!QFile::exists(executable)) return; + if (executable.isEmpty() || !QFile::exists(executable)) return; // launch executable with --version argument QProcess process; @@ -198,13 +251,39 @@ void CProfilesDialog::onExecutableBrowseClicked() CProfile &profile = m_model->getProfiles()[m_currentProfileIndex]; - QString file = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), profile.executable, tr("Executables (*.exe)")); + QString executable = profile.executable; - if (file.isEmpty()) return; + if (executable.isEmpty()) + { + executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server); + } - profile.executable = file; + executable = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), executable, tr("Executables (*.exe)")); - executablePathLabel->setText(QFileInfo(profile.executable).fileName()); + if (executable.isEmpty()) return; + + // don't need to save the new executable if the same as default one + if (executable == CConfigFile::getInstance()->getServerClientFullPath(profile.server)) + { + profile.executable.clear(); + } + else + { + profile.executable = executable; + } + + executablePathLabel->setText(QFileInfo(executable).fileName()); updateExecutableVersion(m_currentProfileIndex); } + +void CProfilesDialog::onProfileDirectoryClicked() +{ + if (m_currentProfileIndex < 0) return; + + const CProfile &profile = m_model->getProfiles()[m_currentProfileIndex]; + + QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id; + + QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory)); +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h index 5116d0b7b..5a8c6516d 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h @@ -42,6 +42,7 @@ private slots: void onAddProfile(); void onDeleteProfile(); void onProfileClicked(const QModelIndex &index); + void onProfileDirectoryClicked(); void displayProfile(int index); void saveProfile(int index); diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp index 9f8ee02ff..42f07ad4c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp @@ -27,6 +27,21 @@ QVariant CProfilesModel::data(const QModelIndex &index, int role) const return tr("#%1: %2").arg(profile.id).arg(profile.name); } +bool CProfilesModel::insertRows(int row, int count, const QModelIndex &parent) +{ + if (row < 0) return false; + + beginInsertRows(parent, row, row + count - 1); + + // prepend empty profiles + CProfile profile; + m_profiles.insert(row, count, profile); + + endInsertRows(); + + return true; +} + bool CProfilesModel::removeRows(int row, int count, const QModelIndex &parent) { if (row < 0) return false; diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h index 4a3a71a77..ca78ec028 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h @@ -19,6 +19,7 @@ public: virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); CProfiles& getProfiles() { return m_profiles; } diff --git a/code/ryzom/tools/client/ryzom_installer/ui/profiles.ui b/code/ryzom/tools/client/ryzom_installer/ui/profiles.ui index 1e3e42768..c0c12bab2 100644 --- a/code/ryzom/tools/client/ryzom_installer/ui/profiles.ui +++ b/code/ryzom/tools/client/ryzom_installer/ui/profiles.ui @@ -7,7 +7,7 @@ 0 0 583 - 368 + 348 @@ -81,33 +81,23 @@ - - - Account: - - - - - - - Name: - + - + Server: - + @@ -121,14 +111,14 @@ - + Executable: - + @@ -146,38 +136,38 @@ - + Client version: - + FV 3.0.0 - + Arguments: - + - + Comments: - + @@ -187,14 +177,14 @@ - + Directory: - + @@ -212,14 +202,14 @@ - + Create shortcuts: - + @@ -257,7 +247,6 @@ profilesListView addButton deleteButton - accountEdit nameEdit serverComboBox executableBrowseButton