From 441ab7eedcb8fe120a7f934684ed5545cdd7a4b6 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Wed, 13 Oct 2021 01:59:25 +0200 Subject: NOISSUE debranding for real, initial work This is probably very broken on macOS and Windows and will need a lot of work to complete fully. --- .gitignore | 4 +- .gitmodules | 2 + BUILD.md | 2 +- CMakeLists.txt | 165 +-- README.md | 32 +- buildconfig/BuildConfig.cpp.in | 42 +- changelog.md | 4 +- launcher/BaseInstance.h | 2 +- launcher/CMakeLists.txt | 78 +- launcher/Env.h | 2 +- launcher/GuiUtil.cpp | 4 +- launcher/InstanceList.cpp | 2 +- launcher/InstanceProxyModel.cpp | 6 +- launcher/InstanceWindow.cpp | 18 +- launcher/LaunchController.cpp | 10 +- launcher/Launcher.cpp | 1493 ++++++++++++++++++++ launcher/Launcher.h | 235 +++ launcher/Launcher.in | 94 ++ launcher/MainWindow.cpp | 198 +-- launcher/MultiMC.cpp | 1493 -------------------- launcher/MultiMC.h | 235 --- launcher/VersionProxyModel.cpp | 8 +- launcher/dialogs/AboutDialog.cpp | 4 +- launcher/dialogs/CopyInstanceDialog.cpp | 10 +- launcher/dialogs/ExportInstanceDialog.cpp | 4 +- launcher/dialogs/IconPickerDialog.cpp | 12 +- launcher/dialogs/NewComponentDialog.cpp | 4 +- launcher/dialogs/NewInstanceDialog.cpp | 24 +- launcher/dialogs/ProfileSelectDialog.cpp | 4 +- launcher/dialogs/UpdateDialog.cpp | 12 +- launcher/dialogs/VersionSelectDialog.cpp | 2 +- launcher/main.cpp | 12 +- launcher/minecraft/OneSixVersionFormat.cpp | 18 +- launcher/package/linux/MultiMC | 93 -- launcher/package/linux/multimc.desktop | 11 - launcher/pagedialog/PageDialog.cpp | 6 +- launcher/pages/global/AccountListPage.cpp | 4 +- launcher/pages/global/AccountListPage.h | 6 +- launcher/pages/global/CustomCommandsPage.cpp | 4 +- launcher/pages/global/CustomCommandsPage.h | 4 +- launcher/pages/global/ExternalToolsPage.cpp | 18 +- launcher/pages/global/ExternalToolsPage.h | 6 +- launcher/pages/global/JavaPage.cpp | 8 +- launcher/pages/global/JavaPage.h | 4 +- launcher/pages/global/LanguagePage.cpp | 2 +- launcher/pages/global/LanguagePage.h | 4 +- launcher/pages/global/LauncherPage.cpp | 466 ++++++ launcher/pages/global/LauncherPage.h | 103 ++ launcher/pages/global/LauncherPage.ui | 584 ++++++++ launcher/pages/global/MinecraftPage.cpp | 6 +- launcher/pages/global/MinecraftPage.h | 4 +- launcher/pages/global/MultiMCPage.cpp | 466 ------ launcher/pages/global/MultiMCPage.h | 103 -- launcher/pages/global/MultiMCPage.ui | 584 -------- launcher/pages/global/PasteEEPage.cpp | 6 +- launcher/pages/global/PasteEEPage.h | 4 +- launcher/pages/global/ProxyPage.cpp | 6 +- launcher/pages/global/ProxyPage.h | 4 +- launcher/pages/instance/GameOptionsPage.h | 4 +- launcher/pages/instance/InstanceSettingsPage.cpp | 14 +- launcher/pages/instance/InstanceSettingsPage.h | 4 +- launcher/pages/instance/LegacyUpgradePage.cpp | 6 +- launcher/pages/instance/LegacyUpgradePage.h | 4 +- launcher/pages/instance/LogPage.cpp | 6 +- launcher/pages/instance/LogPage.h | 4 +- launcher/pages/instance/ModFolderPage.cpp | 4 +- launcher/pages/instance/ModFolderPage.h | 4 +- launcher/pages/instance/NotesPage.h | 6 +- launcher/pages/instance/OtherLogsPage.cpp | 4 +- launcher/pages/instance/OtherLogsPage.h | 4 +- launcher/pages/instance/ScreenshotsPage.cpp | 4 +- launcher/pages/instance/ScreenshotsPage.h | 4 +- launcher/pages/instance/ServersPage.cpp | 4 +- launcher/pages/instance/ServersPage.h | 4 +- launcher/pages/instance/VersionPage.cpp | 18 +- launcher/pages/instance/WorldListPage.cpp | 8 +- launcher/pages/instance/WorldListPage.h | 4 +- launcher/pages/modplatform/ImportPage.cpp | 2 +- launcher/pages/modplatform/ImportPage.h | 4 +- launcher/pages/modplatform/VanillaPage.cpp | 2 +- launcher/pages/modplatform/VanillaPage.h | 4 +- .../pages/modplatform/atlauncher/AtlListModel.cpp | 4 +- launcher/pages/modplatform/atlauncher/AtlPage.cpp | 2 +- launcher/pages/modplatform/atlauncher/AtlPage.h | 4 +- launcher/pages/modplatform/flame/FlameModel.cpp | 4 +- launcher/pages/modplatform/flame/FlamePage.cpp | 2 +- launcher/pages/modplatform/flame/FlamePage.h | 4 +- launcher/pages/modplatform/ftb/FtbListModel.cpp | 4 +- launcher/pages/modplatform/ftb/FtbPage.h | 4 +- .../pages/modplatform/legacy_ftb/ListModel.cpp | 4 +- launcher/pages/modplatform/legacy_ftb/Page.cpp | 2 +- launcher/pages/modplatform/legacy_ftb/Page.h | 4 +- .../pages/modplatform/technic/TechnicModel.cpp | 4 +- launcher/pages/modplatform/technic/TechnicPage.cpp | 2 +- launcher/pages/modplatform/technic/TechnicPage.h | 4 +- launcher/resources/MultiMC.icns | Bin 782703 -> 0 bytes launcher/resources/MultiMC.ico | Bin 55224 -> 0 bytes launcher/resources/MultiMC.manifest | 31 - launcher/resources/multimc.rc | 29 - launcher/setupwizard/AnalyticsWizardPage.cpp | 6 +- launcher/setupwizard/JavaWizardPage.cpp | 6 +- launcher/setupwizard/LanguageWizardPage.cpp | 6 +- launcher/setupwizard/SetupWizard.cpp | 2 +- launcher/themes/ITheme.cpp | 6 +- launcher/translations/TranslationsModel.cpp | 2 +- launcher/widgets/JavaSettingsWidget.cpp | 12 +- launcher/widgets/LanguageSelectionWidget.cpp | 8 +- launcher/widgets/PageContainer.cpp | 10 +- libraries/classparser/CMakeLists.txt | 6 +- libraries/iconfix/CMakeLists.txt | 12 +- libraries/quazip | 2 +- libraries/rainbow/CMakeLists.txt | 8 +- notsecrets/CMakeLists.txt | 5 + notsecrets/Launcher.icns | Bin 0 -> 304757 bytes notsecrets/Launcher.ico | Bin 0 -> 102134 bytes notsecrets/Launcher.manifest | 31 + notsecrets/genicons.sh | 18 + notsecrets/launcher.rc | 29 + notsecrets/logo.svg | 274 ++++ secrets/multimc.rc | 29 + 120 files changed, 3862 insertions(+), 3581 deletions(-) create mode 100644 launcher/Launcher.cpp create mode 100644 launcher/Launcher.h create mode 100755 launcher/Launcher.in delete mode 100644 launcher/MultiMC.cpp delete mode 100644 launcher/MultiMC.h delete mode 100755 launcher/package/linux/MultiMC delete mode 100755 launcher/package/linux/multimc.desktop create mode 100644 launcher/pages/global/LauncherPage.cpp create mode 100644 launcher/pages/global/LauncherPage.h create mode 100644 launcher/pages/global/LauncherPage.ui delete mode 100644 launcher/pages/global/MultiMCPage.cpp delete mode 100644 launcher/pages/global/MultiMCPage.h delete mode 100644 launcher/pages/global/MultiMCPage.ui delete mode 100644 launcher/resources/MultiMC.icns delete mode 100644 launcher/resources/MultiMC.ico delete mode 100644 launcher/resources/MultiMC.manifest delete mode 100644 launcher/resources/multimc.rc create mode 100644 notsecrets/Launcher.icns create mode 100644 notsecrets/Launcher.ico create mode 100644 notsecrets/Launcher.manifest create mode 100755 notsecrets/genicons.sh create mode 100644 notsecrets/launcher.rc create mode 100644 notsecrets/logo.svg create mode 100644 secrets/multimc.rc diff --git a/.gitignore b/.gitignore index 6b716252..84bf1676 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,5 @@ tags #OSX Stuff .DS_Store -branding -secrets +branding/ +secrets/ diff --git a/.gitmodules b/.gitmodules index bd51ef80..04a561c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,8 @@ [submodule "depends/libnbtplusplus"] path = libraries/libnbtplusplus url = https://github.com/MultiMC/libnbtplusplus.git + pushurl = git@github.com:MultiMC/libnbtplusplus.git [submodule "libraries/quazip"] path = libraries/quazip url = https://github.com/MultiMC/quazip.git + pushurl = git@github.com:MultiMC/quazip.git diff --git a/BUILD.md b/BUILD.md index de97433b..faa9fa85 100644 --- a/BUILD.md +++ b/BUILD.md @@ -197,7 +197,7 @@ cmake \ -DCMAKE_INSTALL_PREFIX:PATH="../dist/" \ -DCMAKE_PREFIX_PATH="/path/to/Qt5.6/" \ -DQt5_DIR="/path/to/Qt5.6/" \ - -DMultiMC_LAYOUT=mac-bundle \ + -DLauncher_LAYOUT=mac-bundle \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \ .. make install diff --git a/CMakeLists.txt b/CMakeLists.txt index 44028f76..e4aae98b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.1) string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD) if(IS_IN_SOURCE_BUILD) - message(FATAL_ERROR "You are building MultiMC in-source. Please separate the build tree from the source tree.") + message(FATAL_ERROR "You are building the Launcher in-source. Please separate the build tree from the source tree.") endif() if (CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_HOST_SYSTEM_VERSION MATCHES ".*[Mm]icrosoft.*" OR CMAKE_HOST_SYSTEM_VERSION MATCHES ".*WSL.*" ) - message(FATAL_ERROR "Building MultiMC is not supported in Linux-on-Windows distributions.") + message(FATAL_ERROR "Building the Launcher is not supported in Linux-on-Windows distributions.") endif() endif() @@ -18,7 +18,7 @@ if(WIN32) cmake_policy(SET CMP0020 OLD) endif() -project(MultiMC) +project(Launcher) enable_testing() @@ -50,61 +50,61 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type") ##################################### Set Application options ##################################### ######## Set URLs ######## -set(MultiMC_NEWS_RSS_URL "https://multimc.org/rss.xml" CACHE STRING "URL to fetch MultiMC's news RSS feed from.") +set(Launcher_NEWS_RSS_URL "https://multimc.org/rss.xml" CACHE STRING "URL to fetch Launcher's news RSS feed from.") ######## Set version numbers ######## -set(MultiMC_VERSION_MAJOR 0) -set(MultiMC_VERSION_MINOR 6) -set(MultiMC_VERSION_HOTFIX 13) +set(Launcher_VERSION_MAJOR 0) +set(Launcher_VERSION_MINOR 6) +set(Launcher_VERSION_HOTFIX 13) # Build number -set(MultiMC_VERSION_BUILD -1 CACHE STRING "Build number. -1 for no build number.") +set(Launcher_VERSION_BUILD -1 CACHE STRING "Build number. -1 for no build number.") # Build platform. -set(MultiMC_BUILD_PLATFORM "" CACHE STRING "A short string identifying the platform that this build was built for. Only used by the notification system and to display in the about dialog.") +set(Launcher_BUILD_PLATFORM "" CACHE STRING "A short string identifying the platform that this build was built for. Only used by the notification system and to display in the about dialog.") # Channel list URL -set(MultiMC_UPDATER_BASE "" CACHE STRING "Base URL for the updater.") +set(Launcher_UPDATER_BASE "" CACHE STRING "Base URL for the updater.") # Notification URL -set(MultiMC_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.") +set(Launcher_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.") # The metadata server -set(MultiMC_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch MultiMC's meta files from.") +set(Launcher_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch Launcher's meta files from.") # paste.ee API key -set(MultiMC_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE STRING "API key you can get from paste.ee when you register an account") +set(Launcher_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE STRING "API key you can get from paste.ee when you register an account") # Imgur API Client ID -set(MultiMC_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application") +set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application") # Google analytics ID -set(MultiMC_ANALYTICS_ID "UA-87731965-2" CACHE STRING "ID you can get from Google analytics") +set(Launcher_ANALYTICS_ID "UA-87731965-2" CACHE STRING "ID you can get from Google analytics") # Bug tracker URL -set(MultiMC_BUG_TRACKER_URL "" CACHE STRING "URL for the bug tracker.") +set(Launcher_BUG_TRACKER_URL "" CACHE STRING "URL for the bug tracker.") # Discord URL -set(MultiMC_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") +set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") # Subreddit URL -set(MultiMC_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.") +set(Launcher_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.") - -option(MultiMC_EMBED_SECRETS "Determines whether to embed secrets. Secrets are separate and non-public." OFF) +# Use the secrets library or a public stub? +option(Launcher_EMBED_SECRETS "Determines whether to embed secrets. Secrets are separate and non-public." OFF) #### Check the current Git commit and branch include(GetGitRevisionDescription) -get_git_head_revision(MultiMC_GIT_REFSPEC MultiMC_GIT_COMMIT) +get_git_head_revision(Launcher_GIT_REFSPEC Launcher_GIT_COMMIT) -message(STATUS "Git commit: ${MultiMC_GIT_COMMIT}") -message(STATUS "Git refspec: ${MultiMC_GIT_REFSPEC}") +message(STATUS "Git commit: ${Launcher_GIT_COMMIT}") +message(STATUS "Git refspec: ${Launcher_GIT_REFSPEC}") -set(MultiMC_RELEASE_VERSION_NAME "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}") +set(Launcher_RELEASE_VERSION_NAME "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}") #### Custom target to just print the version. -add_custom_target(version echo "Version: ${MultiMC_RELEASE_VERSION_NAME}") -add_custom_target(tcversion echo "\\#\\#teamcity[setParameter name=\\'env.MULTIMC_VERSION\\' value=\\'${MultiMC_RELEASE_VERSION_NAME}\\']") +add_custom_target(version echo "Version: ${Launcher_RELEASE_VERSION_NAME}") +add_custom_target(tcversion echo "\\#\\#teamcity[setParameter name=\\'env.LAUNCHER_VERSION\\' value=\\'${Launcher_RELEASE_VERSION_NAME}\\']") ################################ 3rd Party Libs ################################ @@ -129,47 +129,55 @@ if (Qt5_POSITION_INDEPENDENT_CODE) SET(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +####################################### Secrets ####################################### + +if(Launcher_EMBED_SECRETS) + add_subdirectory(secrets) +else() + add_subdirectory(notsecrets) +endif() + ####################################### Install layout ####################################### # How to install the build results -set(MultiMC_LAYOUT "auto" CACHE STRING "The layout for MultiMC installation (auto, win-bundle, lin-bundle, lin-nodeps, lin-system, mac-bundle)") -set_property(CACHE MultiMC_LAYOUT PROPERTY STRINGS auto win-bundle lin-bundle lin-nodeps lin-system mac-bundle) +set(Launcher_LAYOUT "auto" CACHE STRING "The layout for the launcher installation (auto, win-bundle, lin-nodeps, mac-bundle)") +set_property(CACHE Launcher_LAYOUT PROPERTY STRINGS auto win-bundle lin-nodeps mac-bundle) -if(MultiMC_LAYOUT STREQUAL "auto") +if(Launcher_LAYOUT STREQUAL "auto") if(UNIX AND APPLE) - set(MultiMC_LAYOUT_REAL "mac-bundle") + set(Launcher_LAYOUT_REAL "mac-bundle") elseif(UNIX) - set(MultiMC_LAYOUT_REAL "lin-nodeps") + set(Launcher_LAYOUT_REAL "lin-nodeps") elseif(WIN32) - set(MultiMC_LAYOUT_REAL "win-bundle") + set(Launcher_LAYOUT_REAL "win-bundle") else() message(FATAL_ERROR "Cannot choose a sensible install layout for your platform.") endif() else() - set(MultiMC_LAYOUT_REAL ${MultiMC_LAYOUT}) + set(Launcher_LAYOUT_REAL ${Launcher_LAYOUT}) endif() -if(MultiMC_LAYOUT_REAL STREQUAL "mac-bundle") - set(BINARY_DEST_DIR "MultiMC.app/Contents/MacOS") - set(LIBRARY_DEST_DIR "MultiMC.app/Contents/MacOS") - set(PLUGIN_DEST_DIR "MultiMC.app/Contents/MacOS") - set(RESOURCES_DEST_DIR "MultiMC.app/Contents/Resources") - set(JARS_DEST_DIR "MultiMC.app/Contents/MacOS/jars") +if(Launcher_LAYOUT_REAL STREQUAL "mac-bundle") + set(BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS") + set(LIBRARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS") + set(PLUGIN_DEST_DIR "${Launcher_Name}.app/Contents/MacOS") + set(RESOURCES_DEST_DIR "${Launcher_Name}.app/Contents/Resources") + set(JARS_DEST_DIR "${Launcher_Name}.app/Contents/MacOS/jars") set(BUNDLE_DEST_DIR ".") # Apps to bundle - set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app") + set(APPS "\${CMAKE_INSTALL_PREFIX}/${Launcher_Name}.app") # Mac bundle settings - set(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC") - set(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.") - set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.multimc.MultiMC5") - set(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}") - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}") - set(MACOSX_BUNDLE_ICON_FILE MultiMC.icns) - set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2015-2021 MultiMC Contributors") + set(MACOSX_BUNDLE_BUNDLE_NAME "${Launcher_Name}") + set(MACOSX_BUNDLE_INFO_STRING "${Launcher_Name}: Minecraft launcher and management utility.") + set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.multimc.${Launcher_Name}") + set(MACOSX_BUNDLE_BUNDLE_VERSION "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}.${Launcher_VERSION_BUILD}") + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}.${Launcher_VERSION_BUILD}") + set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}.${Launcher_VERSION_BUILD}") + set(MACOSX_BUNDLE_ICON_FILE ${Launcher_Name}.icns) + set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2015-2021 ${Launcher_Copyright}") # directories to look for dependencies set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) @@ -178,32 +186,9 @@ if(MultiMC_LAYOUT_REAL STREQUAL "mac-bundle") set(INSTALL_BUNDLE "full") # Add the icon - install(FILES launcher/resources/MultiMC.icns DESTINATION ${RESOURCES_DEST_DIR}) - -elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-bundle") - set(BINARY_DEST_DIR "bin") - set(LIBRARY_DEST_DIR "bin") - set(PLUGIN_DEST_DIR "plugins") - set(BUNDLE_DEST_DIR ".") - set(RESOURCES_DEST_DIR ".") - set(JARS_DEST_DIR "bin/jars") - - # Apps to bundle - set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") - - # directories to look for dependencies - set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + install(FILES ${Launcher_Branding_ICNS} DESTINATION ${RESOURCES_DEST_DIR}) - # install as bundle - set(INSTALL_BUNDLE "full") - - # Set RPATH - SET(MultiMC_BINARY_RPATH "$ORIGIN/") - - # Install basic runner script - install(PROGRAMS launcher/package/linux/MultiMC DESTINATION ${BUNDLE_DEST_DIR}) - -elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-nodeps") +elseif(Launcher_LAYOUT_REAL STREQUAL "lin-nodeps") set(BINARY_DEST_DIR "bin") set(LIBRARY_DEST_DIR "bin") set(PLUGIN_DEST_DIR "plugins") @@ -215,28 +200,13 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-nodeps") set(INSTALL_BUNDLE "nodeps") # Set RPATH - SET(MultiMC_BINARY_RPATH "$ORIGIN/") + SET(Launcher_BINARY_RPATH "$ORIGIN/") # Install basic runner script - install(PROGRAMS launcher/package/linux/MultiMC DESTINATION ${BUNDLE_DEST_DIR}) - -elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-system") - set(MultiMC_APP_BINARY_NAME "multimc" CACHE STRING "Name of the MultiMC binary") - set(MultiMC_BINARY_DEST_DIR "bin" CACHE STRING "Path to the binary directory") - set(MultiMC_LIBRARY_DEST_DIR "lib${LIB_SUFFIX}" CACHE STRING "Path to the library directory") - set(MultiMC_SHARE_DEST_DIR "share/multimc" CACHE STRING "Path to the shared data directory") - set(JARS_DEST_DIR "${MultiMC_SHARE_DEST_DIR}/jars") - - set(BINARY_DEST_DIR ${MultiMC_BINARY_DEST_DIR}) - set(LIBRARY_DEST_DIR ${MultiMC_LIBRARY_DEST_DIR}) - - MESSAGE(STATUS "Compiling for linux system with ${MultiMC_SHARE_DEST_DIR} and MULTIMC_LINUX_DATADIR") - SET(MultiMC_APP_BINARY_DEFS "-DMULTIMC_JARS_LOCATION=${CMAKE_INSTALL_PREFIX}/${JARS_DEST_DIR}" "-DMULTIMC_LINUX_DATADIR") + configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY) + install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION ${BUNDLE_DEST_DIR} RENAME ${Launcher_Name}) - # install as bundle with no dependencies included - set(INSTALL_BUNDLE "nodeps") - -elseif(MultiMC_LAYOUT_REAL STREQUAL "win-bundle") +elseif(Launcher_LAYOUT_REAL STREQUAL "win-bundle") set(BINARY_DEST_DIR ".") set(LIBRARY_DEST_DIR ".") set(PLUGIN_DEST_DIR ".") @@ -245,7 +215,7 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "win-bundle") set(JARS_DEST_DIR "jars") # Apps to bundle - set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") + set(APPS "\${CMAKE_INSTALL_PREFIX}/${Launcher_Name}.exe") # directories to look for dependencies set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) @@ -264,7 +234,7 @@ set_directory_properties(PROPERTIES EP_BASE External) option(NBT_BUILD_SHARED "Build NBT shared library" ON) option(NBT_USE_ZLIB "Build NBT library with zlib support" OFF) option(NBT_BUILD_TESTS "Build NBT library tests" OFF) #FIXME: fix unit tests. -set(NBT_NAME MultiMC_nbt++) +set(NBT_NAME Launcher_nbt++) set(NBT_DEST_DIR ${LIBRARY_DEST_DIR}) add_subdirectory(libraries/libnbtplusplus) @@ -287,12 +257,5 @@ add_subdirectory(libraries/katabasis) # An OAuth2 library that tried to do too m add_subdirectory(buildconfig) -if(MultiMC_EMBED_SECRETS) - add_subdirectory(secrets) -else() - add_subdirectory(notsecrets) -endif() - - # NOTE: this must always be last to appease the CMake deity of quirky install command evaluation order. add_subdirectory(launcher) diff --git a/README.md b/README.md index 92260d5e..84a1e4c4 100644 --- a/README.md +++ b/README.md @@ -48,33 +48,33 @@ Unless required by applicable law or agreed to in writing, software distributed ## Build status ### Linux (Intel32) - -Build: + +Build: - -Deploy: + +Deploy: ### Linux (AMD64) - -Build: + +Build: - -Deploy: + +Deploy: ### macOS (AMD64) - -Build: + +Build: - -Deploy: + +Deploy: ### Windows (Intel32) - -Build: + +Build: - -Deploy: + +Deploy: diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index d9f4d1f1..1b223b5d 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -6,19 +6,19 @@ const Config BuildConfig; Config::Config() { // Version information - VERSION_MAJOR = @MultiMC_VERSION_MAJOR@; - VERSION_MINOR = @MultiMC_VERSION_MINOR@; - VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@; - VERSION_BUILD = @MultiMC_VERSION_BUILD@; - - BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@"; - UPDATER_BASE = "@MultiMC_UPDATER_BASE@"; - ANALYTICS_ID = "@MultiMC_ANALYTICS_ID@"; - NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@"; - FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@"; - - GIT_COMMIT = "@MultiMC_GIT_COMMIT@"; - GIT_REFSPEC = "@MultiMC_GIT_REFSPEC@"; + VERSION_MAJOR = @Launcher_VERSION_MAJOR@; + VERSION_MINOR = @Launcher_VERSION_MINOR@; + VERSION_HOTFIX = @Launcher_VERSION_HOTFIX@; + VERSION_BUILD = @Launcher_VERSION_BUILD@; + + BUILD_PLATFORM = "@Launcher_BUILD_PLATFORM@"; + UPDATER_BASE = "@Launcher_UPDATER_BASE@"; + ANALYTICS_ID = "@Launcher_ANALYTICS_ID@"; + NOTIFICATION_URL = "@Launcher_NOTIFICATION_URL@"; + FULL_VERSION_STR = "@Launcher_VERSION_MAJOR@.@Launcher_VERSION_MINOR@.@Launcher_VERSION_BUILD@"; + + GIT_COMMIT = "@Launcher_GIT_COMMIT@"; + GIT_REFSPEC = "@Launcher_GIT_REFSPEC@"; if(GIT_REFSPEC.startsWith("refs/heads/") && !UPDATER_BASE.isEmpty() && !BUILD_PLATFORM.isEmpty() && VERSION_BUILD >= 0) { VERSION_CHANNEL = GIT_REFSPEC; @@ -30,15 +30,15 @@ Config::Config() VERSION_CHANNEL = QObject::tr("custom"); } - VERSION_STR = "@MultiMC_VERSION_STRING@"; - NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; - PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; - IMGUR_CLIENT_ID = "@MultiMC_IMGUR_CLIENT_ID@"; - META_URL = "@MultiMC_META_URL@"; + VERSION_STR = "@Launcher_VERSION_STRING@"; + NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@"; + PASTE_EE_KEY = "@Launcher_PASTE_EE_API_KEY@"; + IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@"; + META_URL = "@Launcher_META_URL@"; - BUG_TRACKER_URL = "@MultiMC_BUG_TRACKER_URL@"; - DISCORD_URL = "@MultiMC_DISCORD_URL@"; - SUBREDDIT_URL = "@MultiMC_SUBREDDIT_URL@"; + BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@"; + DISCORD_URL = "@Launcher_DISCORD_URL@"; + SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@"; } QString Config::printableVersionString() const diff --git a/changelog.md b/changelog.md index 97454d7f..e864a4c7 100644 --- a/changelog.md +++ b/changelog.md @@ -1121,7 +1121,7 @@ Fluffy and functional! - GH-1275: Server resource pack folder is created on launch. - This is a workaround for Minecraft bug MCL-3732. - GH-1320: Improve compatibility with non-Oracle Java. - - GH-1355: MMC environment will no longer leak into Minecraft after MultiMC updates itself. + - GH-1355: LAUNCHER environment will no longer leak into Minecraft after MultiMC updates itself. - Minecraft log: - Java exception detection in Minecraft logs has been improved. @@ -1166,7 +1166,7 @@ Fluffy and functional! - GH-1069, GH-1100: `LD_LIBRARY_PATH` and `LD_PRELOAD` environment variables supplied to MultiMC now don't affect MultiMC but affect the launched game. This means you can use something like the Steam overlay in MultiMC instances on Linux. - If you need to use these variables for MultiMC itself, you can use `MMC_LIBRARY_PATH` and `MMC_PRELOAD` instead. + If you need to use these variables for MultiMC itself, you can use `LAUNCHER_LIBRARY_PATH` and `LAUNCHER_PRELOAD` instead. - GH-1389: External processes (like folder views, editors, etc.) are now started in a way that prevents the MultiMC environment to be reused by them. - GH-1355: If `LD_LIBRARY_PATH` contains any of MultiMC's internal folders, this will not propagate to started processes. diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 8c08dc05..51258933 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -78,7 +78,7 @@ public: */ void invalidate(); - /// The instance's ID. The ID SHALL be determined by MMC internally. The ID IS guaranteed to + /// The instance's ID. The ID SHALL be determined by LAUNCHER internally. The ID IS guaranteed to /// be unique. virtual QString id() const; diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 4ec6a7d1..d1216f86 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -88,13 +88,13 @@ set(CORE_SOURCES add_unit_test(FileSystem SOURCES FileSystem_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic DATA testdata ) add_unit_test(GZip SOURCES GZip_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) set(PATHMATCHER_SOURCES @@ -158,13 +158,13 @@ set(UPDATE_SOURCES add_unit_test(UpdateChecker SOURCES updater/UpdateChecker_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic DATA updater/testdata ) add_unit_test(DownloadTask SOURCES updater/DownloadTask_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic DATA updater/testdata ) @@ -337,14 +337,14 @@ set(MINECRAFT_SOURCES add_unit_test(GradleSpecifier SOURCES minecraft/GradleSpecifier_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) add_executable(PackageManifest mojang/PackageManifest_test.cpp ) target_link_libraries(PackageManifest - MultiMC_logic + Launcher_logic Qt5::Test ) target_include_directories(PackageManifest @@ -358,25 +358,25 @@ add_test( add_unit_test(MojangVersionFormat SOURCES minecraft/MojangVersionFormat_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic DATA minecraft/testdata ) add_unit_test(Library SOURCES minecraft/Library_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) # FIXME: shares data with FileSystem test add_unit_test(ModFolderModel SOURCES minecraft/mod/ModFolderModel_test.cpp DATA testdata - LIBS MultiMC_logic + LIBS Launcher_logic ) add_unit_test(ParseUtils SOURCES minecraft/ParseUtils_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) # the screenshots feature @@ -414,7 +414,7 @@ set(SETTINGS_SOURCES add_unit_test(INIFile SOURCES settings/INIFile_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) set(JAVA_SOURCES @@ -437,7 +437,7 @@ set(JAVA_SOURCES add_unit_test(JavaVersion SOURCES java/JavaVersion_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) set(TRANSLATIONS_SOURCES @@ -523,7 +523,7 @@ set(ATLAUNCHER_SOURCES add_unit_test(Index SOURCES meta/Index_test.cpp - LIBS MultiMC_logic + LIBS Launcher_logic ) ################################ COMPILE ################################ @@ -557,8 +557,8 @@ set(LOGIC_SOURCES SET(MULTIMC_SOURCES # Application base - MultiMC.h - MultiMC.cpp + Launcher.h + Launcher.cpp UpdateController.cpp UpdateController.h @@ -678,8 +678,8 @@ SET(MULTIMC_SOURCES pages/global/LanguagePage.h pages/global/MinecraftPage.cpp pages/global/MinecraftPage.h - pages/global/MultiMCPage.cpp - pages/global/MultiMCPage.h + pages/global/LauncherPage.cpp + pages/global/LauncherPage.h pages/global/ProxyPage.cpp pages/global/ProxyPage.h pages/global/PasteEEPage.cpp @@ -831,7 +831,7 @@ SET(MULTIMC_UIS pages/global/ExternalToolsPage.ui pages/global/JavaPage.ui pages/global/MinecraftPage.ui - pages/global/MultiMCPage.ui + pages/global/LauncherPage.ui pages/global/ProxyPage.ui pages/global/PasteEEPage.ui @@ -891,11 +891,11 @@ qt5_wrap_ui(MULTIMC_UI ${MULTIMC_UIS}) qt5_add_resources(MULTIMC_RESOURCES ${MULTIMC_QRCS}) # Add executable -add_library(MultiMC_logic STATIC ${LOGIC_SOURCES} ${MULTIMC_SOURCES} ${MULTIMC_UI} ${MULTIMC_RESOURCES}) -target_link_libraries(MultiMC_logic +add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${MULTIMC_SOURCES} ${MULTIMC_UI} ${MULTIMC_RESOURCES}) +target_link_libraries(Launcher_logic systeminfo - MultiMC_quazip - MultiMC_classparser + Launcher_quazip + Launcher_classparser ${NBT_NAME} ${ZLIB_LIBRARIES} optional-bare @@ -903,46 +903,46 @@ target_link_libraries(MultiMC_logic BuildConfig Katabasis ) -target_link_libraries(MultiMC_logic +target_link_libraries(Launcher_logic Qt5::Core Qt5::Xml Qt5::Network Qt5::Concurrent Qt5::Gui ) -target_link_libraries(MultiMC_logic - MultiMC_iconfix +target_link_libraries(Launcher_logic + Launcher_iconfix ${QUAZIP_LIBRARIES} hoedown - MultiMC_rainbow + Launcher_rainbow LocalPeer ganalytics ) -add_executable(MultiMC MACOSX_BUNDLE WIN32 main.cpp ${MULTIMC_RCS}) -target_link_libraries(MultiMC MultiMC_logic) +target_link_libraries(Launcher_logic secrets) -if(DEFINED MultiMC_APP_BINARY_NAME) - set_target_properties(MultiMC PROPERTIES OUTPUT_NAME "${MultiMC_APP_BINARY_NAME}") +add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${MULTIMC_RCS}) +target_link_libraries(${Launcher_Name} Launcher_logic) + +if(DEFINED Launcher_APP_BINARY_NAME) + set_target_properties(${Launcher_Name} PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}") endif() -if(DEFINED MultiMC_BINARY_RPATH) - SET_TARGET_PROPERTIES(MultiMC PROPERTIES INSTALL_RPATH "${MultiMC_BINARY_RPATH}") +if(DEFINED Launcher_BINARY_RPATH) + SET_TARGET_PROPERTIES(${Launcher_Name} PROPERTIES INSTALL_RPATH "${Launcher_BINARY_RPATH}") endif() -if(DEFINED MultiMC_APP_BINARY_DEFS) - target_compile_definitions(MultiMC PRIVATE ${MultiMC_APP_BINARY_DEFS}) - target_compile_definitions(MultiMC_logic PRIVATE ${MultiMC_APP_BINARY_DEFS}) +if(DEFINED Launcher_APP_BINARY_DEFS) + target_compile_definitions(${Launcher_Name} PRIVATE ${Launcher_APP_BINARY_DEFS}) + target_compile_definitions(Launcher_logic PRIVATE ${Launcher_APP_BINARY_DEFS}) endif() -install(TARGETS MultiMC +install(TARGETS ${Launcher_Name} BUNDLE DESTINATION ${BUNDLE_DEST_DIR} COMPONENT Runtime LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime ) -target_link_libraries(MultiMC_logic secrets) - -#### The MultiMC bundle mess! #### +#### The bundle mess! #### # Bundle utilities are used to complete the portable packages - they add all the libraries that would otherwise be missing on the target system. # NOTE: it seems that this absolutely has to be here, and nowhere else. if(INSTALL_BUNDLE STREQUAL "full") diff --git a/launcher/Env.h b/launcher/Env.h index 7d1a8bc9..52427696 100644 --- a/launcher/Env.h +++ b/launcher/Env.h @@ -25,7 +25,7 @@ class Index; class Env { - friend class MultiMC; + friend class Launcher; private: struct Private; Env(); diff --git a/launcher/GuiUtil.cpp b/launcher/GuiUtil.cpp index 302206f5..3dd31c7a 100644 --- a/launcher/GuiUtil.cpp +++ b/launcher/GuiUtil.cpp @@ -8,7 +8,7 @@ #include "net/PasteUpload.h" #include "dialogs/CustomMessageBox.h" -#include "MultiMC.h" +#include "Launcher.h" #include #include #include @@ -16,7 +16,7 @@ QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) { ProgressDialog dialog(parentWidget); - auto APIKeySetting = MMC->settings()->get("PasteEEAPIKey").toString(); + auto APIKeySetting = LAUNCHER->settings()->get("PasteEEAPIKey").toString(); if(APIKeySetting == "multimc") { APIKeySetting = BuildConfig.PASTE_EE_KEY; diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index cb38853b..42b2ae1a 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -822,7 +822,7 @@ Task * InstanceList::wrapInstanceTask(InstanceTask * task) QString InstanceList::getStagedInstancePath() { QString key = QUuid::createUuid().toString(); - QString relPath = FS::PathCombine("_MMC_TEMP/" , key); + QString relPath = FS::PathCombine("_LAUNCHER_TEMP/" , key); QDir rootPath(m_instDir); auto path = FS::PathCombine(m_instDir, relPath); if(!rootPath.mkpath(relPath)) diff --git a/launcher/InstanceProxyModel.cpp b/launcher/InstanceProxyModel.cpp index 5317f60c..0311c239 100644 --- a/launcher/InstanceProxyModel.cpp +++ b/launcher/InstanceProxyModel.cpp @@ -1,5 +1,5 @@ #include "InstanceProxyModel.h" -#include "MultiMC.h" +#include "Launcher.h" #include #include @@ -12,7 +12,7 @@ QVariant InstanceProxyModel::data(const QModelIndex & index, int role) const QVariant data = QSortFilterProxyModel::data(index, role); if(role == Qt::DecorationRole) { - return QVariant(MMC->icons()->getIcon(data.toString())); + return QVariant(LAUNCHER->icons()->getIcon(data.toString())); } return data; } @@ -22,7 +22,7 @@ bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, { BaseInstance *pdataLeft = static_cast(left.internalPointer()); BaseInstance *pdataRight = static_cast(right.internalPointer()); - QString sortMode = MMC->settings()->get("InstSortMode").toString(); + QString sortMode = LAUNCHER->settings()->get("InstSortMode").toString(); if (sortMode == "LastLaunch") { return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); diff --git a/launcher/InstanceWindow.cpp b/launcher/InstanceWindow.cpp index 015ffe1c..8f73671b 100644 --- a/launcher/InstanceWindow.cpp +++ b/launcher/InstanceWindow.cpp @@ -14,7 +14,7 @@ */ #include "InstanceWindow.h" -#include "MultiMC.h" +#include "Launcher.h" #include #include @@ -35,7 +35,7 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent) { setAttribute(Qt::WA_DeleteOnClose); - auto icon = MMC->icons()->getIcon(m_instance->iconKey()); + auto icon = LAUNCHER->icons()->getIcon(m_instance->iconKey()); QString windowTitle = tr("Console window for ") + m_instance->name(); // Set window properties @@ -87,9 +87,9 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent) // restore window state { - auto base64State = MMC->settings()->get("ConsoleWindowState").toByteArray(); + auto base64State = LAUNCHER->settings()->get("ConsoleWindowState").toByteArray(); restoreState(QByteArray::fromBase64(base64State)); - auto base64Geometry = MMC->settings()->get("ConsoleWindowGeometry").toByteArray(); + auto base64Geometry = LAUNCHER->settings()->get("ConsoleWindowGeometry").toByteArray(); restoreGeometry(QByteArray::fromBase64(base64Geometry)); } @@ -148,7 +148,7 @@ void InstanceWindow::updateLaunchButtons() void InstanceWindow::on_btnLaunchMinecraftOffline_clicked() { - MMC->launch(m_instance, false, nullptr); + LAUNCHER->launch(m_instance, false, nullptr); } void InstanceWindow::on_InstanceLaunchTask_changed(shared_qobject_ptr proc) @@ -183,8 +183,8 @@ void InstanceWindow::closeEvent(QCloseEvent *event) return; } - MMC->settings()->set("ConsoleWindowState", saveState().toBase64()); - MMC->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); + LAUNCHER->settings()->set("ConsoleWindowState", saveState().toBase64()); + LAUNCHER->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); emit isClosing(); event->accept(); } @@ -198,11 +198,11 @@ void InstanceWindow::on_btnKillMinecraft_clicked() { if(m_instance->isRunning()) { - MMC->kill(m_instance); + LAUNCHER->kill(m_instance); } else { - MMC->launch(m_instance, true, nullptr); + LAUNCHER->launch(m_instance, true, nullptr); } } diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 190605fd..15972923 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -1,7 +1,7 @@ #include "LaunchController.h" #include "MainWindow.h" #include -#include "MultiMC.h" +#include "Launcher.h" #include "dialogs/CustomMessageBox.h" #include "dialogs/ProfileSelectDialog.h" #include "dialogs/ProgressDialog.h" @@ -39,7 +39,7 @@ void LaunchController::login() { JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget); // Find an account to use. - std::shared_ptr accounts = MMC->accounts(); + std::shared_ptr accounts = LAUNCHER->accounts(); if (accounts->count() <= 0) { // Tell the user they need to log in at least one account in order to play. @@ -56,7 +56,7 @@ void LaunchController::login() { if (reply == QMessageBox::Yes) { // Open the account manager. - MMC->ShowGlobalSettings(m_parentWidget, "accounts"); + LAUNCHER->ShowGlobalSettings(m_parentWidget, "accounts"); } } @@ -254,7 +254,7 @@ void LaunchController::launchInstance() auto showConsole = m_instance->settings()->get("ShowConsole").toBool(); if(!console && showConsole) { - MMC->showInstanceWindow(m_instance); + LAUNCHER->showInstanceWindow(m_instance); } connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch); connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded); @@ -360,7 +360,7 @@ void LaunchController::onFailed(QString reason) { if(m_instance->settings()->get("ShowConsoleOnError").toBool()) { - MMC->showInstanceWindow(m_instance, "console"); + LAUNCHER->showInstanceWindow(m_instance, "console"); } emitFailed(reason); } diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp new file mode 100644 index 00000000..ab74a324 --- /dev/null +++ b/launcher/Launcher.cpp @@ -0,0 +1,1493 @@ +#include "Launcher.h" +#include "BuildConfig.h" +#include "MainWindow.h" +#include "InstanceWindow.h" + +#include "groupview/AccessibleGroupView.h" +#include + +#include "pages/BasePageProvider.h" +#include "pages/global/LauncherPage.h" +#include "pages/global/MinecraftPage.h" +#include "pages/global/JavaPage.h" +#include "pages/global/LanguagePage.h" +#include "pages/global/ProxyPage.h" +#include "pages/global/ExternalToolsPage.h" +#include "pages/global/AccountListPage.h" +#include "pages/global/PasteEEPage.h" +#include "pages/global/CustomCommandsPage.h" + +#include "themes/ITheme.h" +#include "themes/SystemTheme.h" +#include "themes/DarkTheme.h" +#include "themes/BrightTheme.h" +#include "themes/CustomTheme.h" + +#include "setupwizard/SetupWizard.h" +#include "setupwizard/LanguageWizardPage.h" +#include "setupwizard/JavaWizardPage.h" +#include "setupwizard/AnalyticsWizardPage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dialogs/CustomMessageBox.h" +#include "InstanceList.h" + +#include +#include "icons/IconList.h" +#include "net/HttpMetaCache.h" +#include "Env.h" + +#include "java/JavaUtils.h" + +#include "updater/UpdateChecker.h" + +#include "tools/JProfiler.h" +#include "tools/JVisualVM.h" +#include "tools/MCEditTool.h" + +#include +#include "settings/INISettingsObject.h" +#include "settings/Setting.h" + +#include "translations/TranslationsModel.h" + +#include +#include +#include +#include + +#include +#include + +#include "pagedialog/PageDialog.h" + + +#if defined Q_OS_WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#endif + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +static const QLatin1String liveCheckFile("live.check"); + +using namespace Commandline; + +#define MACOS_HINT "If you are on macOS Sierra, you might have to move MultiMC.app to your /Applications or ~/Applications folder. "\ + "This usually fixes the problem and you can move the application elsewhere afterwards.\n"\ + "\n" + +namespace { +void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + const char *levels = "DWCFIS"; + const QString format("%1 %2 %3\n"); + + qint64 msecstotal = LAUNCHER->timeSinceStart(); + qint64 seconds = msecstotal / 1000; + qint64 msecs = msecstotal % 1000; + QString foo; + char buf[1025] = {0}; + ::snprintf(buf, 1024, "%5lld.%03lld", seconds, msecs); + + QString out = format.arg(buf).arg(levels[type]).arg(msg); + + LAUNCHER->logFile->write(out.toUtf8()); + LAUNCHER->logFile->flush(); + QTextStream(stderr) << out.toLocal8Bit(); + fflush(stderr); +} + +QString getIdealPlatform(QString currentPlatform) { + auto info = Sys::getKernelInfo(); + switch(info.kernelType) { + case Sys::KernelType::Darwin: { + if(info.kernelMajor >= 17) { + // macOS 10.13 or newer + return "osx64-5.15.2"; + } + else { + // macOS 10.12 or older + return "osx64"; + } + } + case Sys::KernelType::Windows: { + // FIXME: 5.15.2 is not stable on Windows, due to a large number of completely unpredictable and hard to reproduce issues + break; +/* + if(info.kernelMajor == 6 && info.kernelMinor >= 1) { + // Windows 7 + return "win32-5.15.2"; + } + else if (info.kernelMajor > 6) { + // Above Windows 7 + return "win32-5.15.2"; + } + else { + // Below Windows 7 + return "win32"; + } +*/ + } + case Sys::KernelType::Undetermined: + case Sys::KernelType::Linux: { + break; + } + } + return currentPlatform; +} + +} + +Launcher::Launcher(int &argc, char **argv) : QApplication(argc, argv) +{ +#if defined Q_OS_WIN32 + // attach the parent console + if(AttachConsole(ATTACH_PARENT_PROCESS)) + { + // if attach succeeds, reopen and sync all the i/o + if(freopen("CON", "w", stdout)) + { + std::cout.sync_with_stdio(); + } + if(freopen("CON", "w", stderr)) + { + std::cerr.sync_with_stdio(); + } + if(freopen("CON", "r", stdin)) + { + std::cin.sync_with_stdio(); + } + auto out = GetStdHandle (STD_OUTPUT_HANDLE); + DWORD written; + const char * endline = "\n"; + WriteConsole(out, endline, strlen(endline), &written, NULL); + consoleAttached = true; + } +#endif + setOrganizationName("MultiMC"); + setOrganizationDomain("multimc.org"); + setApplicationName("MultiMC5"); + setApplicationDisplayName("MultiMC 5"); + setApplicationVersion(BuildConfig.printableVersionString()); + + startTime = QDateTime::currentDateTime(); + +#ifdef Q_OS_LINUX + { + QFile osrelease("/proc/sys/kernel/osrelease"); + if (osrelease.open(QFile::ReadOnly | QFile::Text)) { + QTextStream in(&osrelease); + auto contents = in.readAll(); + if( + contents.contains("WSL", Qt::CaseInsensitive) || + contents.contains("Microsoft", Qt::CaseInsensitive) + ) { + showFatalErrorMessage( + "Unsupported system detected!", + "Linux-on-Windows distributions are not supported.\n\n" + "Please use the Windows MultiMC binary when playing on Windows." + ); + return; + } + } + } +#endif + + // Don't quit on hiding the last window + this->setQuitOnLastWindowClosed(false); + + // Commandline parsing + QHash args; + { + Parser parser(FlagStyle::GNU, ArgumentStyle::SpaceAndEquals); + + // --help + parser.addSwitch("help"); + parser.addShortOpt("help", 'h'); + parser.addDocumentation("help", "Display this help and exit."); + // --version + parser.addSwitch("version"); + parser.addShortOpt("version", 'V'); + parser.addDocumentation("version", "Display program version and exit."); + // --dir + parser.addOption("dir"); + parser.addShortOpt("dir", 'd'); + parser.addDocumentation("dir", "Use the supplied folder as MultiMC root instead of " + "the binary location (use '.' for current)"); + // --launch + parser.addOption("launch"); + parser.addShortOpt("launch", 'l'); + parser.addDocumentation("launch", "Launch the specified instance (by instance ID)"); + // --server + parser.addOption("server"); + parser.addShortOpt("server", 's'); + parser.addDocumentation("server", "Join the specified server on launch " + "(only valid in combination with --launch)"); + // --alive + parser.addSwitch("alive"); + parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after MultiMC starts"); + // --import + parser.addOption("import"); + parser.addShortOpt("import", 'I'); + parser.addDocumentation("import", "Import instance from specified zip (local path or URL)"); + + // parse the arguments + try + { + args = parser.parse(arguments()); + } + catch (const ParsingError &e) + { + std::cerr << "CommandLineError: " << e.what() << std::endl; + if(argc > 0) + std::cerr << "Try '" << argv[0] << " -h' to get help on MultiMC's command line parameters." + << std::endl; + m_status = Launcher::Failed; + return; + } + + // display help and exit + if (args["help"].toBool()) + { + std::cout << qPrintable(parser.compileHelp(arguments()[0])); + m_status = Launcher::Succeeded; + return; + } + + // display version and exit + if (args["version"].toBool()) + { + std::cout << "Version " << BuildConfig.printableVersionString().toStdString() << std::endl; + std::cout << "Git " << BuildConfig.GIT_COMMIT.toStdString() << std::endl; + m_status = Launcher::Succeeded; + return; + } + } + m_instanceIdToLaunch = args["launch"].toString(); + m_serverToJoin = args["server"].toString(); + m_liveCheck = args["alive"].toBool(); + m_zipToImport = args["import"].toUrl(); + + QString origcwdPath = QDir::currentPath(); + QString binPath = applicationDirPath(); + QString adjustedBy; + QString dataPath; + // change folder + QString dirParam = args["dir"].toString(); + if (!dirParam.isEmpty()) + { + // the dir param. it makes multimc data path point to whatever the user specified + // on command line + adjustedBy += "Command line " + dirParam; + dataPath = dirParam; + } + else + { +#ifdef MULTIMC_LINUX_DATADIR + QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + dataPath = xdgDataHome + "/multimc"; + adjustedBy += "XDG standard " + dataPath; +#elif defined(Q_OS_MAC) + QDir foo(FS::PathCombine(applicationDirPath(), "../../Data")); + dataPath = foo.absolutePath(); + adjustedBy += "Fallback to special Mac location " + dataPath; +#else + dataPath = applicationDirPath(); + adjustedBy += "Fallback to binary path " + dataPath; +#endif + } + + if (!FS::ensureFolderPathExists(dataPath)) + { + showFatalErrorMessage( + "MultiMC data folder could not be created.", + "MultiMC data folder could not be created.\n" + "\n" +#if defined(Q_OS_MAC) + MACOS_HINT +#endif + "Make sure you have the right permissions to the MultiMC data folder and any folder needed to access it.\n" + "\n" + "MultiMC cannot continue until you fix this problem." + ); + return; + } + if (!QDir::setCurrent(dataPath)) + { + showFatalErrorMessage( + "MultiMC data folder could not be opened.", + "MultiMC data folder could not be opened.\n" + "\n" +#if defined(Q_OS_MAC) + MACOS_HINT +#endif + "Make sure you have the right permissions to the MultiMC data folder.\n" + "\n" + "MultiMC cannot continue until you fix this problem." + ); + return; + } + + if(m_instanceIdToLaunch.isEmpty() && !m_serverToJoin.isEmpty()) + { + std::cerr << "--server can only be used in combination with --launch!" << std::endl; + m_status = Launcher::Failed; + return; + } + +#if defined(Q_OS_MAC) + // move user data to new location if on macOS and it still exists in Contents/MacOS + QDir fi(applicationDirPath()); + QString originalData = fi.absolutePath(); + // if the config file exists in Contents/MacOS, then user data is still there and needs to moved + if (QFileInfo::exists(FS::PathCombine(originalData, "multimc.cfg"))) + { + if (!QFileInfo::exists(FS::PathCombine(originalData, "dontmovemacdata"))) + { + QMessageBox::StandardButton askMoveDialogue; + askMoveDialogue = QMessageBox::question(nullptr, "MultiMC 5", "Would you like to move application data to a new data location? It will improve MultiMC's performance, but if you switch to older versions it will look like instances have disappeared. If you select no, you can migrate later in settings. You should select yes unless you're commonly switching between different versions of MultiMC (eg. develop and stable).", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (askMoveDialogue == QMessageBox::Yes) + { + qDebug() << "On macOS and found config file in old location, moving user data..."; + QDir dir; + QStringList dataFiles { + "*.log", // MultiMC-@.log + "accounts.json", + "accounts", + "assets", + "cache", + "icons", + "instances", + "libraries", + "meta", + "metacache", + "mods", + "multimc.cfg", + "themes", + "translations" + }; + QDirIterator files(originalData, dataFiles); + while (files.hasNext()) { + QString filePath(files.next()); + QString fileName(files.fileName()); + if (!dir.rename(filePath, FS::PathCombine(dataPath, fileName))) + { + qWarning() << "Failed to move " << fileName; + } + } + } + else + { + dataPath = originalData; + QDir::setCurrent(dataPath); + QFile file(originalData + "/dontmovemacdata"); + file.open(QIODevice::WriteOnly); + } + } + else + { + dataPath = originalData; + QDir::setCurrent(dataPath); + } + } +#endif + + /* + * Establish the mechanism for communication with an already running MultiMC that uses the same data path. + * If there is one, tell it what the user actually wanted to do and exit. + * We want to initialize this before logging to avoid messing with the log of a potential already running copy. + */ + auto appID = ApplicationId::fromPathAndVersion(QDir::currentPath(), BuildConfig.printableVersionString()); + { + // FIXME: you can run the same binaries with multiple data dirs and they won't clash. This could cause issues for updates. + m_peerInstance = new LocalPeer(this, appID); + connect(m_peerInstance, &LocalPeer::messageReceived, this, &Launcher::messageReceived); + if(m_peerInstance->isClient()) + { + int timeout = 2000; + + if(m_instanceIdToLaunch.isEmpty()) + { + m_peerInstance->sendMessage("activate", timeout); + + if(!m_zipToImport.isEmpty()) + { + m_peerInstance->sendMessage("import " + m_zipToImport.toString(), timeout); + } + } + else + { + if(!m_serverToJoin.isEmpty()) + { + m_peerInstance->sendMessage( + "launch-with-server " + m_instanceIdToLaunch + " " + m_serverToJoin, timeout); + } + else + { + m_peerInstance->sendMessage("launch " + m_instanceIdToLaunch, timeout); + } + } + m_status = Launcher::Succeeded; + return; + } + } + + // init the logger + { + static const QString logBase = "MultiMC-%0.log"; + auto moveFile = [](const QString &oldName, const QString &newName) + { + QFile::remove(newName); + QFile::copy(oldName, newName); + QFile::remove(oldName); + }; + + moveFile(logBase.arg(3), logBase.arg(4)); + moveFile(logBase.arg(2), logBase.arg(3)); + moveFile(logBase.arg(1), logBase.arg(2)); + moveFile(logBase.arg(0), logBase.arg(1)); + + logFile = std::unique_ptr(new QFile(logBase.arg(0))); + if(!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) + { + showFatalErrorMessage( + "MultiMC data folder is not writable!", + "MultiMC couldn't create a log file - the MultiMC data folder is not writable.\n" + "\n" + #if defined(Q_OS_MAC) + MACOS_HINT + #endif + "Make sure you have write permissions to the MultiMC data folder.\n" + "\n" + "MultiMC cannot continue until you fix this problem." + ); + return; + } + qInstallMessageHandler(appDebugOutput); + qDebug() << "<> Log initialized."; + } + + // Set up paths + { + // Root path is used for updates. +#ifdef Q_OS_LINUX + QDir foo(FS::PathCombine(binPath, "..")); + m_rootPath = foo.absolutePath(); +#elif defined(Q_OS_WIN32) + m_rootPath = binPath; +#elif defined(Q_OS_MAC) + QDir foo(FS::PathCombine(binPath, "../..")); + m_rootPath = foo.absolutePath(); + // on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues) + FS::updateTimestamp(m_rootPath); +#endif + +#ifdef MULTIMC_JARS_LOCATION + ENV.setJarsPath( TOSTRING(MULTIMC_JARS_LOCATION) ); +#endif + + qDebug() << "MultiMC 5, (c) 2013-2021 MultiMC Contributors"; + qDebug() << "Version : " << BuildConfig.printableVersionString(); + qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT; + qDebug() << "Git refspec : " << BuildConfig.GIT_REFSPEC; + if (adjustedBy.size()) + { + qDebug() << "Work dir before adjustment : " << origcwdPath; + qDebug() << "Work dir after adjustment : " << QDir::currentPath(); + qDebug() << "Adjusted by : " << adjustedBy; + } + else + { + qDebug() << "Work dir : " << QDir::currentPath(); + } + qDebug() << "Binary path : " << binPath; + qDebug() << "Application root path : " << m_rootPath; + if(!m_instanceIdToLaunch.isEmpty()) + { + qDebug() << "ID of instance to launch : " << m_instanceIdToLaunch; + } + if(!m_serverToJoin.isEmpty()) + { + qDebug() << "Address of server to join :" << m_serverToJoin; + } + qDebug() << "<> Paths set."; + } + + do // once + { + if(m_liveCheck) + { + QFile check(liveCheckFile); + if(!check.open(QIODevice::W