From 9609ac7de27300f9bf4ded8ef17befd2604dde4b Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 16:54:10 +0200 Subject: [PATCH 01/10] Changed: Replace atof by fromString --HG-- branch : develop --- code/ryzom/server/src/ai_service/ai_generic_fight.cpp | 4 ++-- code/ryzom/server/src/ai_service/continent_actions.cpp | 6 +++--- code/ryzom/server/src/ai_service/generic_logic_action.cpp | 3 ++- code/ryzom/server/src/ai_service/script_compiler.cpp | 6 ++++-- code/ryzom/server/src/ai_service/script_parser.lex | 3 ++- code/ryzom/server/src/ai_service/script_parser_lex.cpp | 3 ++- code/ryzom/server/src/ai_service/script_vm.cpp | 6 +++--- code/ryzom/server/src/ai_service/sheets.cpp | 3 ++- 8 files changed, 20 insertions(+), 14 deletions(-) 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()); From aa5f3b849912aad3b07f2b0e9f2bf12c2551724a Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 16:55:54 +0200 Subject: [PATCH 02/10] Changed: Updated CMake toolchains modules --HG-- branch : develop --- code/CMakeModules/AndroidToolChain.cmake | 31 ++++++++++++++++++------ code/CMakeModules/iOSToolChain.cmake | 14 +++++------ 2 files changed, 31 insertions(+), 14 deletions(-) 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) From d8f53a1fcb49d41e06bdd2623e4045406cfcf561 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 16:57:19 +0200 Subject: [PATCH 03/10] Changed: Removed account option --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 2 - .../client/ryzom_installer/src/configfile.h | 1 - .../ryzom_installer/src/profilesdialog.cpp | 3 -- .../client/ryzom_installer/ui/profiles.ui | 43 +++++++------------ 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 91877eb9e..d10e227ef 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); diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index aa3a61f8b..fe2dcb05e 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; diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index d113ab2c2..bc3cf8d76 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -85,7 +85,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); @@ -99,7 +98,6 @@ void CProfilesDialog::displayProfile(int index) // 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()); @@ -120,7 +118,6 @@ void CProfilesDialog::saveProfile(int index) 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(); 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 From 32e3dfe54b9020406588765c511801a844ab1ac0 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 16:59:21 +0200 Subject: [PATCH 04/10] Changed: Adding new profile --HG-- branch : develop --- .../ryzom_installer/src/profilesdialog.cpp | 46 ++++++++++++++++++- .../ryzom_installer/src/profilesmodel.cpp | 15 ++++++ .../ryzom_installer/src/profilesmodel.h | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index bc3cf8d76..e56eb0b96 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -60,6 +60,7 @@ void CProfilesDialog::accept() void CProfilesDialog::onAddProfile() { + addProfile(); } void CProfilesDialog::onDeleteProfile() @@ -137,7 +138,50 @@ void CProfilesDialog::deleteProfile(int index) 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) 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; } From f5762eff59285c71f2d0036a9b9a3717bbfc3790 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:00:09 +0200 Subject: [PATCH 05/10] Changed: Open directory containing the profile --HG-- branch : develop --- .../ryzom_installer/src/profilesdialog.cpp | 26 ++++++++++++++++++- .../ryzom_installer/src/profilesdialog.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index e56eb0b96..8f9cbbe2d 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); @@ -97,6 +98,15 @@ 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); nameEdit->setText(profile.name); @@ -104,10 +114,13 @@ void CProfilesDialog::displayProfile(int index) executablePathLabel->setText(QFileInfo(profile.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; @@ -249,3 +262,14 @@ void CProfilesDialog::onExecutableBrowseClicked() 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); From a37752e21330584f1f0cfba53e6736fd16818a65 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:02:44 +0200 Subject: [PATCH 06/10] Fixed: Use the right executable for client or default one --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 26 +++++++++++-- .../client/ryzom_installer/src/configfile.h | 4 +- .../client/ryzom_installer/src/mainwindow.cpp | 20 ++++++---- .../ryzom_installer/src/operationdialog.cpp | 1 - .../ryzom_installer/src/profilesdialog.cpp | 37 +++++++++++-------- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index d10e227ef..048074d4c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -575,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 fe2dcb05e..d95894fae 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -171,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/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 34b8303b9..217d67018 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -80,16 +80,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.arguments.split(' '); - bool started = QProcess::startDetached(profile.executable, arguments); + bool started = QProcess::startDetached(executable, arguments); CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex); } @@ -100,19 +104,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); - bool started = QProcess::startDetached(server.configurationFilename, arguments); + bool started = QProcess::startDetached(executable, arguments); CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex); } 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 8f9cbbe2d..18570f5db 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -111,7 +111,7 @@ void CProfilesDialog::displayProfile(int index) profileIdLabel->setText(profile.id); 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(profileDirectory); @@ -208,19 +208,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; @@ -252,13 +244,28 @@ 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); } From a9ec60ad69fea7a2cceed1ca8af0b406f33a052d Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:03:14 +0200 Subject: [PATCH 07/10] Changed: Display previous profile after one is deleted --HG-- branch : develop --- .../client/ryzom_installer/src/profilesdialog.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index 18570f5db..ac126a1b6 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -128,7 +128,7 @@ 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]; @@ -146,7 +146,14 @@ 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() From 8f88b352ab241a13594827c31e2e6899b85a41ca Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:03:37 +0200 Subject: [PATCH 08/10] Changed: Quit menu item --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp | 6 ++++++ code/ryzom/tools/client/ryzom_installer/src/mainwindow.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 217d67018..65c9c3ca3 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())); @@ -163,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(); From a9540fb9d1d8266203d30a01cd9ecb380ff70db3 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:04:19 +0200 Subject: [PATCH 09/10] Changed: Use profile ID instead of index for -p parameter --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 65c9c3ca3..c60958479 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -91,7 +91,7 @@ void CMainWindow::onPlayClicked() QStringList arguments; arguments << "-p"; - arguments << QString::number(profileIndex); + arguments << profile.id; arguments << profile.arguments.split(' '); bool started = QProcess::startDetached(executable, arguments); @@ -115,7 +115,7 @@ void CMainWindow::onConfigureClicked() QStringList arguments; arguments << "-p"; - arguments << QString::number(profileIndex); + arguments << profile.id; bool started = QProcess::startDetached(executable, arguments); From 52df4c8e562db27e11f61d33cca213c0a36b378e Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 17:05:02 +0200 Subject: [PATCH 10/10] Fixed: Preserve files permissions after copying a file --HG-- branch : develop --- .../ryzom/tools/client/ryzom_installer/src/filescopier.cpp | 7 +++++++ code/ryzom/tools/client/ryzom_installer/src/filescopier.h | 1 + 2 files changed, 8 insertions(+) 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;