diff options
20 files changed, 292 insertions, 317 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6d1189b..0590b348 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,9 @@ jobs: - os: ubuntu-20.04 + - os: ubuntu-20.04 + appimage: true + - os: windows-2022 name: "Windows-i686" msystem: mingw32 @@ -59,6 +62,32 @@ jobs: cmake:p ninja:p qt5:p + ccache:p + + - name: Setup ccache + if: runner.os != 'Windows' && inputs.build_type == 'Debug' + uses: hendrikmuhs/ccache-action@v1.2.1 + with: + key: ${{ matrix.os }}-${{ matrix.appimage }} + + - name: Setup ccache (Windows) + if: runner.os == 'Windows' && inputs.build_type == 'Debug' + shell: msys2 {0} + run: | + ccache --set-config=cache_dir='${{ github.workspace }}\.ccache' + ccache --set-config=max_size='500M' + ccache --set-config=compression=true + ccache -p # Show config + ccache -z # Zero stats + + - name: Retrieve ccache cache (Windows) + if: runner.os == 'Windows' && inputs.build_type == 'Debug' + uses: actions/cache@v3.0.2 + with: + path: '${{ github.workspace }}\.ccache' + key: ${{ matrix.os }}-${{ matrix.msystem }} + restore-keys: | + ${{ matrix.os }}-${{ matrix.msystem }} - name: Set short version shell: bash @@ -66,30 +95,25 @@ jobs: ver_short=`git rev-parse --short HEAD` echo "VERSION=$ver_short" >> $GITHUB_ENV - - name: Install OpenJDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - name: Install Qt (macOS) if: runner.os == 'macOS' run: | brew update - brew install qt@5 + brew install qt@5 ninja + + - name: Update Qt (AppImage) + if: runner.os == 'Linux' && matrix.appimage == true + run: | + sudo add-apt-repository ppa:savoury1/qt-5-15 - name: Install Qt (Linux) if: runner.os == 'Linux' run: | sudo apt-get -y update - sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 - - - name: Install Ninja - if: runner.os != 'Windows' - uses: urkle/action-get-ninja@v1 + sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 ninja-build - name: Prepare AppImage (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage == true run: | wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage" @@ -104,18 +128,18 @@ jobs: - name: Configure CMake (macOS) if: runner.os == 'macOS' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DQt5_DIR=/usr/local/opt/qt@5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -DLauncher_BUILD_PLATFORM=macOS -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DQt5_DIR=/usr/local/opt/qt@5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -DLauncher_BUILD_PLATFORM=macOS -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja - name: Configure CMake (Windows) if: runner.os == 'Windows' shell: msys2 {0} run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja - name: Configure CMake (Linux) if: runner.os == 'Linux' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=Linux -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=Linux -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja ## # BUILD @@ -167,7 +191,7 @@ jobs: cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable - name: Package (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage != true run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }} @@ -175,7 +199,7 @@ jobs: tar --owner root --group root -czf ../PolyMC.tar.gz * - name: Package (Linux, portable) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage != true run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable @@ -184,7 +208,7 @@ jobs: tar -czf ../PolyMC-portable.tar.gz * - name: Package AppImage (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage == true shell: bash run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr @@ -234,21 +258,21 @@ jobs: path: ${{ env.INSTALL_PORTABLE_DIR }}/** - name: Upload binary tarball (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage != true uses: actions/upload-artifact@v3 with: name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }} path: PolyMC.tar.gz - name: Upload binary tarball (Linux, portable) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage != true uses: actions/upload-artifact@v3 with: name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }} path: PolyMC-portable.tar.gz - name: Upload AppImage (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.appimage == true uses: actions/upload-artifact@v3 with: name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 7e8e4d99..f0f5b8cc 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -1,7 +1,7 @@ name: Comment on pull request on: workflow_run: - workflows: ['Test workflow with upload'] + workflows: ['Build Application'] types: [completed] jobs: pr_comment: diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 8bd434f0..11109857 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -409,69 +409,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) 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, BuildConfig.LAUNCHER_CONFIGFILE))) - { - if (!QFileInfo::exists(FS::PathCombine(originalData, "dontmovemacdata"))) - { - QMessageBox::StandardButton askMoveDialogue; - askMoveDialogue = QMessageBox::question( - nullptr, - BuildConfig.LAUNCHER_DISPLAYNAME, - "Would you like to move application data to a new data location? It will improve the launcher'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 (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", // Launcher log files: ${Launcher_Name}-@.log - "accounts.json", - "accounts", - "assets", - "cache", - "icons", - "instances", - "libraries", - "meta", - "metacache", - "mods", - BuildConfig.LAUNCHER_CONFIGFILE, - "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 PolyMC that uses the same data path. * If there is one, tell it what the user actually wanted to do and exit. @@ -691,6 +628,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("LastHostname", ""); m_settings->registerSetting("JvmArgs", ""); m_settings->registerSetting("IgnoreJavaCompatibility", false); + m_settings->registerSetting("IgnoreJavaWizard", false); // Native library workarounds m_settings->registerSetting("UseNativeOpenAL", false); @@ -936,6 +874,10 @@ bool Application::createSetupWizard() { bool javaRequired = [&]() { + bool ignoreJavaWizard = m_settings->get("IgnoreJavaWizard").toBool(); + if(ignoreJavaWizard) { + return false; + } QString currentHostName = QHostInfo::localHostName(); QString oldHostName = settings()->get("LastHostname").toString(); if (currentHostName != oldHostName) @@ -966,6 +908,7 @@ bool Application::createSetupWizard() { m_setupWizard->addPage(new LanguageWizardPage(m_setupWizard)); } + if (javaRequired) { m_setupWizard->addPage(new JavaWizardPage(m_setupWizard)); diff --git a/launcher/minecraft/auth/steps/LauncherLoginStep.cpp b/launcher/minecraft/auth/steps/LauncherLoginStep.cpp index c978bd07..f5697223 100644 --- a/launcher/minecraft/auth/steps/LauncherLoginStep.cpp +++ b/launcher/minecraft/auth/steps/LauncherLoginStep.cpp @@ -50,7 +50,9 @@ void LauncherLoginStep::onRequestDone( auto requestor = qobject_cast<AuthRequest *>(QObject::sender()); requestor->deleteLater(); +#ifndef NDEBUG qDebug() << data; +#endif if (error != QNetworkReply::NoError) { qWarning() << "Reply error:" << error; #ifndef NDEBUG diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index d31885b9..0fe673ff 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -313,5 +313,6 @@ <file>scalable/instances/fox.svg</file> <file>scalable/instances/bee.svg</file> + <file>scalable/instances/polymc.svg</file> </qresource> </RCC> diff --git a/launcher/resources/multimc/scalable/instances/polymc.svg b/launcher/resources/multimc/scalable/instances/polymc.svg new file mode 100644 index 00000000..c192d503 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/polymc.svg @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg width="64" height="64" version="1.1" viewBox="0 0 16.933 16.933" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <defs> + <linearGradient id="linearGradient84726" x1="4.4979" x2="12.435" y1="3.8011" y2="9.5681" gradientUnits="userSpaceOnUse"> + <stop stop-color="#88b858" offset="0"/> + <stop stop-color="#72b147" offset=".5"/> + <stop stop-color="#5a9a30" offset="1"/> + </linearGradient> + </defs> + <g> + <path d="m3.561 16.016s0-3.5642 4.9056-3.5642c4.9069 0 4.9056 3.5642 4.9056 3.5642z" fill="#765338"/> + <path d="m8.4667 12.452-4.9056 3.5642-3.0319-9.3311z" fill="#b7835a"/> + <path d="m8.4667 12.452 7.9375-5.7669-3.0319 9.3311z" fill="#5b422d"/> + <path d="m8.8308 12.716-0.36417 0.26458-0.36417-0.26458c0-0.26458 0.36417-0.26458 0.36417-0.26458s0.36417 0 0.36417 0.26458z" fill="#72b147"/> + <path d="m8.4667 12.452s-2e-7 -5.7669 7.9375-5.7669l-0.22507 0.69269-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819z" fill="#5a9a30"/> + <path d="m8.1025 12.716-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.22507-0.69269c7.9375 1e-7 7.9375 5.7669 7.9375 5.7669z" fill="#88b858"/> + <path d="m0.52917 6.6846 7.9375 5.7669 7.9375-5.7669-7.9375-5.7669z" fill="url(#linearGradient84726)"/> + </g> + <path d="m0.75424 7.3773-0.22507-0.69269 7.9375 5.7669 7.9375-5.7669-0.22507 0.69269-7.7124 5.6034z" fill-opacity="0"/> +</svg> diff --git a/launcher/ui/pages/global/ExternalToolsPage.ui b/launcher/ui/pages/global/ExternalToolsPage.ui index 8609d469..3643094d 100644 --- a/launcher/ui/pages/global/ExternalToolsPage.ui +++ b/launcher/ui/pages/global/ExternalToolsPage.ui @@ -158,6 +158,9 @@ <property name="text"> <string>&Text Editor:</string> </property> + <property name="buddy"> + <cstring>jsonEditorTextBox</cstring> + </property> </widget> </item> <item row="0" column="2"> diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp index f0616db1..b5e8de6c 100644 --- a/launcher/ui/pages/global/JavaPage.cpp +++ b/launcher/ui/pages/global/JavaPage.cpp @@ -97,6 +97,7 @@ void JavaPage::applySettings() s->set("JavaPath", ui->javaPathTextBox->text()); s->set("JvmArgs", ui->jvmArgsTextBox->text()); s->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked()); + s->set("IgnoreJavaWizard", ui->skipJavaWizardCheckbox->isChecked()); JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget()); } void JavaPage::loadSettings() @@ -121,6 +122,7 @@ void JavaPage::loadSettings() ui->javaPathTextBox->setText(s->get("JavaPath").toString()); ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString()); ui->skipCompatibilityCheckbox->setChecked(s->get("IgnoreJavaCompatibility").toBool()); + ui->skipJavaWizardCheckbox->setChecked(s->get("IgnoreJavaWizard").toBool()); } void JavaPage::on_javaDetectBtn_clicked() diff --git a/launcher/ui/pages/global/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui index bb195770..3e4b12a1 100644 --- a/launcher/ui/pages/global/JavaPage.ui +++ b/launcher/ui/pages/global/JavaPage.ui @@ -72,6 +72,9 @@ <property name="text"> <string>&Minimum memory allocation:</string> </property> + <property name="buddy"> + <cstring>minMemSpinBox</cstring> + </property> </widget> </item> <item row="1" column="0"> @@ -79,6 +82,9 @@ <property name="text"> <string>Ma&ximum memory allocation:</string> </property> + <property name="buddy"> + <cstring>maxMemSpinBox</cstring> + </property> </widget> </item> <item row="0" column="1"> @@ -108,6 +114,9 @@ <property name="text"> <string notr="true">&PermGen:</string> </property> + <property name="buddy"> + <cstring>permGenSpinBox</cstring> + </property> </widget> </item> <item row="2" column="1"> @@ -152,37 +161,11 @@ <property name="text"> <string>&Java path:</string> </property> + <property name="buddy"> + <cstring>javaPathTextBox</cstring> + </property> </widget> </item> - <item row="0" column="1" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLineEdit" name="javaPathTextBox"/> - </item> - <item> - <widget class="QPushButton" name="javaBrowseBtn"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>28</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="1" colspan="2"> - <widget class="QLineEdit" name="jvmArgsTextBox"/> - </item> <item row="2" column="0"> <widget class="QLabel" name="labelJVMArgs"> <property name="sizePolicy"> @@ -194,23 +177,29 @@ <property name="text"> <string>J&VM arguments:</string> </property> + <property name="buddy"> + <cstring>jvmArgsTextBox</cstring> + </property> </widget> </item> - <item row="3" column="1"> - <widget class="QPushButton" name="javaDetectBtn"> + <item row="4" column="1"> + <widget class="QCheckBox" name="skipCompatibilityCheckbox"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string> + </property> <property name="text"> - <string>&Auto-detect...</string> + <string>&Skip Java compatibility checks</string> </property> </widget> </item> - <item row="3" column="2"> - <widget class="QPushButton" name="javaTestBtn"> + <item row="3" column="1"> + <widget class="QPushButton" name="javaDetectBtn"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -218,23 +207,59 @@ </sizepolicy> </property> <property name="text"> - <string>&Test</string> + <string>&Auto-detect...</string> </property> </widget> </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="skipCompatibilityCheckbox"> + <item row="0" column="1" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="javaPathTextBox"/> + </item> + <item> + <widget class="QPushButton" name="javaBrowseBtn"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>28</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string notr="true">...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="javaTestBtn"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="text"> + <string>&Test</string> + </property> + </widget> + </item> + <item row="2" column="1" colspan="2"> + <widget class="QLineEdit" name="jvmArgsTextBox"/> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="skipJavaWizardCheckbox"> <property name="toolTip"> - <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string> + <string>If enabled, the launcher will not prompt you to choose a Java version if one isn't found.</string> </property> <property name="text"> - <string>&Skip Java compatibility checks</string> + <string>Skip Java &Wizard</string> </property> </widget> </item> diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 097a2bfa..af2e2cd1 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -97,13 +97,6 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch } connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview())); connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview())); - - //move mac data button - QFile file(QDir::current().absolutePath() + "/dontmovemacdata"); - if (!file.exists()) - { - ui->migrateDataFolderMacBtn->setVisible(false); - } } LauncherPage::~LauncherPage() @@ -190,13 +183,6 @@ void LauncherPage::on_modsDirBrowseBtn_clicked() ui->modsDirTextBox->setText(cooked_dir); } } -void LauncherPage::on_migrateDataFolderMacBtn_clicked() -{ - QFile file(QDir::current().absolutePath() + "/dontmovemacdata"); - file.remove(); - QProcess::startDetached(qApp->arguments()[0]); - qApp->quit(); -} void LauncherPage::refreshUpdateChannelList() { diff --git a/launcher/ui/pages/global/LauncherPage.h b/launcher/ui/pages/global/LauncherPage.h index 63cfe9c3..bbf5d2fe 100644 --- a/launcher/ui/pages/global/LauncherPage.h +++ b/launcher/ui/pages/global/LauncherPage.h @@ -88,7 +88,6 @@ slots: void on_instDirBrowseBtn_clicked(); void on_modsDirBrowseBtn_clicked(); void on_iconsDirBrowseBtn_clicked(); - void on_migrateDataFolderMacBtn_clicked(); /*! * Updates the list of update channels in the combo box. diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 086de17b..ae7eb73f 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -158,13 +158,6 @@ </widget> </item> <item> - <widget class="QPushButton" name="migrateDataFolderMacBtn"> - <property name="text"> - <string>Move the data to new location (will restart the launcher)</string> - </property> - </widget> - </item> - <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> diff --git a/launcher/ui/pages/global/ProxyPage.ui b/launcher/ui/pages/global/ProxyPage.ui index 5a2fc73d..91ba46b3 100644 --- a/launcher/ui/pages/global/ProxyPage.ui +++ b/launcher/ui/pages/global/ProxyPage.ui @@ -147,6 +147,9 @@ <property name="text"> <string>&Username:</string> </property> + <property name="buddy"> + <cstring>proxyUserEdit</cstring> + </property> </widget> </item> <item row="1" column="0"> @@ -154,6 +157,9 @@ <property name="text"> <string>&Password:</string> </property> + <property name="buddy"> + <cstring>proxyPassEdit</cstring> + </property> </widget> </item> <item row="1" column="1"> diff --git a/launcher/ui/widgets/CustomCommands.ui b/launcher/ui/widgets/CustomCommands.ui index 68e680a5..4a39ff7f 100644 --- a/launcher/ui/widgets/CustomCommands.ui +++ b/launcher/ui/widgets/CustomCommands.ui @@ -43,6 +43,9 @@ <property name="text"> <string>P&ost-exit command:</string> </property> + <property name="buddy"> + <cstring>postExitCmdTextBox</cstring> + </property> </widget> </item> <item row="0" column="1"> @@ -53,6 +56,9 @@ <property name="text"> <string>&Pre-launch command:</string> </property> + <property name="buddy"> + <cstring>preLaunchCmdTextBox</cstring> + </property> </widget> </item> <item row="2" column="1"> @@ -63,6 +69,9 @@ <property name="text"> <string>&Wrapper command:</string> </property> + <property name="buddy"> + <cstring>wrapperCmdTextBox</cstring> + </property> </widget> </item> <item row="1" column="1"> diff --git a/libraries/iconfix/CMakeLists.txt b/libraries/iconfix/CMakeLists.txt index 08441203..97a59129 100644 --- a/libraries/iconfix/CMakeLists.txt +++ b/libraries/iconfix/CMakeLists.txt @@ -12,7 +12,7 @@ internal/qiconloader.cpp internal/qiconloader_p.h ) -add_library(Launcher_iconfix ${ICONFIX_SOURCES}) +add_library(Launcher_iconfix STATIC ${ICONFIX_SOURCES}) target_include_directories(Launcher_iconfix PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}" ) target_link_libraries(Launcher_iconfix Qt5::Core Qt5::Widgets) diff --git a/libraries/launcher/org/multimc/EntryPoint.java b/libraries/launcher/org/multimc/EntryPoint.java index 0f904f5f..b626d095 100644 --- a/libraries/launcher/org/multimc/EntryPoint.java +++ b/libraries/launcher/org/multimc/EntryPoint.java @@ -16,136 +16,123 @@ package org.multimc;/* import org.multimc.onesix.OneSixLauncher; -import java.io.*; -import java.nio.charset.Charset; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.logging.Level; +import java.util.logging.Logger; public class EntryPoint { - private enum Action - { - Proceed, - Launch, - Abort - } + + private static final Logger LOGGER = Logger.getLogger("EntryPoint"); + + private final ParamBucket params = new ParamBucket(); + + private org.multimc.Launcher launcher; public static void main(String[] args) { EntryPoint listener = new EntryPoint(); + int retCode = listener.listen(); + if (retCode != 0) { - System.out.println("Exiting with " + retCode); + LOGGER.info("Exiting with " + retCode); + System.exit(retCode); } } private Action parseLine(String inData) throws ParseException { - String[] pair = inData.split(" ", 2); + String[] tokens = inData.split("\\s+", 2); - if(pair.length == 1) - { - String command = pair[0]; - if (pair[0].equals("launch")) + if (tokens.length == 0) + throw new ParseException("Unexpected empty string!"); + + switch (tokens[0]) { + case "launch": { return Action.Launch; + } - else if (pair[0].equals("abort")) + case "abort": { return Action.Abort; + } - else throw new ParseException("Error while parsing:" + pair[0]); - } + case "launcher": { + if (tokens.length != 2) + throw new ParseException("Expected 2 tokens, got " + tokens.length); - if(pair.length != 2) - throw new ParseException("Pair length is not 2."); + if (tokens[1].equals("onesix")) { + launcher = new OneSixLauncher(); - String command = pair[0]; - String param = pair[1]; + LOGGER.info("Using onesix launcher."); + + return Action.Proceed; + } else { + throw new ParseException("Invalid launcher type: " + tokens[1]); + } + } + + default: { + if (tokens.length != 2) + throw new ParseException("Error while parsing:" + inData); + + params.add(tokens[0], tokens[1]); - if(command.equals("launcher")) - { - if(param.equals("onesix")) - { - m_launcher = new OneSixLauncher(); - Utils.log("Using onesix launcher."); - Utils.log(); return Action.Proceed; } - else - throw new ParseException("Invalid launcher type: " + param); } - - m_params.add(command, param); - //System.out.println(command + " : " + param); - return Action.Proceed; } public int listen() { - BufferedReader buffer; - try - { - buffer = new BufferedReader(new InputStreamReader(System.in, "UTF-8")); - } catch (UnsupportedEncodingException e) - { - System.err.println("For some reason, your java does not support UTF-8. Consider living in the current century."); - e.printStackTrace(); - return 1; - } - boolean isListening = true; - boolean isAborted = false; - // Main loop - while (isListening) - { - String inData; - try - { - // Read from the pipe one line at a time - inData = buffer.readLine(); - if (inData != null) - { - Action a = parseLine(inData); - if(a == Action.Abort) - { - isListening = false; - isAborted = true; - } - if(a == Action.Launch) - { - isListening = false; - } - } - else - { - isListening = false; - isAborted = true; + Action action = Action.Proceed; + + try (BufferedReader reader = new BufferedReader(new InputStreamReader( + System.in, + StandardCharsets.UTF_8 + ))) { + String line; + + while (action == Action.Proceed) { + if ((line = reader.readLine()) != null) { + action = parseLine(line); + } else { + action = Action.Abort; } } - catch (IOException e) - { - System.err.println("Launcher ABORT due to IO exception:"); - e.printStackTrace(); - return 1; - } - catch (ParseException e) - { - System.err.println("Launcher ABORT due to PARSE exception:"); - e.printStackTrace(); - return 1; - } + } catch (IOException | ParseException e) { + LOGGER.log(Level.SEVERE, "Launcher ABORT due to exception:", e); + + return 1; } - if(isAborted) + + // Main loop + if (action == Action.Abort) { - System.err.println("Launch aborted by the launcher."); + LOGGER.info("Launch aborted by the launcher."); + return 1; } - if(m_launcher != null) + + if (launcher != null) { - return m_launcher.launch(m_params); + return launcher.launch(params); } - System.err.println("No valid launcher implementation specified."); + + LOGGER.log(Level.SEVERE, "No valid launcher implementation specified."); + return 1; } - private ParamBucket m_params = new ParamBucket(); - private org.multimc.Launcher m_launcher; + private enum Action { + Proceed, + Launch, + Abort + } + } diff --git a/libraries/launcher/org/multimc/Launcher.java b/libraries/launcher/org/multimc/Launcher.java index d8cb6d1b..c5e8fbc1 100644 --- a/libraries/launcher/org/multimc/Launcher.java +++ b/libraries/launcher/org/multimc/Launcher.java @@ -18,5 +18,5 @@ package org.multimc; public interface Launcher { - abstract int launch(ParamBucket params); + int launch(ParamBucket params); } diff --git a/libraries/launcher/org/multimc/ParamBucket.java b/libraries/launcher/org/multimc/ParamBucket.java index 2fde1329..8ff03ddc 100644 --- a/libraries/launcher/org/multimc/ParamBucket.java +++ b/libraries/launcher/org/multimc/ParamBucket.java @@ -19,62 +19,62 @@ package org.multimc; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; public class ParamBucket { + + private final Map<String, List<String>> paramsMap = new HashMap<>(); + public void add(String key, String value) { - List<String> coll = null; - if(!m_params.containsKey(key)) - { - coll = new ArrayList<String>(); - m_params.put(key, coll); - } - else - { - coll = m_params.get(key); - } - coll.add(value); + paramsMap.computeIfAbsent(key, k -> new ArrayList<>()) + .add(value); } public List<String> all(String key) throws NotFoundException { - if(!m_params.containsKey(key)) + List<String> params = paramsMap.get(key); + + if (params == null) throw new NotFoundException(); - return m_params.get(key); + + return params; } public List<String> allSafe(String key, List<String> def) { - if(!m_params.containsKey(key) || m_params.get(key).size() < 1) - { + List<String> params = paramsMap.get(key); + + if (params == null || params.isEmpty()) return def; - } - return m_params.get(key); + + return params; } public List<String> allSafe(String key) { - return allSafe(key, new ArrayList<String>()); + return allSafe(key, new ArrayList<>()); } public String first(String key) throws NotFoundException { List<String> list = all(key); - if(list.size() < 1) - { + + if (list.isEmpty()) throw new NotFoundException(); - } + return list.get(0); } public String firstSafe(String key, String def) { - if(!m_params.containsKey(key) || m_params.get(key).size() < 1) - { + List<String> params = paramsMap.get(key); + + if (params == null || params.isEmpty()) return def; - } - return m_params.get(key).get(0); + + return params.get(0); } public String firstSafe(String key) @@ -82,5 +82,4 @@ public class ParamBucket return firstSafe(key, ""); } - private HashMap<String, List<String>> m_params = new HashMap<String, List<String>>(); } diff --git a/libraries/launcher/org/multimc/Utils.java b/libraries/launcher/org/multimc/Utils.java index 353af7d3..e48029c2 100644 --- a/libraries/launcher/org/multimc/Utils.java +++ b/libraries/launcher/org/multimc/Utils.java @@ -16,21 +16,10 @@ package org.multimc; -import java.io.*; import java.io.File; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.Arrays; -import java.util.Enumeration; import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; public class Utils { @@ -93,27 +82,5 @@ public class Utils return null; } - /** - * Log to the launcher console - * - * @param message A String containing the message - * @param level A String containing the level name. See MinecraftLauncher::getLevel() - */ - public static void log(String message, String level) - { - // Kinda dirty - String tag = "!![" + level + "]!"; - System.out.println(tag + message.replace("\n", "\n" + tag)); - } - - public static void log(String message) - { - log(message, "Launcher"); - } - - public static void log() - { - System.out.println(); - } } diff --git a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java index ea445995..0058bd43 100644 --- a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java +++ b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java @@ -19,14 +19,18 @@ import org.multimc.*; import java.applet.Applet; import java.io.File; -import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; public class OneSixLauncher implements Launcher { + + private static final Logger LOGGER = Logger.getLogger("OneSixLauncher"); + // parameters, separated from ParamBucket private List<String> libraries; private List<String> mcparams; @@ -104,7 +108,7 @@ public class OneSixLauncher implements Launcher if (f == null) { - System.err.println("Could not find Minecraft path field."); + LOGGER.warning("Could not find Minecraft path field."); } else { @@ -113,8 +117,12 @@ public class OneSixLauncher implements Launcher } } catch (Exception e) { - System.err.println("Could not set base folder. Failed to find/access Minecraft main class:"); - e.printStackTrace(System.err); + LOGGER.log( + Level.SEVERE, + "Could not set base folder. Failed to find/access Minecraft main class:", + e + ); + return -1; } @@ -122,7 +130,7 @@ public class OneSixLauncher implements Launcher if(!traits.contains("noapplet")) { - Utils.log("Launching with applet wrapper..."); + LOGGER.info("Launching with applet wrapper..."); try { Class<?> MCAppletClass = cl.loadClass(appletClass); @@ -132,10 +140,9 @@ public class OneSixLauncher implements Launcher return 0; } catch (Exception e) { - Utils.log("Applet wrapper failed:", "Error"); - e.printStackTrace(System.err); - Utils.log(); - Utils.log("Falling back to using main class."); + LOGGER.log(Level.SEVERE, "Applet wrapper failed:", e); + + LOGGER.warning("Falling back to using main class."); } } @@ -147,8 +154,8 @@ public class OneSixLauncher implements Launcher return 0; } catch (Exception e) { - Utils.log("Failed to invoke the Minecraft main class:", "Fatal"); - e.printStackTrace(System.err); + LOGGER.log(Level.SEVERE, "Failed to invoke the Minecraft main class:", e); + return -1; } } @@ -185,8 +192,8 @@ public class OneSixLauncher implements Launcher mc = cl.loadClass(mainClass); } catch (ClassNotFoundException e) { - System.err.println("Failed to find Minecraft main class:"); - e.printStackTrace(System.err); + LOGGER.log(Level.SEVERE, "Failed to find Minecraft main class:", e); + return -1; } @@ -197,8 +204,8 @@ public class OneSixLauncher implements Launcher meth = mc.getMethod("main", String[].class); } catch (NoSuchMethodException e) { - System.err.println("Failed to acquire the main method:"); - e.printStackTrace(System.err); + LOGGER.log(Level.SEVERE, "Failed to acquire the main method:", e); + return -1; } @@ -210,8 +217,8 @@ public class OneSixLauncher implements Launcher meth.invoke(null, (Object) paramsArray); } catch (Exception e) { - System.err.println("Failed to start Minecraft:"); - e.printStackTrace(System.err); + LOGGER.log(Level.SEVERE, "Failed to start Minecraft:", e); + return -1; } return 0; @@ -226,8 +233,8 @@ public class OneSixLauncher implements Launcher processParams(params); } catch (NotFoundException e) { - System.err.println("Not enough arguments."); - e.printStackTrace(System.err); + LOGGER.log(Level.SEVERE, "Not enough arguments!"); + return -1; } @@ -245,4 +252,5 @@ public class OneSixLauncher implements Launcher return launchWithMainClass(); } } + } |