From 00f4f533aa6f64582f647fe891c761b311fb1ac3 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Tue, 25 Feb 2014 18:46:50 +0100 Subject: Fix to the way translations are handled. Also updated the german translation with the new strings. --- CMakeLists.txt | 20 +- translations/CMakeLists.txt | 20 + translations/mmc_de.ts | 1205 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 1090 insertions(+), 155 deletions(-) create mode 100644 translations/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 54a4be19..f070684d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -758,24 +758,8 @@ INCLUDE(CPack) include_directories(${PROJECT_BINARY_DIR}/include) -### translation stuff - -file (GLOB TRANSLATIONS_FILES translations/*.ts) - -option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)") -IF(UPDATE_TRANSLATIONS) - qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES}) -ELSE() - qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES}) -ENDIF() - -add_custom_target (translations DEPENDS ${QM_FILES}) -IF(APPLE AND UNIX) ## OSX - install(FILES ${QM_FILES} DESTINATION MultiMC.app/Contents/MacOS/translations) -ELSE() - install(FILES ${QM_FILES} DESTINATION translations) -ENDIF() - +# Translations +add_subdirectory(translations) # Tests add_subdirectory(tests) diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt new file mode 100644 index 00000000..7463ae40 --- /dev/null +++ b/translations/CMakeLists.txt @@ -0,0 +1,20 @@ +set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) + +### translation stuff + +file(GLOB TRANSLATION_FILES ${CMAKE_CURRENT_LIST_DIR}/*.ts) +set(FILES_TO_TRANSLATE_ABSOLUTE) +foreach(file ${FILES_TO_TRANSLATE}) + list(APPEND FILES_TO_TRANSLATE_ABSOLUTE "${CMAKE_SOURCE_DIR}/${file}") +endforeach() + +qt5_create_translation(TRANSLATION_MESSAGES ${FILES_TO_TRANSLATE_ABSOLUTE} ${TRANSLATION_FILES}) +qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES}) +add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES}) +add_custom_target(translations DEPENDS ${TRANSLATION_QM}) + +IF(APPLE AND UNIX) ## OSX + install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/MacOS/translations) +ELSE() + install(FILES ${TRANSLATION_QM} DESTINATION translations) +ENDIF() diff --git a/translations/mmc_de.ts b/translations/mmc_de.ts index 67ea67f6..6fb26eb5 100644 --- a/translations/mmc_de.ts +++ b/translations/mmc_de.ts @@ -8,12 +8,11 @@ Dialog - MultiMC - MultiMC + MultiMC - + About Über @@ -27,7 +26,37 @@ Über MultiMC - + + MultiMC 5 + MultiMC 5 + + + + Version: + Version: + + + + Version Type: + + + + + Platform: + + + + + Build Number: + + + + + Channel: + + + + <html><head/><body><p>MultiMC is a custom launcher that makes managing Minecraft easier by allowing you to have multiple instances of Minecraft at once.</p></body></html> <html><head/><body><p>MultiMC ist ein alternativer Launcher, der das Management von Minecraft vereinfacht, indem er es dir erlaubt, mehrere Installationen von Minecraft zu verwalten.</p></body></html> @@ -42,7 +71,197 @@ - + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">MultiMC</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Sky &lt;</span><a href="https://www.twitter.com/drayshak"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">@drayshak</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt; font-weight:600;">With thanks to</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">TakSuyu &lt;</span><a href="mailto:taksuyu@gmail.com"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">taksuyu@gmail.com</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Kilobyte &lt;</span><a href="mailto:stiepen22@gmx.de"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">stiepen22@gmx.de</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Jan (02JanDal) &lt;</span><a href="mailto:02jandal@gmail.com"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">02jandal@gmail.com</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Robotbrain &lt;</span><a href="https://twitter.com/skylordelros"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">@skylordelros</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Rootbear75 &lt;</span><a href="https://twitter.com/rootbear75"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">@rootbear75</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">&gt; (build server)</span></p></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:11pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">MultiMC</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Copyright 2012-2014 MultiMC Contributors</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">you may not use this file except in compliance with the License.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">You may obtain a copy of the License at</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;"> http://www.apache.org/licenses/LICENSE-2.0</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Unless required by applicable law or agreed to in writing, software</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">See the License for the specific language governing permissions and</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">limitations under the License.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">QSLog</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Copyright (c) 2010, Razvan Petru</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">All rights reserved.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Redistribution and use in source and binary forms, with or without modification,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">are permitted provided that the following conditions are met:</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">* Redistributions of source code must retain the above copyright notice, this</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> list of conditions and the following disclaimer.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">* Redistributions in binary form must reproduce the above copyright notice, this</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> list of conditions and the following disclaimer in the documentation and/or other</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> materials provided with the distribution.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">* The name of the contributors may not be used to endorse or promote products</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> derived from this software without specific prior written permission.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">OF THE POSSIBILITY OF SUCH DAMAGE.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">Group View (instance view)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> /*</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Copyright (C) 2007 Rafael Fernández López &lt;ereslibre@kde.org&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Copyright (C) 2007 John Tapsell &lt;tapsell@kde.org&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> *</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * This library is free software; you can redistribute it and/or</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * modify it under the terms of the GNU Library General Public</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * License as published by the Free Software Foundation; either</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * version 2 of the License, or (at your option) any later version.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> *</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * This library is distributed in the hope that it will be useful,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Library General Public License for more details.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> *</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * You should have received a copy of the GNU Library General Public License</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * along with this library; see the file COPYING.LIB. If not, write to</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Boston, MA 02110-1301, USA.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> */</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">Pack200</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The GNU General Public License (GPL)</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Version 2, June 1991</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">+ &quot;CLASSPATH&quot; EXCEPTION TO THE GPL</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Certain source files distributed by Oracle America and/or its affiliates are</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">subject to the following clarification and special exception to the GPL, but</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">only where Oracle has expressly included in the particular source file's header</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">the words &quot;Oracle designates this particular file as subject to the &quot;Classpath&quot;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">exception as provided by Oracle in the LICENSE file that accompanied this code.&quot;</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> Linking this library statically or dynamically with other modules is making</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> a combined work based on this library. Thus, the terms and conditions of</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> the GNU General Public License cover the whole combination.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> As a special exception, the copyright holders of this library give you</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> permission to link this library with independent modules to produce an</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> executable, regardless of the license terms of these independent modules,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> and to copy and distribute the resulting executable under terms of your</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> choice, provided that you also meet, for each linked independent module,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> the terms and conditions of the license of that module. An independent</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> module is a module which is not derived from or based on this library. If</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> you modify this library, you may extend this exception to your version of</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> the library, but you are not obligated to do so. If you do not wish to do</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> so, delete this exception statement from your version.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">Quazip</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Copyright (C) 2005-2011 Sergey A. Tachenov</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This program is free software; you can redistribute it and/or modify it</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">under the terms of the GNU Lesser General Public License as published by</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">the Free Software Foundation; either version 2 of the License, or (at</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">your option) any later version.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This program is distributed in the hope that it will be useful, but</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">WITHOUT ANY WARRANTY; without even the implied warranty of</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">General Public License for more details.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You should have received a copy of the GNU Lesser General Public License</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">along with this program; if not, write to the Free Software Foundation,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">See COPYING file for the full LGPL text.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Original ZIP package is copyrighted by Gilles Vollant, see</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">quazip/(un)zip.h files for details, basically it's zlib license.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">xz-minidec</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">/*</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * XZ decompressor</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> *</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Authors: Lasse Collin &lt;lasse.collin@tukaani.org&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Igor Pavlov &lt;http://7-zip.org/&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> *</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * This file has been put into the public domain.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * You can do whatever you want with this file.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> */</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:18pt; font-weight:600;">Java IconLoader class</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Copyright (c) 2011, Chris Molini</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">All rights reserved.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Redistribution and use in source and binary forms, with or without</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">modification, are permitted provided that the following conditions are met:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Redistributions of source code must retain the above copyright</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> notice, this list of conditions and the following disclaimer.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Redistributions in binary form must reproduce the above copyright</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> notice, this list of conditions and the following disclaimer in the</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> documentation and/or other materials provided with the distribution.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * Neither the name of the &lt;organization&gt; nor the</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> names of its contributors may be used to endorse or promote products</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> derived from this software without specific prior written permission.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">DISCLAIMED. IN NO EVENT SHALL &lt;COPYRIGHT HOLDER&gt; BE LIABLE FOR ANY</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">We keep MultiMC open source because we think it's important to be able to see the source code for a project like this, and we do so using the Apache license.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Part of the reason for using the Apache license is we don't want people using the &quot;MultiMC&quot; name when redistributing the project. This means people must take the time to go through the source code and remove all references to &quot;MultiMC&quot;, including but not limited to the project icon and the title of windows, (no *MultiMC-fork* in the title).</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The Apache license covers reasonable use for the name - a mention of the project's origins in the About dialog and the license is acceptable. However, it should be abundantly clear that the project is a fork <span style=" font-weight:600;">without</span> implying that you have our blessing.</p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -59,7 +278,7 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Jan (02JanDal) &lt;</span><a href="mailto:02jandal@gmail.com"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">02jandal@gmail.com</span></a><span style=" font-size:10pt;">&gt;</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Robotbrain &lt;</span><a href="https://twitter.com/skylordelros"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">@skylordelros</span></a><span style=" font-size:10pt;">&gt;</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Rootbear75 &lt;</span><a href="https://twitter.com/rootbear75"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">@rootbear75</span></a><span style=" font-size:10pt;">&gt; (build server)</span></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> @@ -77,13 +296,12 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Rootbear75 &lt;</span><a href="https://twitter.com/rootbear75"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">@rootbear75</span></a><span style=" font-size:10pt;">&gt; (bau server)</span></p></body></html> - + No Language file loaded. Hey, Translator, feel free to put credit to you here Deutsche Sprachdatei von Kilobyte (siehe oben). Aktualisiert von xnrand (nsfw auf IRC), Jan und ACGaming. - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -209,7 +427,7 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * This file has been put into the public domain.</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> * You can do whatever you want with this file.</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> */</span></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:7.8pt; font-weight:400; font-style:normal;"> @@ -336,12 +554,11 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> */</span></p></body></html> - + Forking/Redistribution Abspaltung/Weiterverbreitung - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -351,7 +568,7 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:11pt;">Part of the reason for using the Apache license is we don't want people using the &quot;MultiMC&quot; name when redistributing the project. This means people must take the time to go through the source code and remove all references to &quot;MultiMC&quot;, including but not limited to the project icon and the title of windows, (no *MultiMC-fork* in the title).</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Bitstream Vera Sans'; font-size:11pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bitstream Vera Sans'; font-size:11pt;">The Apache license covers reasonable use for the name - a mention of the project's origins in the About dialog and the license is acceptable. However, it should be abundantly clear that the project is a fork </span><span style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:600;">without</span><span style=" font-family:'Bitstream Vera Sans'; font-size:11pt;"> implying that you have our blessing.</span></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> @@ -366,7 +583,7 @@ p, li { white-space: pre-wrap; } <html><head/><body><p><a href="http://github.com/Forkk/MultiMC5"><span style=" text-decoration: underline; color:#0000ff;">http://github.com/Forkk/MultiMC5</span></a></p></body></html> - + Credits Dank an @@ -477,7 +694,7 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">POSSIBILITY OF SUCH DAMAGE.</span></p></body></html> - + About Qt Über Qt @@ -486,6 +703,31 @@ p, li { white-space: pre-wrap; } Close Schließen + + + Version + Version + + + + Version Type + + + + + Platform + + + + + Build Number + + + + + Channel + + AccountListDialog @@ -584,6 +826,27 @@ p, li { white-space: pre-wrap; } Authentifizierung: Bearbeite Antwort... + + BaseExternalTool + + + MCEdit + + + + + Choose which world to open: + + + + + BaseProfiler + + + Profiler aborted + + + ConsoleWindow @@ -596,6 +859,11 @@ p, li { white-space: pre-wrap; } Upload Log Log hochladen + + + Manage Screenshots + + &Kill Minecraft @@ -611,11 +879,22 @@ p, li { white-space: pre-wrap; } Minecraft töten + + Console window for + + + + Close - Schließen + Schließen + + + + Hide + - + Kill Minecraft? Minecraft töten? @@ -641,7 +920,7 @@ p, li { white-space: pre-wrap; } DownloadUpdateTask - + Finding information about the current version... Finde Informationen zur benutzten Version... @@ -681,12 +960,12 @@ p, li { white-space: pre-wrap; } Bearbeite Dateilisten - Rechne aus, wie das Update installiert werden soll... - + Failed to write update script file. Fehler beim Schreiben des Updatescripts. - + Failed to download update files. Fehler beim Herunterladen der Updatedateien. @@ -813,7 +1092,29 @@ p, li { white-space: pre-wrap; } Konsole automatisch schließen, nachdem das Spiel beendet wurde? - + + The maximum amount of memory Minecraft is allowed to use. + + + + + + + MB + + + + + The amount of memory Minecraft is started with. + + + + + The amount of memory available to store loaded Java classes. + + + + Browse... Durchsuchen... @@ -831,7 +1132,7 @@ p, li { white-space: pre-wrap; } Automatisch einloggen, wenn das Instanzsymbol doppelt gecklickt wurde? - + Java Java @@ -841,7 +1142,7 @@ p, li { white-space: pre-wrap; } Arbeitsspeicher - + Minimum memory allocation: Min. Arbeitsspeicher: @@ -851,7 +1152,7 @@ p, li { white-space: pre-wrap; } Max. Arbeitsspeicher: - + PermGen: PermGen: @@ -925,6 +1226,32 @@ p, li { white-space: pre-wrap; } Das ausgewählte Java-Programm hat nicht funktioniert. Du solltest die Auto-Erkennung benutzen, oder den Pfad zum Java-Programm angeben. + + JProfiler + + + Listening on port: %1 + + + + + Profiler aborted + + + + + JVisualVM + + + JVisualVM started + + + + + Profiler aborted + + + JavaListLoadTask @@ -933,6 +1260,14 @@ p, li { white-space: pre-wrap; } Suche nach Java-Installationen... + + LLListLoadTask + + + Loading LiteLoader version list... + + + LWJGLSelectDialog @@ -1022,7 +1357,7 @@ p, li { white-space: pre-wrap; } Texturenpakete - + Select Loader Mods Title of regular mod selection dialog @@ -1060,7 +1395,7 @@ p, li { white-space: pre-wrap; } LegacyUpdate - + Downloading new LWJGL... LWJGL wird heruntergeladen... @@ -1085,7 +1420,7 @@ p, li { white-space: pre-wrap; } Neue minecraft.jar wird heruntergeladen... - + Installing mods: Adding Mod-Installation: Hinzufügen @@ -1209,7 +1544,7 @@ p, li { white-space: pre-wrap; } MCVListLoadTask - + Loading instance version list... Lade Liste von Minecraft-Versionen... @@ -1232,24 +1567,24 @@ p, li { white-space: pre-wrap; } Instanz-Werkzeugleiste - + News Toolbar Nachrichten-Werkzeugleiste - + Add Instance Instanz hinzufügen - + Add a new instance. Neue Instanz erstellen. - + View Instance Folder Instanzordner öffnen @@ -1260,7 +1595,7 @@ p, li { white-space: pre-wrap; } Instanzordner im Dateimanager öffnen. - + Refresh Aktualisieren @@ -1271,7 +1606,7 @@ p, li { white-space: pre-wrap; } Instanzliste neuladen. - + View Central Mods Folder Zenstralen Mod-Ordner öffnen @@ -1282,7 +1617,7 @@ p, li { white-space: pre-wrap; } Zentralen Mod-Ordner in einem Dateimanager öffnen. - + Check for Updates Auf Updates überprüfen @@ -1293,19 +1628,19 @@ p, li { white-space: pre-wrap; } Auf Updates für MultiMC prüfen - - + + Settings Einstellungen - + Change settings. Einstellungen ändern. - + Report a Bug Fehler melden @@ -1324,7 +1659,7 @@ p, li { white-space: pre-wrap; } Den MultiMC-Entwicklerblog öffnen, um Neuigkeiten über MultiMC zu erhalten. - + More News Mehr Nachrichten @@ -1340,7 +1675,7 @@ p, li { white-space: pre-wrap; } Öffne den MultiMC-Entwicklerblog, um weitere Neuigkeiten über MultiMC zu erhalten. - + About MultiMC Über MultiMC @@ -1358,11 +1693,12 @@ p, li { white-space: pre-wrap; } + Launch the selected instance. Die ausgewählte Instanz starten. - + Instance Name Instanzname @@ -1499,17 +1835,32 @@ p, li { white-space: pre-wrap; } Den Konfigurationsordner im Dateimanager anzeigen - + Meow Miau - <html><head/><body><p align="center"><span style=" font-weight:600; color:#ff0004;">Catnarok!</span></p><p align="center">Or just a cat with a ball of yarn?</p><p align="center"><span style=" font-style:italic;">WHO KNOWS?!</span></p><p align="center"><img src=":/icons/instances/tnt"/></p></body></html> - + <html><head/><body><p align="center">It's a fluffy kitty :3</p></body></html> + - + + Launch the selected instance in offline mode. + + + + + Manage Screenshots + + + + + <html><head/><body><p>View and upload screenshots for this instance</p></body></html> + + + + Copy Instance Kopiere Instanz @@ -1520,7 +1871,7 @@ p, li { white-space: pre-wrap; } - + Manage Accounts Verwalte Konten @@ -1534,17 +1885,22 @@ p, li { white-space: pre-wrap; } <html><head/><body><p align="center"><span style=" font-weight:600; color:#ff0004;">Catnatok!</span></p><p align="center">Or just a cat with a ball of yarn?</p><p align="center"><span style=" font-style:italic;">WHO KNOWS?!</span></p><p align="center"><img src=":/icons/instances/tnt"/></p></body></html> - + No instance selected Keine Instanz ausgewählt - + + No status available + + + + Accounts Konten - + No update found. Keine neue Version gefunden. @@ -1556,7 +1912,38 @@ You are using the latest version. Du verwendest bereits die neueste Version. - + + Rename + + + + + + Launch + + + + + Profilers + + + + + Profiler not setup correctly. Go into settings, "External Tools". + + + + + Tools + + + + + Tool not setup correctly. Go into settings, "External Tools". + + + + No accounts added! Keine Konten angegeben! @@ -1566,7 +1953,7 @@ Du verwendest bereits die neueste Version. Kein voreingestelltes Konto - + Loading news... Nachrichten werden geladen... @@ -1576,7 +1963,17 @@ Du verwendest bereits die neueste Version. Keine Nachrichten verfügbar. - + + Notification + + + + + Don't show again + + + + @@ -1584,20 +1981,22 @@ Du verwendest bereits die neueste Version. - + + + Error Fehler - - + + MultiMC cannot download Minecraft or update instances unless you have at least one account added. Please add your Mojang or Minecraft account. MultiMC kann Minecraft nicht herunterladen und keine Instanzen aktualisieren, solange du kein Konto erstellt hast. Bitte füge dein Mojang- oder Minecraft-Konto hinzu. - + Group name Gruppenname @@ -1607,7 +2006,7 @@ Bitte füge dein Mojang- oder Minecraft-Konto hinzu. Neuen Gruppennamen eingeben. - + CAREFUL ACHTUNG @@ -1629,7 +2028,7 @@ Die folgende Instanz löschen: Neuen Instanznamen eingeben. - + No Accounts Keine Konten @@ -1644,17 +2043,65 @@ Die folgende Instanz löschen: Welches Konto möchtest du benutzen? - + Your account is currently not logged in. Please enter your password to log in again. Dein Konto ist momentan nicht angemeldet. Bitte gib dein Passwort an, um dich anzumelden. + + + Player name + + + + + Choose your offline mode player name. + + + + + Couldn't start profiler: %1 + + + + + Waiting for profiler... + + + The launch of Minecraft itself is delayed until you press the button. This is the right time to setup the profiler, as the profiler server is running now. + +%1 + + + + + Waiting + + + + + Couldn't start the profiler: %1 + + + + + Failed to load screenshots! + + + + + Done uploading! + + + + + Play Offline Offline spielen - + Error updating instance Fehler beim Aktualisieren der Instanz @@ -1699,12 +2146,12 @@ Die folgende Instanz löschen: Instanzeinstellungen - + Rename Instance Instanz umbenennen - + Select a Java version Wähle eine Java-Version @@ -1722,7 +2169,7 @@ Die folgende Instanz löschen: MinecraftProcess - + Minecraft exited with exitcode %1. Message displayed on instance exit Minecraft wurde mit Status %1 beendet. @@ -1740,7 +2187,45 @@ Die folgende Instanz löschen: Minecraft wurde durch den Nutzer getötet. - + + Running Post-Launch command: %1 + + + + + Post-Launch command failed with code %1. + + + + + + + Post-Launch command ran successfully. + + + + + + + Running Pre-Launch command: %1 + + + + + Pre-Launch command failed with code %1. + + + + + + + Pre-Launch command ran successfully. + + + + + + Could not launch minecraft! Error message displayed if instace can't start Konnte Minecraft nicht starten! @@ -1849,7 +2334,7 @@ Die folgende Instanz löschen: OneSixFTBInstanceForge - + Downloading Forge... Forge wird heruntergeladen... @@ -1864,7 +2349,7 @@ Die folgende Instanz löschen: Fehlschlag beim Laden der Versions-Konfiguration - + Couldn't install Forge Fehler beim Installieren von Forge @@ -1881,19 +2366,18 @@ Die folgende Instanz löschen: Bibliothek - + Loader Mods Mods - - + &Add &Hinzufügen - + Manage Mods Verwalte Mods @@ -1903,7 +2387,7 @@ Die folgende Instanz löschen: Version - + Main Class: Hauptklasse: @@ -1922,50 +2406,67 @@ Die folgende Instanz löschen: Install LiteLoader Installiere LiteLoader + + + Reload + + + + + Remove + + + Reset order + + + + + Move up + + + + + Move down + + + Create an customized copy of the base version - Eine modifizierte Kopie der Version erstellen + Eine modifizierte Kopie der Version erstellen - Customize - Benutzerdefiniert + Benutzerdefiniert - Revert to original base version - Benutzerdefinierte Einstellungen zurücksetzen + Benutzerdefinierte Einstellungen zurücksetzen - Revert - Zurücksetzen + Zurücksetzen - Add new libraries - Füge neue Bibliotheken hinzu + Füge neue Bibliotheken hinzu - Remove selected libraries - Entferne ausgewählte Bibliotheken + Entferne ausgewählte Bibliotheken - - + &Remove &Entfernen - Open custom.json - Öffne custom.json + Öffne custom.json - + &View Folder &Ordner öffnen @@ -1976,49 +2477,78 @@ Die folgende Instanz löschen: Ressourcenpakete - - + + Couldn't remove file + + + + + + Couldn't save the new order + + + + + Revert? Zurücksetzen? - + + + This action will remove your custom.json. Continue? + + + + + No Forge versions are currently available for Minecraft + + + + + Select LiteLoader version + + + + + No LiteLoader versions are currently available for Minecraft + + + Do you want to revert the version of this instance to its original configuration? - Möchtest du wirklich die Version dieser Instanz zurücksetzen? + Möchtest du wirklich die Version dieser Instanz zurücksetzen? - + + + Error Fehler - Unable to open custom.json, check the settings - Fehler beim Öffnen der custom.json-Datei, überprüfe deine Einstellungen + Fehler beim Öffnen der custom.json-Datei, überprüfe deine Einstellungen - + Select Forge version Wähle Forge-Version - This will revert any changes you did to the version up to this point. Is that OK? - Dies wird alle Änderungen, die du vorgenommen hast, zurücksetzen. Bist du damit einverstanden? + Dies wird alle Änderungen, die du vorgenommen hast, zurücksetzen. Bist du damit einverstanden? - - + LiteLoader LiteLoader - There is no information available on how to install LiteLoader into this version of Minecraft - Es gibt momentan keine Informationen zur Installation von LiteLoader für diese Version von Minecraft + Es gibt momentan keine Informationen zur Installation von LiteLoader für diese Version von Minecraft - + For reasons unknown, the LiteLoader installation failed. Check your MultiMC log files for details. Aus unbekannten Gründen ist die Installation von LiteLoader fehlgeschlagen. Sieh dir die MultiMC-Logdateien an, um weitere Details zu erhalten. @@ -2026,18 +2556,16 @@ Die folgende Instanz löschen: OneSixUpdate - - Testing the Java installation... - Java-Installation wird getestet... + Java-Installation wird getestet... - + Getting the version files from Mojang... Versionsdateien von Mojang werden heruntergeladen... - + Updating assets index... Datenindex wird aktualisiert... @@ -2047,14 +2575,26 @@ Die folgende Instanz löschen: Daten werden von Mojang geholt... - + Getting the library files from Mojang... Bibliotheken werden von Mojang geholt... - Preparing for launch... - Start wird vorbereitet... + Start wird vorbereitet... + + + + OneSixVersion + + + Name + Name + + + + Version + Version @@ -2101,11 +2641,96 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.The mod author didn't provide a website link for this mod. Der Autor der Modifikation hat keine URL hinterlegt. + + + + Empty path + + + + + Invalid path to JVisualVM + + + + + + Path does not exist + + + + + Invalid JProfiler install + + + + + Path is empty + + + + + Path does not seem to be a MCEdit path + + + + + Latest + + + + + + + + + + + + Error + Fehler + + + + + Error while applying %1. Please check MultiMC-0.log for more info. + + + + + Error while reading. Please check MultiMC-0.log for more info. + + + + + Error while applying. Please check MultiMC-0.log for more info. + + + + + The version descriptors of this instance are not compatible with the current version of MultiMC + + + + + Unable to open %1: %2 + + + + + Unable to parse %1: %2 at %3 + + + + + Error while reading %1. Please check MultiMC-0.log for more info. + + RefreshTask - + Refreshing login token... Erneuerung des Login-Tokens... @@ -2115,6 +2740,63 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Erneuerung des Login-Tokens: Verarbeite Antwort... + + ScreenshotDialog + + + Screenshot Manager + + + + + Upload + + + + + Delete + Löschen + + + + Close + Schließen + + + + <a href="https://imgur.com/a/%1">Visit album</a><br/>Delete hash: %2 (save this if you want to be able to edit/delete the album) + + + + + Failed to upload screenshots! + + + + + Unknown error + + + + + ScreenshotList + + + + Error! + + + + + Failed to delete screenshots! + + + + + Unable to refresh list: %1 + + + SettingsDialog @@ -2123,12 +2805,11 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Einstellungen - General - Allgemein + Allgemein - + Sorting Mode Sortiermodus @@ -2143,22 +2824,21 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Nach Namen - + Update Settings Updateeinstellungen - Use development builds? - Entwicklungsversionen benutzen? + Entwicklungsversionen benutzen? - + Check for updates when MultiMC starts? Beim Start nach Updates suchen? - + Folders Ordner @@ -2174,13 +2854,31 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast. - - + + + + + ... ... - + + Features + + + + + Update Channel: + + + + + No channel selected. + + + + FTB FTB @@ -2215,7 +2913,17 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Symbole: - + + User Interface + + + + + Language (needs restart): + + + + External Editors (leave empty for system default) Externe Editor-Anwendungen (leer lassen, um die System-Voreinstellung zu benutzen) @@ -2264,12 +2972,129 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Automatically close console when the game quits? Konsole automatisch schließen, nachdem das Spiel beendet wurde? + + + Network settings. + + + + + Network + + + + + Proxy + + + + + Type + + + + + Uses your system's default proxy settings. + + + + + Default + + + + + None + + + + + SOCKS5 + + + + + HTTP + + + + + Address and Port + + + + + 127.0.0.1 + + + + + Authentication + + + + + Username: + Nutzername: + + + + Password: + Passwort: + + + + Note: Proxy username and password are stored in plain text inside MultiMC's configuration file! + + + + + External Tools + + + + + JProfiler + + + + + + + Check + + + + + <html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html> + + + + + JVisualVM + + + + + <html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html> + + + + + MCEdit + + + + + <html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html> + + Login automatically when an instance icon is double clicked? Automatisch einloggen, wenn das Instanzsymbol doppelt geklickt wurde? - + Java Java @@ -2279,7 +3104,19 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Arbeitsspeicher - + + The maximum amount of memory Minecraft is allowed to use. + + + + + + + MB + + + + Minimum memory allocation: Min. Arbeitspeicher: @@ -2289,12 +3126,22 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Max. Arbeitspeicher: - + + The amount of memory Minecraft is started with. + + + + PermGen: PermGen: - + + The amount of memory available to store loaded Java classes. + + + + Java Settings Java-Einstellungen @@ -2347,17 +3194,17 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Der Vor-Start-Befehl wird ausgeführt, bevor die Instanz startet, der Nach-Ende-Befehl, nachdem die Instanz beendet wurde. Beide werden im Hauptverzeichnis von MultiMC gestartet. Verfügbare Umgebungsvariablen: INST_ID, INST_DIR, INST_NAME. - + FTB Launcher Directory FTB-Launcher-Ordner - + FTB Directory FTB-Ordner - + Instance Directory Instanz-Ordner @@ -2382,27 +3229,103 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.JSON-Editor - + Invalid Ungültig - + The file chosen does not seem to be an executable Die ausgewählte Datei scheint keine Anwendung zu sein - + + English + + + + + JProfiler Directory + + + + + + + + + + Error + Fehler + + + + + Error while checking JProfiler install: +%1 + + + + + + + OK + + + + + JProfiler setup seems to be OK + + + + + JVisualVM Executable + + + + + + Error while checking JVisualVM install: +%1 + + + + + JVisualVM setup seems to be OK + + + + + MCEdit Application + + + + + MCEdit Directory + + + + + + Error while checking MCEdit install: +%1 + + + + + MCEdit setup seems to be OK + + + Development builds - Entwicklungsversionen + Entwicklungsversionen - Development builds contain experimental features and may be unstable. Are you sure you want to enable them? - Entwicklungsversionen enthalten experimentelle Features und können instabil sein. Möchtest du sie dennoch aktivieren? + Entwicklungsversionen enthalten experimentelle Features und können instabil sein. Möchtest du sie dennoch aktivieren? - + Select a Java version Wähle eine Java-Version @@ -2480,6 +3403,14 @@ Diese Mitteilung wird so lange angezeigt, bis du die Option entfernt hast.Validiere Zugriffstoken: Bearbeite Antwort... + + VersionListView + + + No versions are currently available. + + + VersionSelectDialog -- cgit v1.2.3 From 7dfd6aa051c582e26125e17e1d6eed5e675e1027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 1 Mar 2014 18:18:51 +0100 Subject: Remove obsolete OneSixFTBInstanceForge --- logic/OneSixFTBInstance.cpp | 70 --------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp index 91efce8e..8b8465b9 100644 --- a/logic/OneSixFTBInstance.cpp +++ b/logic/OneSixFTBInstance.cpp @@ -10,76 +10,6 @@ #include "MultiMC.h" #include "pathutils.h" -class OneSixFTBInstanceForge : public Task -{ - Q_OBJECT -public: - explicit OneSixFTBInstanceForge(const QString &version, OneSixFTBInstance *inst, QObject *parent = 0) : - Task(parent), instance(inst), version("Forge " + version) - { - } - - void executeTask() - { - for (int i = 0; i < MMC->forgelist()->count(); ++i) - { - if (MMC->forgelist()->at(i)->name() == version) - { - forgeVersion = std::dynamic_pointer_cast(MMC->forgelist()->at(i)); - break; - } - } - if (!forgeVersion) - { - emitFailed(QString("Couldn't find forge version ") + version ); - return; - } - entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename); - if (entry->stale) - { - setStatus(tr("Downloading Forge...")); - fjob = new NetJob("Forge download"); - fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry)); - connect(fjob, &NetJob::failed, [this](){emitFailed(m_failReason);}); - connect(fjob, &NetJob::succeeded, this, &OneSixFTBInstanceForge::installForge); - connect(fjob, &NetJob::progress, [this](qint64 c, qint64 total){ setProgress(100 * c / total); }); - fjob->start(); - } - else - { - installForge(); - } - } - -private -slots: - void installForge() - { - setStatus(tr("Installing Forge...")); - QString forgePath = entry->getFullPath(); - ForgeInstaller forge(forgePath, forgeVersion->universal_url); - if (!instance->reloadVersion()) - { - emitFailed(tr("Couldn't load the version config")); - return; - } - auto version = instance->getFullVersion(); - if (!forge.add(instance)) - { - emitFailed(tr("Couldn't install Forge")); - return; - } - emitSucceeded(); - } - -private: - OneSixFTBInstance *instance; - QString version; - ForgeVersionPtr forgeVersion; - MetaEntryPtr entry; - NetJob *fjob; -}; - OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : OneSixInstance(rootDir, settings, parent) { -- cgit v1.2.3 From 7c24bcc83476dcbdd7f7acbe14ecef4398962689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 1 Mar 2014 23:06:47 +0100 Subject: Reorganize the version-related code. --- CMakeLists.txt | 21 +- gui/dialogs/OneSixModEditDialog.cpp | 4 +- gui/dialogs/OneSixModEditDialog.h | 2 +- logic/BaseInstaller.cpp | 2 +- logic/ForgeInstaller.cpp | 6 +- logic/ForgeInstaller.h | 4 +- logic/LiteLoaderInstaller.cpp | 2 +- logic/OneSixFTBInstance.cpp | 2 +- logic/OneSixInstance.cpp | 12 +- logic/OneSixInstance.h | 8 +- logic/OneSixInstance_p.h | 6 +- logic/OneSixUpdate.cpp | 8 +- logic/OneSixVersion.cpp | 221 ---------- logic/OneSixVersion.h | 137 ------- logic/OneSixVersionBuilder.cpp | 797 +----------------------------------- logic/OneSixVersionBuilder.h | 15 +- logic/VersionFile.cpp | 702 +++++++++++++++++++++++++++++++ logic/VersionFile.h | 90 ++++ logic/VersionFinal.cpp | 221 ++++++++++ logic/VersionFinal.h | 137 +++++++ 20 files changed, 1214 insertions(+), 1183 deletions(-) delete mode 100644 logic/OneSixVersion.cpp delete mode 100644 logic/OneSixVersion.h create mode 100644 logic/VersionFile.cpp create mode 100644 logic/VersionFile.h create mode 100644 logic/VersionFinal.cpp create mode 100644 logic/VersionFinal.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f070684d..229179cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,31 +414,38 @@ logic/LegacyInstance.cpp logic/LegacyInstance_p.h logic/LegacyUpdate.h logic/LegacyUpdate.cpp + logic/LegacyForge.h logic/LegacyForge.cpp # OneSix instances logic/OneSixUpdate.h logic/OneSixUpdate.cpp -logic/OneSixVersion.h -logic/OneSixVersion.cpp +logic/OneSixInstance.h +logic/OneSixInstance.cpp +logic/OneSixInstance_p.h + +# OneSix version json infrastructure +logic/OneSixVersionBuilder.h +logic/OneSixVersionBuilder.cpp +logic/VersionFile.h +logic/VersionFile.cpp +logic/VersionFinal.h +logic/VersionFinal.cpp logic/OneSixLibrary.h logic/OneSixLibrary.cpp logic/OneSixRule.h logic/OneSixRule.cpp logic/OpSys.h logic/OpSys.cpp + +# Mod installers logic/BaseInstaller.h logic/BaseInstaller.cpp logic/ForgeInstaller.h logic/ForgeInstaller.cpp logic/LiteLoaderInstaller.h logic/LiteLoaderInstaller.cpp -logic/OneSixInstance.h -logic/OneSixInstance.cpp -logic/OneSixInstance_p.h -logic/OneSixVersionBuilder.h -logic/OneSixVersionBuilder.cpp # Nostalgia logic/NostalgiaInstance.h diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index fe621a9a..67210217 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -34,7 +34,7 @@ #include "gui/dialogs/ProgressDialog.h" #include "logic/ModList.h" -#include "logic/OneSixVersion.h" +#include "logic/VersionFinal.h" #include "logic/EnabledItemFilter.h" #include "logic/lists/ForgeVersionList.h" #include "logic/lists/LiteLoaderVersionList.h" @@ -353,7 +353,7 @@ QMap OneSixModEditDialog::getExistingOrder() const QMap order; // default { - for (OneSixVersion::VersionFile file : m_version->versionFiles) + for (VersionFinal::VersionFile file : m_version->versionFiles) { if (file.id.startsWith("org.multimc.")) { diff --git a/gui/dialogs/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h index f44b336b..1f3f9f67 100644 --- a/gui/dialogs/OneSixModEditDialog.h +++ b/gui/dialogs/OneSixModEditDialog.h @@ -60,7 +60,7 @@ protected: private: Ui::OneSixModEditDialog *ui; - std::shared_ptr m_version; + std::shared_ptr m_version; std::shared_ptr m_mods; std::shared_ptr m_resourcepacks; EnabledItemFilter *main_model; diff --git a/logic/BaseInstaller.cpp b/logic/BaseInstaller.cpp index 92aa0c92..669fd0ac 100644 --- a/logic/BaseInstaller.cpp +++ b/logic/BaseInstaller.cpp @@ -17,7 +17,7 @@ #include -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixLibrary.h" #include "OneSixInstance.h" diff --git a/logic/ForgeInstaller.cpp b/logic/ForgeInstaller.cpp index 3e18d17f..6f238c21 100644 --- a/logic/ForgeInstaller.cpp +++ b/logic/ForgeInstaller.cpp @@ -14,7 +14,7 @@ */ #include "ForgeInstaller.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixLibrary.h" #include "net/HttpMetaCache.h" #include @@ -33,7 +33,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url) { - std::shared_ptr newVersion; + std::shared_ptr newVersion; m_universal_url = universal_url; QuaZip zip(filename); @@ -66,7 +66,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url) // read the forge version info { - newVersion = OneSixVersion::fromJson(versionInfoVal.toObject()); + newVersion = VersionFinal::fromJson(versionInfoVal.toObject()); if (!newVersion) return; } diff --git a/logic/ForgeInstaller.h b/logic/ForgeInstaller.h index c5052092..df029f38 100644 --- a/logic/ForgeInstaller.h +++ b/logic/ForgeInstaller.h @@ -20,7 +20,7 @@ #include #include -class OneSixVersion; +class VersionFinal; class ForgeInstaller : public BaseInstaller { @@ -33,7 +33,7 @@ public: private: // the version, read from the installer - std::shared_ptr m_forge_version; + std::shared_ptr m_forge_version; QString internalPath; QString finalPath; QString realVersionId; diff --git a/logic/LiteLoaderInstaller.cpp b/logic/LiteLoaderInstaller.cpp index 126027fb..44400e8a 100644 --- a/logic/LiteLoaderInstaller.cpp +++ b/logic/LiteLoaderInstaller.cpp @@ -20,7 +20,7 @@ #include "logger/QsLog.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixLibrary.h" #include "OneSixInstance.h" diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp index 8b8465b9..cdb3f53e 100644 --- a/logic/OneSixFTBInstance.cpp +++ b/logic/OneSixFTBInstance.cpp @@ -1,6 +1,6 @@ #include "OneSixFTBInstance.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixLibrary.h" #include "tasks/SequentialTask.h" #include "ForgeInstaller.h" diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 10411c56..bd5d559e 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -19,7 +19,7 @@ #include "OneSixInstance_p.h" #include "OneSixUpdate.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "pathutils.h" #include "logger/QsLog.h" #include "assets/AssetsUtils.h" @@ -34,8 +34,8 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, I_D(OneSixInstance); d->m_settings->registerSetting("IntendedVersion", ""); d->m_settings->registerSetting("ShouldUpdate", false); - d->version.reset(new OneSixVersion(this, this)); - d->vanillaVersion.reset(new OneSixVersion(this, this)); + d->version.reset(new VersionFinal(this, this)); + d->vanillaVersion.reset(new VersionFinal(this, this)); } void OneSixInstance::init() @@ -79,7 +79,7 @@ QString replaceTokensIn(QString text, QMap with) return result; } -QDir OneSixInstance::reconstructAssets(std::shared_ptr version) +QDir OneSixInstance::reconstructAssets(std::shared_ptr version) { QDir assetsDir = QDir("assets/"); QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes")); @@ -345,13 +345,13 @@ void OneSixInstance::clearVersion() emit versionReloaded(); } -std::shared_ptr OneSixInstance::getFullVersion() const +std::shared_ptr OneSixInstance::getFullVersion() const { I_D(const OneSixInstance); return d->version; } -std::shared_ptr OneSixInstance::getVanillaVersion() const +std::shared_ptr OneSixInstance::getVanillaVersion() const { I_D(const OneSixInstance); return d->vanillaVersion; diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 06fd9de3..75edec1e 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -17,7 +17,7 @@ #include "BaseInstance.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "ModList.h" class OneSixInstance : public BaseInstance @@ -58,9 +58,9 @@ public: /// clears all version information in preparation for an update void clearVersion(); /// get the current full version info - std::shared_ptr getFullVersion() const; + std::shared_ptr getFullVersion() const; /// gets the current version info, but only for version.json - std::shared_ptr getVanillaVersion() const; + std::shared_ptr getVanillaVersion() const; /// is the current version original, or custom? virtual bool versionIsCustom() override; @@ -80,5 +80,5 @@ signals: private: QStringList processMinecraftArgs(AuthSessionPtr account); - QDir reconstructAssets(std::shared_ptr version); + QDir reconstructAssets(std::shared_ptr version); }; diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h index 0cc46f33..2dffa62c 100644 --- a/logic/OneSixInstance_p.h +++ b/logic/OneSixInstance_p.h @@ -16,13 +16,13 @@ #pragma once #include "BaseInstance_p.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "ModList.h" struct OneSixInstancePrivate : public BaseInstancePrivate { - std::shared_ptr version; - std::shared_ptr vanillaVersion; + std::shared_ptr version; + std::shared_ptr vanillaVersion; std::shared_ptr loader_mod_list; std::shared_ptr resource_pack_list; }; diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index f87c65e7..750aeabb 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -25,7 +25,7 @@ #include "BaseInstance.h" #include "lists/MinecraftVersionList.h" -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixLibrary.h" #include "OneSixInstance.h" #include "net/ForgeMirrors.h" @@ -150,7 +150,7 @@ void OneSixUpdate::assetIndexStart() { setStatus(tr("Updating assets index...")); OneSixInstance *inst = (OneSixInstance *)m_inst; - std::shared_ptr version = inst->getFullVersion(); + std::shared_ptr version = inst->getFullVersion(); QString assetName = version->assets; QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json"; QString localPath = assetName + ".json"; @@ -174,7 +174,7 @@ void OneSixUpdate::assetIndexFinished() AssetsIndex index; OneSixInstance *inst = (OneSixInstance *)m_inst; - std::shared_ptr version = inst->getFullVersion(); + std::shared_ptr version = inst->getFullVersion(); QString assetName = version->assets; QString asset_fname = "assets/indexes/" + assetName + ".json"; @@ -243,7 +243,7 @@ void OneSixUpdate::jarlibStart() } // Build a list of URLs that will need to be downloaded. - std::shared_ptr version = inst->getFullVersion(); + std::shared_ptr version = inst->getFullVersion(); // minecraft.jar for this version { QString version_id = version->id; diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp deleted file mode 100644 index 06e748bd..00000000 --- a/logic/OneSixVersion.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "OneSixVersion.h" - -#include -#include - -#include "OneSixVersionBuilder.h" - -OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent) - : QAbstractListModel(parent), m_instance(instance) -{ - clear(); -} - -bool OneSixVersion::reload(QWidget *widgetParent, const bool onlyVanilla, const QStringList &external) -{ - beginResetModel(); - bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla, external); - endResetModel(); - return ret; -} - -void OneSixVersion::clear() -{ - beginResetModel(); - id.clear(); - time.clear(); - releaseTime.clear(); - type.clear(); - assets.clear(); - processArguments.clear(); - minecraftArguments.clear(); - minimumLauncherVersion = 0xDEADBEAF; - mainClass.clear(); - libraries.clear(); - tweakers.clear(); - versionFiles.clear(); - endResetModel(); -} - -void OneSixVersion::dump() const -{ - qDebug().nospace() << "OneSixVersion(" - << "\n\tid=" << id - << "\n\ttime=" << time - << "\n\treleaseTime=" << releaseTime - << "\n\ttype=" << type - << "\n\tassets=" << assets - << "\n\tprocessArguments=" << processArguments - << "\n\tminecraftArguments=" << minecraftArguments - << "\n\tminimumLauncherVersion=" << minimumLauncherVersion - << "\n\tmainClass=" << mainClass - << "\n\tlibraries="; - for (auto lib : libraries) - { - qDebug().nospace() << "\n\t\t" << lib.get(); - } - qDebug().nospace() << "\n)"; -} - -bool OneSixVersion::canRemove(const int index) const -{ - if (index < versionFiles.size()) - { - return versionFiles.at(index).id != "org.multimc.version.json"; - } - return false; -} - -QString OneSixVersion::versionFileId(const int index) const -{ - if (index < 0 || index >= versionFiles.size()) - { - return QString(); - } - return versionFiles.at(index).id; -} - -bool OneSixVersion::remove(const int index) -{ - if (canRemove(index)) - { - return QFile::remove(versionFiles.at(index).filename); - } - return false; -} - -QList > OneSixVersion::getActiveNormalLibs() -{ - QList > output; - for (auto lib : libraries) - { - if (lib->isActive() && !lib->isNative()) - { - output.append(lib); - } - } - return output; -} - -QList > OneSixVersion::getActiveNativeLibs() -{ - QList > output; - for (auto lib : libraries) - { - if (lib->isActive() && lib->isNative()) - { - output.append(lib); - } - } - return output; -} - -std::shared_ptr OneSixVersion::fromJson(const QJsonObject &obj) -{ - std::shared_ptr version(new OneSixVersion(0)); - if (OneSixVersionBuilder::read(version.get(), obj)) - { - return version; - } - return 0; -} - -QVariant OneSixVersion::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - int row = index.row(); - int column = index.column(); - - if (row < 0 || row >= versionFiles.size()) - return QVariant(); - - if (role == Qt::DisplayRole) - { - switch (column) - { - case 0: - return versionFiles.at(row).name; - case 1: - return versionFiles.at(row).version; - default: - return QVariant(); - } - } - return QVariant(); -} - -QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal) - { - if (role == Qt::DisplayRole) - { - switch (section) - { - case 0: - return tr("Name"); - case 1: - return tr("Version"); - default: - return QVariant(); - } - } - } - return QVariant(); -} - -Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return Qt::NoItemFlags; - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; -} - -int OneSixVersion::rowCount(const QModelIndex &parent) const -{ - return versionFiles.size(); -} - -int OneSixVersion::columnCount(const QModelIndex &parent) const -{ - return 2; -} - -QDebug operator<<(QDebug &dbg, const OneSixVersion *version) -{ - version->dump(); - return dbg.maybeSpace(); -} -QDebug operator<<(QDebug &dbg, const OneSixLibrary *library) -{ - dbg.nospace() << "OneSixLibrary(" - << "\n\t\t\trawName=" << library->rawName() - << "\n\t\t\tname=" << library->name() - << "\n\t\t\tversion=" << library->version() - << "\n\t\t\ttype=" << library->type() - << "\n\t\t\tisActive=" << library->isActive() - << "\n\t\t\tisNative=" << library->isNative() - << "\n\t\t\tdownloadUrl=" << library->downloadUrl() - << "\n\t\t\tstoragePath=" << library->storagePath() - << "\n\t\t\tabsolutePath=" << library->absoluteUrl() - << "\n\t\t\thint=" << library->hint(); - dbg.nospace() << "\n\t\t)"; - return dbg.maybeSpace(); -} diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h deleted file mode 100644 index fee47fa3..00000000 --- a/logic/OneSixVersion.h +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include -#include -#include - -#include "OneSixLibrary.h" - -class OneSixInstance; - -class OneSixVersion : public QAbstractListModel -{ - Q_OBJECT -public: - explicit OneSixVersion(OneSixInstance *instance, QObject *parent = 0); - - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - - bool reload(QWidget *widgetParent, const bool onlyVanilla = false, const QStringList &external = QStringList()); - void clear(); - - void dump() const; - - bool canRemove(const int index) const; - - QString versionFileId(const int index) const; - -public -slots: - bool remove(const int index); - -public: - QList> getActiveNormalLibs(); - QList> getActiveNativeLibs(); - - static std::shared_ptr fromJson(const QJsonObject &obj); - - // data members -public: - /// the ID - determines which jar to use! ACTUALLY IMPORTANT! - QString id; - /// Last updated time - as a string - QString time; - /// Release time - as a string - QString releaseTime; - /// Release type - "release" or "snapshot" - QString type; - /// Assets type - "legacy" or a version ID - QString assets; - /** - * DEPRECATED: Old versions of the new vanilla launcher used this - * ex: "username_session_version" - */ - QString processArguments; - /** - * arguments that should be used for launching minecraft - * - * ex: "--username ${auth_player_name} --session ${auth_session} - * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" - */ - QString minecraftArguments; - /** - * the minimum launcher version required by this version ... current is 4 (at point of - * writing) - */ - int minimumLauncherVersion = 0xDEADBEEF; - /** - * A list of all tweaker classes - */ - QStringList tweakers; - /** - * The main class to load first - */ - QString mainClass; - - /// the list of libs - both active and inactive, native and java - QList> libraries; - - /* - FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. - - "rules": [ - { - "action": "allow" - }, - { - "action": "disallow", - "os": { - "name": "osx", - "version": "^10\\.5\\.\\d$" - } - } - ], - "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX - 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" - } - */ - // QList rules; - - struct VersionFile - { - QString name; - QString id; - QString version; - QString mcVersion; - QString filename; - int order; - }; - QList versionFiles; - -private: - OneSixInstance *m_instance; -}; - -QDebug operator<<(QDebug &dbg, const OneSixVersion *version); -QDebug operator<<(QDebug &dbg, const OneSixLibrary *library); diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index f6917697..0d4d66a2 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -26,806 +26,37 @@ #include #include -#include "OneSixVersion.h" +#include "VersionFinal.h" #include "OneSixInstance.h" #include "OneSixRule.h" +#include "VersionFile.h" #include "modutils.h" #include "logger/QsLog.h" -#define CURRENT_MINIMUM_LAUNCHER_VERSION 14 - -struct VersionFile -{ - int order; - QString name; - QString fileId; - QString version; - // TODO use the mcVersion to determine if a version file should be removed on update - QString mcVersion; - QString filename; - // TODO requirements - // QMap requirements; - QString id; - QString mainClass; - QString overwriteMinecraftArguments; - QString addMinecraftArguments; - QString removeMinecraftArguments; - QString processArguments; - QString type; - QString releaseTime; - QString time; - QString assets; - int minimumLauncherVersion = -1; - - bool shouldOverwriteTweakers = false; - QStringList overwriteTweakers; - QStringList addTweakers; - QStringList removeTweakers; - - struct Library - { - QString name; - QString url; - QString hint; - QString absoluteUrl; - bool applyExcludes = false; - QStringList excludes; - bool applyNatives = false; - QList> natives; - bool applyRules = false; - QList> rules; - - // user for '+' libraries - enum InsertType - { - Apply, - Append, - Prepend, - Replace - }; - InsertType insertType = Append; - QString insertData; - enum DependType - { - Soft, - Hard - }; - DependType dependType = Soft; - }; - bool shouldOverwriteLibs = false; - QList overwriteLibs; - QList addLibs; - QList removeLibs; - - enum ApplyError - { - LauncherVersionError, - OtherError, - NoApplyError - }; - - static Library fromLibraryJson(const QJsonObject &libObj, const QString &filename, - bool &isError) - { - isError = true; - Library out; - if (!libObj.contains("name")) - { - QLOG_ERROR() << filename << "contains a library that doesn't have a 'name' field"; - return out; - } - out.name = libObj.value("name").toString(); - - auto readString = [libObj, filename](const QString &key, QString &variable) - { - if (libObj.contains(key)) - { - QJsonValue val = libObj.value(key); - if (!val.isString()) - { - QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; - } - else - { - variable = val.toString(); - } - } - }; - - readString("url", out.url); - readString("MMC-hint", out.hint); - readString("MMC-absulute_url", out.absoluteUrl); - readString("MMC-absoluteUrl", out.absoluteUrl); - if (libObj.contains("extract")) - { - if (!libObj.value("extract").isObject()) - { - QLOG_ERROR() - << filename - << "contains a library with an 'extract' field that's not an object"; - return out; - } - QJsonObject extractObj = libObj.value("extract").toObject(); - if (!extractObj.contains("exclude") || !extractObj.value("exclude").isArray()) - { - QLOG_ERROR() << filename - << "contains a library with an invalid 'extract' field"; - return out; - } - out.applyExcludes = true; - QJsonArray excludeArray = extractObj.value("exclude").toArray(); - for (auto excludeVal : excludeArray) - { - if (!excludeVal.isString()) - { - QLOG_WARN() << filename << "contains a library that contains an 'extract' " - "field that contains an invalid 'exclude' entry " - "(skipping)"; - } - else - { - out.excludes.append(excludeVal.toString()); - } - } - } - if (libObj.contains("natives")) - { - if (!libObj.value("natives").isObject()) - { - QLOG_ERROR() - << filename - << "contains a library with a 'natives' field that's not an object"; - return out; - } - out.applyNatives = true; - QJsonObject nativesObj = libObj.value("natives").toObject(); - for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) - { - if (!it.value().isString()) - { - QLOG_WARN() << filename << "contains an invalid native (skipping)"; - } - OpSys opSys = OpSys_fromString(it.key()); - if (opSys != Os_Other) - { - out.natives.append(qMakePair(opSys, it.value().toString())); - } - } - } - if (libObj.contains("rules")) - { - out.applyRules = true; - out.rules = rulesFromJsonV4(libObj); - } - isError = false; - return out; - } - static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, - const bool requireOrder, bool &isError, const OneSixVersionBuilder::ParseFlags flags = OneSixVersionBuilder::NoFlags) - { - VersionFile out; - isError = true; - if (doc.isEmpty() || doc.isNull()) - { - QLOG_ERROR() << filename << "is empty or null"; - return out; - } - if (!doc.isObject()) - { - QLOG_ERROR() << "The root of" << filename << "is not an object"; - return out; - } - - QJsonObject root = doc.object(); - - if (requireOrder) - { - if (root.contains("order")) - { - if (root.value("order").isDouble()) - { - out.order = root.value("order").toDouble(); - } - else - { - QLOG_ERROR() << "'order' field contains an invalid value in" << filename; - return out; - } - } - else - { - QLOG_ERROR() << filename << "doesn't contain an order field"; - } - } - - out.name = root.value("name").toString(); - out.fileId = root.value("fileId").toString(); - out.version = root.value("version").toString(); - out.mcVersion = root.value("mcVersion").toString(); - out.filename = filename; - - auto readString = [root, filename](const QString &key, QString &variable) - { - if (root.contains(key)) - { - QJsonValue val = root.value(key); - if (!val.isString()) - { - QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; - } - else - { - variable = val.toString(); - } - } - }; - - if (!(flags & OneSixVersionBuilder::IsFTBPackJson)) - { - readString("id", out.id); - } - readString("mainClass", out.mainClass); - readString("processArguments", out.processArguments); - readString("minecraftArguments", out.overwriteMinecraftArguments); - readString("+minecraftArguments", out.addMinecraftArguments); - readString("-minecraftArguments", out.removeMinecraftArguments); - readString("type", out.type); - readString("releaseTime", out.releaseTime); - readString("time", out.time); - readString("assets", out.assets); - if (root.contains("minimumLauncherVersion")) - { - QJsonValue val = root.value("minimumLauncherVersion"); - if (!val.isDouble()) - { - QLOG_WARN() << "minimumLauncherVersion is not an int in" << filename - << "(skipping)"; - } - else - { - out.minimumLauncherVersion = val.toDouble(); - } - } - - if (root.contains("tweakers")) - { - QJsonValue tweakersVal = root.value("tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a 'tweakers' field, but it's not an array"; - return out; - } - out.shouldOverwriteTweakers = true; - QJsonArray tweakers = root.value("tweakers").toArray(); - for (auto tweakerVal : tweakers) - { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a 'tweakers' field entry that's not a string"; - return out; - } - out.overwriteTweakers.append(tweakerVal.toString()); - } - } - if (root.contains("+tweakers")) - { - QJsonValue tweakersVal = root.value("+tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a '+tweakers' field, but it's not an array"; - return out; - } - QJsonArray tweakers = root.value("+tweakers").toArray(); - for (auto tweakerVal : tweakers) - { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a '+tweakers' field entry that's not a string"; - return out; - } - out.addTweakers.append(tweakerVal.toString()); - } - } - if (root.contains("-tweakers")) - { - QJsonValue tweakersVal = root.value("-tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a '-tweakers' field, but it's not an array"; - return out; - } - out.shouldOverwriteTweakers = true; - QJsonArray tweakers = root.value("-tweakers").toArray(); - for (auto tweakerVal : tweakers) - { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a '-tweakers' field entry that's not a string"; - return out; - } - out.removeTweakers.append(tweakerVal.toString()); - } - } - - if (root.contains("libraries")) - { - out.shouldOverwriteLibs = !(flags & OneSixVersionBuilder::IsFTBPackJson); - QJsonValue librariesVal = root.value("libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a 'libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) - { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - bool error; - Library lib = fromLibraryJson(libObj, filename, error); - if (error) - { - QLOG_ERROR() << "Error while reading a library entry in" << filename; - return out; - } - if (flags & OneSixVersionBuilder::IsFTBPackJson) - { - lib.hint = "local"; - lib.insertType = Library::Prepend; - out.addLibs.prepend(lib); - } - else - { - out.overwriteLibs.append(lib); - } - } - } - if (root.contains("+libraries")) - { - QJsonValue librariesVal = root.value("+libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a '+libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) - { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - bool error; - Library lib = fromLibraryJson(libObj, filename, error); - if (error) - { - QLOG_ERROR() << "Error while reading a library entry in" << filename; - return out; - } - if (!libObj.contains("insert")) - { - QLOG_ERROR() << "Missing 'insert' field in '+libraries' field in" - << filename; - return out; - } - QJsonValue insertVal = libObj.value("insert"); - QString insertString; - { - if (insertVal.isString()) - { - insertString = insertVal.toString(); - } - else if (insertVal.isObject()) - { - QJsonObject insertObj = insertVal.toObject(); - if (insertObj.isEmpty()) - { - QLOG_ERROR() << "One library has an empty insert object in" - << filename; - return out; - } - insertString = insertObj.keys().first(); - lib.insertData = insertObj.value(insertString).toString(); - } - } - if (insertString == "apply") - { - lib.insertType = Library::Apply; - } - else if (insertString == "prepend") - { - lib.insertType = Library::Prepend; - } - else if (insertString == "append") - { - lib.insertType = Library::Prepend; - } - else if (insertString == "replace") - { - lib.insertType = Library::Replace; - } - else - { - QLOG_ERROR() << "A '+' library in" << filename - << "contains an invalid insert type"; - return out; - } - if (libObj.contains("MMC-depend") && libObj.value("MMC-depend").isString()) - { - const QString dependString = libObj.value("MMC-depend").toString(); - if (dependString == "hard") - { - lib.dependType = Library::Hard; - } - else if (dependString == "soft") - { - lib.dependType = Library::Soft; - } - else - { - QLOG_ERROR() << "A '+' library in" << filename - << "contains an invalid depend type"; - return out; - } - } - out.addLibs.append(lib); - } - } - if (root.contains("-libraries")) - { - QJsonValue librariesVal = root.value("-libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename - << "contains a '-libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) - { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - if (!libObj.contains("name")) - { - QLOG_ERROR() << filename << "contains a library without a name"; - return out; - } - if (!libObj.value("name").isString()) - { - QLOG_ERROR() << filename - << "contains a library without a valid 'name' field"; - return out; - } - out.removeLibs.append(libObj.value("name").toString()); - } - } - - isError = false; - return out; - } - - static std::shared_ptr createLibrary(const Library &lib) - { - std::shared_ptr out(new OneSixLibrary(lib.name)); - if (!lib.url.isEmpty()) - { - out->setBaseUrl(lib.url); - } - out->setHint(lib.hint); - if (!lib.absoluteUrl.isEmpty()) - { - out->setAbsoluteUrl(lib.absoluteUrl); - } - out->setAbsoluteUrl(lib.absoluteUrl); - out->extract_excludes = lib.excludes; - for (auto native : lib.natives) - { - out->addNative(native.first, native.second); - } - out->setRules(lib.rules); - out->finalize(); - return out; - } - int findLibrary(QList> haystack, const QString &needle) - { - for (int i = 0; i < haystack.size(); ++i) - { - if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix) - .indexIn(haystack.at(i)->rawName()) != -1) - { - return i; - } - } - return -1; - } - ApplyError applyTo(OneSixVersion *version) - { - if (minimumLauncherVersion != -1) - { - if (minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION) - { - QLOG_ERROR() << filename << "is for a different launcher version (" - << minimumLauncherVersion << "), current supported is" - << CURRENT_MINIMUM_LAUNCHER_VERSION; - return LauncherVersionError; - } - } - - if (!version->id.isNull() && !mcVersion.isNull()) - { - if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard) - .indexIn(version->id) == -1) - { - QLOG_ERROR() << filename << "is for a different version of Minecraft"; - return OtherError; - } - } - - if (!id.isNull()) - { - version->id = id; - } - if (!mainClass.isNull()) - { - version->mainClass = mainClass; - } - if (!processArguments.isNull()) - { - version->processArguments = processArguments; - } - if (!type.isNull()) - { - version->type = type; - } - if (!releaseTime.isNull()) - { - version->releaseTime = releaseTime; - } - if (!time.isNull()) - { - version->time = time; - } - if (!assets.isNull()) - { - version->assets = assets; - } - if (minimumLauncherVersion >= 0) - { - version->minimumLauncherVersion = minimumLauncherVersion; - } - if (!overwriteMinecraftArguments.isNull()) - { - version->minecraftArguments = overwriteMinecraftArguments; - } - if (!addMinecraftArguments.isNull()) - { - version->minecraftArguments += addMinecraftArguments; - } - if (!removeMinecraftArguments.isNull()) - { - version->minecraftArguments.remove(removeMinecraftArguments); - } - if (shouldOverwriteTweakers) - { - version->tweakers = overwriteTweakers; - } - for (auto tweaker : addTweakers) - { - version->tweakers += tweaker; - } - for (auto tweaker : removeTweakers) - { - version->tweakers.removeAll(tweaker); - } - if (shouldOverwriteLibs) - { - version->libraries.clear(); - for (auto lib : overwriteLibs) - { - version->libraries.append(createLibrary(lib)); - } - } - for (auto lib : addLibs) - { - switch (lib.insertType) - { - case Library::Apply: - { - - int index = findLibrary(version->libraries, lib.name); - if (index >= 0) - { - auto library = version->libraries[index]; - if (!lib.url.isNull()) - { - library->setBaseUrl(lib.url); - } - if (!lib.hint.isNull()) - { - library->setHint(lib.hint); - } - if (!lib.absoluteUrl.isNull()) - { - library->setAbsoluteUrl(lib.absoluteUrl); - } - if (lib.applyExcludes) - { - library->extract_excludes = lib.excludes; - } - if (lib.applyNatives) - { - library->clearSuffixes(); - for (auto native : lib.natives) - { - library->addNative(native.first, native.second); - } - } - if (lib.applyRules) - { - library->setRules(lib.rules); - } - library->finalize(); - } - else - { - QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; - } - break; - } - case Library::Append: - case Library::Prepend: - { - - const int startOfVersion = lib.name.lastIndexOf(':') + 1; - const int index = - findLibrary(version->libraries, - QString(lib.name).replace(startOfVersion, INT_MAX, '*')); - if (index < 0) - { - if (lib.insertType == Library::Append) - { - version->libraries.append(createLibrary(lib)); - } - else - { - version->libraries.prepend(createLibrary(lib)); - } - } - else - { - auto otherLib = version->libraries.at(index); - const Util::Version ourVersion = lib.name.mid(startOfVersion, INT_MAX); - const Util::Version otherVersion = otherLib->version(); - // if the existing version is a hard dependency we can either use it or - // fail, but we can't change it - if (otherLib->dependType == OneSixLibrary::Hard) - { - // we need a higher version, or we're hard to and the versions aren't - // equal - if (ourVersion > otherVersion || - (lib.dependType == Library::Hard && ourVersion != otherVersion)) - { - QLOG_ERROR() << "Error resolving library dependencies between" - << otherLib->rawName() << "and" << lib.name << "in" - << filename; - return OtherError; - } - else - { - // the library is already existing, so we don't have to do anything - } - } - else if (otherLib->dependType == OneSixLibrary::Soft) - { - // if we are higher it means we should update - if (ourVersion > otherVersion) - { - auto library = createLibrary(lib); - if (Util::Version(otherLib->minVersion) < ourVersion) - { - library->minVersion = ourVersion.toString(); - } - version->libraries.replace(index, library); - } - else - { - // our version is smaller than the existing version, but we require - // it: fail - if (lib.dependType == Library::Hard) - { - QLOG_ERROR() << "Error resolving library dependencies between" - << otherLib->rawName() << "and" << lib.name << "in" - << filename; - return OtherError; - } - } - } - } - break; - } - case Library::Replace: - { - int index = findLibrary(version->libraries, lib.insertData); - if (index >= 0) - { - version->libraries.replace(index, createLibrary(lib)); - } - else - { - QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; - } - break; - } - } - } - for (auto lib : removeLibs) - { - int index = findLibrary(version->libraries, lib); - if (index >= 0) - { - version->libraries.removeAt(index); - } - else - { - QLOG_WARN() << "Couldn't find" << lib << "(skipping)"; - } - } - - OneSixVersion::VersionFile versionFile; - versionFile.name = name; - versionFile.id = fileId; - versionFile.version = this->version; - versionFile.mcVersion = mcVersion; - versionFile.filename = filename; - versionFile.order = order; - version->versionFiles.append(versionFile); - - return NoApplyError; - } -}; - OneSixVersionBuilder::OneSixVersionBuilder() { } -bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance, +bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external) { OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = instance; builder.m_widgetParent = widgetParent; - return builder.build(onlyVanilla, external); + return builder.buildInternal(onlyVanilla, external); } -bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj) +bool OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj) { OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = 0; builder.m_widgetParent = 0; - return builder.read(obj); + return builder.readJsonAndApply(obj); } -bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &external) +bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringList &external) { m_version->clear(); @@ -837,8 +68,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &exte { QLOG_INFO() << "Reading" << fileName; VersionFile file; - ParseFlags flags = fileName.endsWith("pack.json") ? IsFTBPackJson : NoFlags; - if (!read(QFileInfo(fileName), false, &file, flags)) + if (!parseJsonFile(QFileInfo(fileName), false, &file, fileName.endsWith("pack.json") ? IsFTBPackJson : NoFlags)) { return false; } @@ -856,7 +86,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &exte { QLOG_INFO() << "Reading custom.json"; VersionFile file; - if (!read(QFileInfo(root.absoluteFilePath("custom.json")), false, &file)) + if (!parseJsonFile(QFileInfo(root.absoluteFilePath("custom.json")), false, &file)) { return false; } @@ -876,7 +106,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &exte // version.json QLOG_INFO() << "Reading version.json"; VersionFile file; - if (!read(QFileInfo(root.absoluteFilePath("version.json")), false, &file)) + if (!parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false, &file)) { return false; } @@ -907,7 +137,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &exte { QLOG_INFO() << "Reading" << info.fileName(); VersionFile file; - if (!read(info, true, &file)) + if (!parseJsonFile(info, true, &file)) { return false; } @@ -968,7 +198,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &exte return true; } -bool OneSixVersionBuilder::read(const QJsonObject &obj) +bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) { m_version->clear(); @@ -1000,7 +230,7 @@ bool OneSixVersionBuilder::read(const QJsonObject &obj) return true; } -bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, const bool requireOrder, +bool OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, const ParseFlags flags) { QFile file(fileInfo.absoluteFilePath()); @@ -1072,6 +302,7 @@ QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *inst } return out; } + bool OneSixVersionBuilder::writeOverrideOrders(const QMap &order, OneSixInstance *instance) { diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index 8cf6f32f..8ca2551a 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -18,7 +18,7 @@ #include #include -class OneSixVersion; +class VersionFinal; class OneSixInstance; class QWidget; class QJsonObject; @@ -29,8 +29,9 @@ class OneSixVersionBuilder { OneSixVersionBuilder(); public: - static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external); - static bool read(OneSixVersion *version, const QJsonObject &obj); + static bool build(VersionFinal *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external); + static bool readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj); + static QMap readOverrideOrders(OneSixInstance *instance); static bool writeOverrideOrders(const QMap &order, OneSixInstance *instance); @@ -42,14 +43,14 @@ public: Q_DECLARE_FLAGS(ParseFlags, ParseFlag) private: - OneSixVersion *m_version; + VersionFinal *m_version; OneSixInstance *m_instance; QWidget *m_widgetParent; - bool build(const bool onlyVanilla, const QStringList &external); - bool read(const QJsonObject &obj); + bool buildInternal(const bool onlyVanilla, const QStringList &external); + bool readJsonAndApply(const QJsonObject &obj); - bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, const ParseFlags flags = NoFlags); + bool parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, const ParseFlags flags = NoFlags); }; Q_DECLARE_OPERATORS_FOR_FLAGS(OneSixVersionBuilder::ParseFlags) diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp new file mode 100644 index 00000000..76cf9279 --- /dev/null +++ b/logic/VersionFile.cpp @@ -0,0 +1,702 @@ +#include +#include + +#include + +#include "logger/QsLog.h" +#include "logic/VersionFile.h" +#include "logic/OneSixLibrary.h" +#include "logic/VersionFinal.h" + + +#define CURRENT_MINIMUM_LAUNCHER_VERSION 14 + +VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, + const QString &filename, bool &isError) +{ + isError = true; + Library out; + if (!libObj.contains("name")) + { + QLOG_ERROR() << filename << "contains a library that doesn't have a 'name' field"; + return out; + } + out.name = libObj.value("name").toString(); + + auto readString = [libObj, filename](const QString & key, QString & variable) + { + if (libObj.contains(key)) + { + QJsonValue val = libObj.value(key); + if (!val.isString()) + { + QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; + } + else + { + variable = val.toString(); + } + } + }; + + readString("url", out.url); + readString("MMC-hint", out.hint); + readString("MMC-absulute_url", out.absoluteUrl); + readString("MMC-absoluteUrl", out.absoluteUrl); + if (libObj.contains("extract")) + { + if (!libObj.value("extract").isObject()) + { + QLOG_ERROR() << filename + << "contains a library with an 'extract' field that's not an object"; + return out; + } + QJsonObject extractObj = libObj.value("extract").toObject(); + if (!extractObj.contains("exclude") || !extractObj.value("exclude").isArray()) + { + QLOG_ERROR() << filename << "contains a library with an invalid 'extract' field"; + return out; + } + out.applyExcludes = true; + QJsonArray excludeArray = extractObj.value("exclude").toArray(); + for (auto excludeVal : excludeArray) + { + if (!excludeVal.isString()) + { + QLOG_WARN() << filename << "contains a library that contains an 'extract' " + "field that contains an invalid 'exclude' entry " + "(skipping)"; + } + else + { + out.excludes.append(excludeVal.toString()); + } + } + } + if (libObj.contains("natives")) + { + if (!libObj.value("natives").isObject()) + { + QLOG_ERROR() << filename + << "contains a library with a 'natives' field that's not an object"; + return out; + } + out.applyNatives = true; + QJsonObject nativesObj = libObj.value("natives").toObject(); + for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) + { + if (!it.value().isString()) + { + QLOG_WARN() << filename << "contains an invalid native (skipping)"; + } + OpSys opSys = OpSys_fromString(it.key()); + if (opSys != Os_Other) + { + out.natives.append(qMakePair(opSys, it.value().toString())); + } + } + } + if (libObj.contains("rules")) + { + out.applyRules = true; + out.rules = rulesFromJsonV4(libObj); + } + isError = false; + return out; +} + +VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, + const bool requireOrder, bool &isError, const bool isFTB) +{ + VersionFile out; + isError = true; + if (doc.isEmpty() || doc.isNull()) + { + QLOG_ERROR() << filename << "is empty or null"; + return out; + } + if (!doc.isObject()) + { + QLOG_ERROR() << "The root of" << filename << "is not an object"; + return out; + } + + QJsonObject root = doc.object(); + + if (requireOrder) + { + if (root.contains("order")) + { + if (root.value("order").isDouble()) + { + out.order = root.value("order").toDouble(); + } + else + { + QLOG_ERROR() << "'order' field contains an invalid value in" << filename; + return out; + } + } + else + { + QLOG_ERROR() << filename << "doesn't contain an order field"; + } + } + + out.name = root.value("name").toString(); + out.fileId = root.value("fileId").toString(); + out.version = root.value("version").toString(); + out.mcVersion = root.value("mcVersion").toString(); + out.filename = filename; + + auto readString = [root, filename](const QString & key, QString & variable) + { + if (root.contains(key)) + { + QJsonValue val = root.value(key); + if (!val.isString()) + { + QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; + } + else + { + variable = val.toString(); + } + } + }; + + // FTB id attribute is completely bogus. We ignore it. + if (!isFTB) + { + readString("id", out.id); + } + + readString("mainClass", out.mainClass); + readString("processArguments", out.processArguments); + readString("minecraftArguments", out.overwriteMinecraftArguments); + readString("+minecraftArguments", out.addMinecraftArguments); + readString("-minecraftArguments", out.removeMinecraftArguments); + readString("type", out.type); + readString("releaseTime", out.releaseTime); + readString("time", out.time); + readString("assets", out.assets); + if (root.contains("minimumLauncherVersion")) + { + QJsonValue val = root.value("minimumLauncherVersion"); + if (!val.isDouble()) + { + QLOG_WARN() << "minimumLauncherVersion is not an int in" << filename + << "(skipping)"; + } + else + { + out.minimumLauncherVersion = val.toDouble(); + } + } + + if (root.contains("tweakers")) + { + QJsonValue tweakersVal = root.value("tweakers"); + if (!tweakersVal.isArray()) + { + QLOG_ERROR() << filename << "contains a 'tweakers' field, but it's not an array"; + return out; + } + out.shouldOverwriteTweakers = true; + QJsonArray tweakers = root.value("tweakers").toArray(); + for (auto tweakerVal : tweakers) + { + if (!tweakerVal.isString()) + { + QLOG_ERROR() << filename + << "contains a 'tweakers' field entry that's not a string"; + return out; + } + out.overwriteTweakers.append(tweakerVal.toString()); + } + } + if (root.contains("+tweakers")) + { + QJsonValue tweakersVal = root.value("+tweakers"); + if (!tweakersVal.isArray()) + { + QLOG_ERROR() << filename << "contains a '+tweakers' field, but it's not an array"; + return out; + } + QJsonArray tweakers = root.value("+tweakers").toArray(); + for (auto tweakerVal : tweakers) + { + if (!tweakerVal.isString()) + { + QLOG_ERROR() << filename + << "contains a '+tweakers' field entry that's not a string"; + return out; + } + out.addTweakers.append(tweakerVal.toString()); + } + } + if (root.contains("-tweakers")) + { + QJsonValue tweakersVal = root.value("-tweakers"); + if (!tweakersVal.isArray()) + { + QLOG_ERROR() << filename << "contains a '-tweakers' field, but it's not an array"; + return out; + } + out.shouldOverwriteTweakers = true; + QJsonArray tweakers = root.value("-tweakers").toArray(); + for (auto tweakerVal : tweakers) + { + if (!tweakerVal.isString()) + { + QLOG_ERROR() << filename + << "contains a '-tweakers' field entry that's not a string"; + return out; + } + out.removeTweakers.append(tweakerVal.toString()); + } + } + + if (root.contains("libraries")) + { + out.shouldOverwriteLibs = !isFTB; + QJsonValue librariesVal = root.value("libraries"); + if (!librariesVal.isArray()) + { + QLOG_ERROR() << filename << "contains a 'libraries' field, but its not an array"; + return out; + } + QJsonArray librariesArray = librariesVal.toArray(); + for (auto libVal : librariesArray) + { + if (!libVal.isObject()) + { + QLOG_ERROR() << filename << "contains a library that's not an object"; + return out; + } + QJsonObject libObj = libVal.toObject(); + bool error; + Library lib = Library::fromJson(libObj, filename, error); + if (error) + { + QLOG_ERROR() << "Error while reading a library entry in" << filename; + return out; + } + if (isFTB) + { + lib.hint = "local"; + lib.insertType = Library::Prepend; + out.addLibs.prepend(lib); + } + else + { + out.overwriteLibs.append(lib); + } + } + } + if (root.contains("+libraries")) + { + QJsonValue librariesVal = root.value("+libraries"); + if (!librariesVal.isArray()) + { + QLOG_ERROR() << filename << "contains a '+libraries' field, but its not an array"; + return out; + } + QJsonArray librariesArray = librariesVal.toArray(); + for (auto libVal : librariesArray) + { + if (!libVal.isObject()) + { + QLOG_ERROR() << filename << "contains a library that's not an object"; + return out; + } + QJsonObject libObj = libVal.toObject(); + bool error; + Library lib = Library::fromJson(libObj, filename, error); + if (error) + { + QLOG_ERROR() << "Error while reading a library entry in" << filename; + return out; + } + if (!libObj.contains("insert")) + { + QLOG_ERROR() << "Missing 'insert' field in '+libraries' field in" << filename; + return out; + } + QJsonValue insertVal = libObj.value("insert"); + QString insertString; + { + if (insertVal.isString()) + { + insertString = insertVal.toString(); + } + else if (insertVal.isObject()) + { + QJsonObject insertObj = insertVal.toObject(); + if (insertObj.isEmpty()) + { + QLOG_ERROR() << "One library has an empty insert object in" << filename; + return out; + } + insertString = insertObj.keys().first(); + lib.insertData = insertObj.value(insertString).toString(); + } + } + if (insertString == "apply") + { + lib.insertType = Library::Apply; + } + else if (insertString == "prepend") + { + lib.insertType = Library::Prepend; + } + else if (insertString == "append") + { + lib.insertType = Library::Prepend; + } + else if (insertString == "replace") + { + lib.insertType = Library::Replace; + } + else + { + QLOG_ERROR() << "A '+' library in" << filename + << "contains an invalid insert type"; + return out; + } + if (libObj.contains("MMC-depend") && libObj.value("MMC-depend").isString()) + { + const QString dependString = libObj.value("MMC-depend").toString(); + if (dependString == "hard") + { + lib.dependType = Library::Hard; + } + else if (dependString == "soft") + { + lib.dependType = Library::Soft; + } + else + { + QLOG_ERROR() << "A '+' library in" << filename + << "contains an invalid depend type"; + return out; + } + } + out.addLibs.append(lib); + } + } + if (root.contains("-libraries")) + { + QJsonValue librariesVal = root.value("-libraries"); + if (!librariesVal.isArray()) + { + QLOG_ERROR() << filename << "contains a '-libraries' field, but its not an array"; + return out; + } + QJsonArray librariesArray = librariesVal.toArray(); + for (auto libVal : librariesArray) + { + if (!libVal.isObject()) + { + QLOG_ERROR() << filename << "contains a library that's not an object"; + return out; + } + QJsonObject libObj = libVal.toObject(); + if (!libObj.contains("name")) + { + QLOG_ERROR() << filename << "contains a library without a name"; + return out; + } + if (!libObj.value("name").isString()) + { + QLOG_ERROR() << filename << "contains a library without a valid 'name' field"; + return out; + } + out.removeLibs.append(libObj.value("name").toString()); + } + } + + isError = false; + return out; +} + +std::shared_ptr VersionFile::createLibrary(const VersionFile::Library &lib) +{ + std::shared_ptr out(new OneSixLibrary(lib.name)); + if (!lib.url.isEmpty()) + { + out->setBaseUrl(lib.url); + } + out->setHint(lib.hint); + if (!lib.absoluteUrl.isEmpty()) + { + out->setAbsoluteUrl(lib.absoluteUrl); + } + out->setAbsoluteUrl(lib.absoluteUrl); + out->extract_excludes = lib.excludes; + for (auto native : lib.natives) + { + out->addNative(native.first, native.second); + } + out->setRules(lib.rules); + out->finalize(); + return out; +} + +int VersionFile::findLibrary(QList> haystack, + const QString &needle) +{ + for (int i = 0; i < haystack.size(); ++i) + { + if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix) + .indexIn(haystack.at(i)->rawName()) != -1) + { + return i; + } + } + return -1; +} + +VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) +{ + if (minimumLauncherVersion != -1) + { + if (minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION) + { + QLOG_ERROR() << filename << "is for a different launcher version (" + << minimumLauncherVersion << "), current supported is" + << CURRENT_MINIMUM_LAUNCHER_VERSION; + return LauncherVersionError; + } + } + + if (!version->id.isNull() && !mcVersion.isNull()) + { + if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(version->id) == + -1) + { + QLOG_ERROR() << filename << "is for a different version of Minecraft"; + return OtherError; + } + } + + if (!id.isNull()) + { + version->id = id; + } + if (!mainClass.isNull()) + { + version->mainClass = mainClass; + } + if (!processArguments.isNull()) + { + version->processArguments = processArguments; + } + if (!type.isNull()) + { + version->type = type; + } + if (!releaseTime.isNull()) + { + version->releaseTime = releaseTime; + } + if (!time.isNull()) + { + version->time = time; + } + if (!assets.isNull()) + { + version->assets = assets; + } + if (minimumLauncherVersion >= 0) + { + version->minimumLauncherVersion = minimumLauncherVersion; + } + if (!overwriteMinecraftArguments.isNull()) + { + version->minecraftArguments = overwriteMinecraftArguments; + } + if (!addMinecraftArguments.isNull()) + { + version->minecraftArguments += addMinecraftArguments; + } + if (!removeMinecraftArguments.isNull()) + { + version->minecraftArguments.remove(removeMinecraftArguments); + } + if (shouldOverwriteTweakers) + { + version->tweakers = overwriteTweakers; + } + for (auto tweaker : addTweakers) + { + version->tweakers += tweaker; + } + for (auto tweaker : removeTweakers) + { + version->tweakers.removeAll(tweaker); + } + if (shouldOverwriteLibs) + { + version->libraries.clear(); + for (auto lib : overwriteLibs) + { + version->libraries.append(createLibrary(lib)); + } + } + for (auto lib : addLibs) + { + switch (lib.insertType) + { + case Library::Apply: + { + + int index = findLibrary(version->libraries, lib.name); + if (index >= 0) + { + auto library = version->libraries[index]; + if (!lib.url.isNull()) + { + library->setBaseUrl(lib.url); + } + if (!lib.hint.isNull()) + { + library->setHint(lib.hint); + } + if (!lib.absoluteUrl.isNull()) + { + library->setAbsoluteUrl(lib.absoluteUrl); + } + if (lib.applyExcludes) + { + library->extract_excludes = lib.excludes; + } + if (lib.applyNatives) + { + library->clearSuffixes(); + for (auto native : lib.natives) + { + library->addNative(native.first, native.second); + } + } + if (lib.applyRules) + { + library->setRules(lib.rules); + } + library->finalize(); + } + else + { + QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; + } + break; + } + case Library::Append: + case Library::Prepend: + { + + const int startOfVersion = lib.name.lastIndexOf(':') + 1; + const int index = findLibrary( + version->libraries, QString(lib.name).replace(startOfVersion, INT_MAX, '*')); + if (index < 0) + { + if (lib.insertType == Library::Append) + { + version->libraries.append(createLibrary(lib)); + } + else + { + version->libraries.prepend(createLibrary(lib)); + } + } + else + { + auto otherLib = version->libraries.at(index); + const Util::Version ourVersion = lib.name.mid(startOfVersion, INT_MAX); + const Util::Version otherVersion = otherLib->version(); + // if the existing version is a hard dependency we can either use it or + // fail, but we can't change it + if (otherLib->dependType == OneSixLibrary::Hard) + { + // we need a higher version, or we're hard to and the versions aren't + // equal + if (ourVersion > otherVersion || + (lib.dependType == Library::Hard && ourVersion != otherVersion)) + { + QLOG_ERROR() << "Error resolving library dependencies between" + << otherLib->rawName() << "and" << lib.name << "in" + << filename; + return OtherError; + } + else + { + // the library is already existing, so we don't have to do anything + } + } + else if (otherLib->dependType == OneSixLibrary::Soft) + { + // if we are higher it means we should update + if (ourVersion > otherVersion) + { + auto library = createLibrary(lib); + if (Util::Version(otherLib->minVersion) < ourVersion) + { + library->minVersion = ourVersion.toString(); + } + version->libraries.replace(index, library); + } + else + { + // our version is smaller than the existing version, but we require + // it: fail + if (lib.dependType == Library::Hard) + { + QLOG_ERROR() << "Error resolving library dependencies between" + << otherLib->rawName() << "and" << lib.name << "in" + << filename; + return OtherError; + } + } + } + } + break; + } + case Library::Replace: + { + int index = findLibrary(version->libraries, lib.insertData); + if (index >= 0) + { + version->libraries.replace(index, createLibrary(lib)); + } + else + { + QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; + } + break; + } + } + } + for (auto lib : removeLibs) + { + int index = findLibrary(version->libraries, lib); + if (index >= 0) + { + version->libraries.removeAt(index); + } + else + { + QLOG_WARN() << "Couldn't find" << lib << "(skipping)"; + } + } + + VersionFinal::VersionFile versionFile; + versionFile.name = name; + versionFile.id = fileId; + versionFile.version = this->version; + versionFile.mcVersion = mcVersion; + versionFile.filename = filename; + versionFile.order = order; + version->versionFiles.append(versionFile); + + return NoApplyError; +} diff --git a/logic/VersionFile.h b/logic/VersionFile.h new file mode 100644 index 00000000..04694999 --- /dev/null +++ b/logic/VersionFile.h @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include "logic/OpSys.h" +#include "logic/OneSixRule.h" +class VersionFinal; + +struct VersionFile +{ + int order; + QString name; + QString fileId; + QString version; + // TODO use the mcVersion to determine if a version file should be removed on update + QString mcVersion; + QString filename; + // TODO requirements + // QMap requirements; + QString id; + QString mainClass; + QString overwriteMinecraftArguments; + QString addMinecraftArguments; + QString removeMinecraftArguments; + QString processArguments; + QString type; + QString releaseTime; + QString time; + QString assets; + int minimumLauncherVersion = -1; + + bool shouldOverwriteTweakers = false; + QStringList overwriteTweakers; + QStringList addTweakers; + QStringList removeTweakers; + + struct Library + { + QString name; + QString url; + QString hint; + QString absoluteUrl; + bool applyExcludes = false; + QStringList excludes; + bool applyNatives = false; + QList> natives; + bool applyRules = false; + QList> rules; + + // user for '+' libraries + enum InsertType + { + Apply, + Append, + Prepend, + Replace + }; + InsertType insertType = Append; + QString insertData; + enum DependType + { + Soft, + Hard + }; + DependType dependType = Soft; + + static Library fromJson(const QJsonObject &libObj, const QString &filename, + bool &isError); + }; + bool shouldOverwriteLibs = false; + QList overwriteLibs; + QList addLibs; + QList removeLibs; + + enum ApplyError + { + LauncherVersionError, + OtherError, + NoApplyError + }; + + static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, + const bool requireOrder, bool &isError, + const bool isFTB = false); + + static std::shared_ptr createLibrary(const Library &lib); + int findLibrary(QList> haystack, const QString &needle); + ApplyError applyTo(VersionFinal *version); +}; \ No newline at end of file diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp new file mode 100644 index 00000000..ce78e8e3 --- /dev/null +++ b/logic/VersionFinal.cpp @@ -0,0 +1,221 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "VersionFinal.h" + +#include +#include + +#include "OneSixVersionBuilder.h" + +VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) + : QAbstractListModel(parent), m_instance(instance) +{ + clear(); +} + +bool VersionFinal::reload(QWidget *widgetParent, const bool onlyVanilla, const QStringList &external) +{ + beginResetModel(); + bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla, external); + endResetModel(); + return ret; +} + +void VersionFinal::clear() +{ + beginResetModel(); + id.clear(); + time.clear(); + releaseTime.clear(); + type.clear(); + assets.clear(); + processArguments.clear(); + minecraftArguments.clear(); + minimumLauncherVersion = 0xDEADBEAF; + mainClass.clear(); + libraries.clear(); + tweakers.clear(); + versionFiles.clear(); + endResetModel(); +} + +void VersionFinal::dump() const +{ + qDebug().nospace() << "VersionFinal(" + << "\n\tid=" << id + << "\n\ttime=" << time + << "\n\treleaseTime=" << releaseTime + << "\n\ttype=" << type + << "\n\tassets=" << assets + << "\n\tprocessArguments=" << processArguments + << "\n\tminecraftArguments=" << minecraftArguments + << "\n\tminimumLauncherVersion=" << minimumLauncherVersion + << "\n\tmainClass=" << mainClass + << "\n\tlibraries="; + for (auto lib : libraries) + { + qDebug().nospace() << "\n\t\t" << lib.get(); + } + qDebug().nospace() << "\n)"; +} + +bool VersionFinal::canRemove(const int index) const +{ + if (index < versionFiles.size()) + { + return versionFiles.at(index).id != "org.multimc.version.json"; + } + return false; +} + +QString VersionFinal::versionFileId(const int index) const +{ + if (index < 0 || index >= versionFiles.size()) + { + return QString(); + } + return versionFiles.at(index).id; +} + +bool VersionFinal::remove(const int index) +{ + if (canRemove(index)) + { + return QFile::remove(versionFiles.at(index).filename); + } + return false; +} + +QList > VersionFinal::getActiveNormalLibs() +{ + QList > output; + for (auto lib : libraries) + { + if (lib->isActive() && !lib->isNative()) + { + output.append(lib); + } + } + return output; +} + +QList > VersionFinal::getActiveNativeLibs() +{ + QList > output; + for (auto lib : libraries) + { + if (lib->isActive() && lib->isNative()) + { + output.append(lib); + } + } + return output; +} + +std::shared_ptr VersionFinal::fromJson(const QJsonObject &obj) +{ + std::shared_ptr version(new VersionFinal(0)); + if (OneSixVersionBuilder::readJsonAndApplyToVersion(version.get(), obj)) + { + return version; + } + return 0; +} + +QVariant VersionFinal::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + int row = index.row(); + int column = index.column(); + + if (row < 0 || row >= versionFiles.size()) + return QVariant(); + + if (role == Qt::DisplayRole) + { + switch (column) + { + case 0: + return versionFiles.at(row).name; + case 1: + return versionFiles.at(row).version; + default: + return QVariant(); + } + } + return QVariant(); +} + +QVariant VersionFinal::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal) + { + if (role == Qt::DisplayRole) + { + switch (section) + { + case 0: + return tr("Name"); + case 1: + return tr("Version"); + default: + return QVariant(); + } + } + } + return QVariant(); +} + +Qt::ItemFlags VersionFinal::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; +} + +int VersionFinal::rowCount(const QModelIndex &parent) const +{ + return versionFiles.size(); +} + +int VersionFinal::columnCount(const QModelIndex &parent) const +{ + return 2; +} + +QDebug operator<<(QDebug &dbg, const VersionFinal *version) +{ + version->dump(); + return dbg.maybeSpace(); +} +QDebug operator<<(QDebug &dbg, const OneSixLibrary *library) +{ + dbg.nospace() << "OneSixLibrary(" + << "\n\t\t\trawName=" << library->rawName() + << "\n\t\t\tname=" << library->name() + << "\n\t\t\tversion=" << library->version() + << "\n\t\t\ttype=" << library->type() + << "\n\t\t\tisActive=" << library->isActive() + << "\n\t\t\tisNative=" << library->isNative() + << "\n\t\t\tdownloadUrl=" << library->downloadUrl() + << "\n\t\t\tstoragePath=" << library->storagePath() + << "\n\t\t\tabsolutePath=" << library->absoluteUrl() + << "\n\t\t\thint=" << library->hint(); + dbg.nospace() << "\n\t\t)"; + return dbg.maybeSpace(); +} diff --git a/logic/VersionFinal.h b/logic/VersionFinal.h new file mode 100644 index 00000000..c9a5f469 --- /dev/null +++ b/logic/VersionFinal.h @@ -0,0 +1,137 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include +#include +#include + +#include "OneSixLibrary.h" + +class OneSixInstance; + +class VersionFinal : public QAbstractListModel +{ + Q_OBJECT +public: + explicit VersionFinal(OneSixInstance *instance, QObject *parent = 0); + + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual int columnCount(const QModelIndex &parent) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + bool reload(QWidget *widgetParent, const bool onlyVanilla = false, const QStringList &external = QStringList()); + void clear(); + + void dump() const; + + bool canRemove(const int index) const; + + QString versionFileId(const int index) const; + +public +slots: + bool remove(const int index); + +public: + QList> getActiveNormalLibs(); + QList> getActiveNativeLibs(); + + static std::shared_ptr fromJson(const QJsonObject &obj); + + // data members +public: + /// the ID - determines which jar to use! ACTUALLY IMPORTANT! + QString id; + /// Last updated time - as a string + QString time; + /// Release time - as a string + QString releaseTime; + /// Release type - "release" or "snapshot" + QString type; + /// Assets type - "legacy" or a version ID + QString assets; + /** + * DEPRECATED: Old versions of the new vanilla launcher used this + * ex: "username_session_version" + */ + QString processArguments; + /** + * arguments that should be used for launching minecraft + * + * ex: "--username ${auth_player_name} --session ${auth_session} + * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" + */ + QString minecraftArguments; + /** + * the minimum launcher version required by this version ... current is 4 (at point of + * writing) + */ + int minimumLauncherVersion = 0xDEADBEEF; + /** + * A list of all tweaker classes + */ + QStringList tweakers; + /** + * The main class to load first + */ + QString mainClass; + + /// the list of libs - both active and inactive, native and java + QList> libraries; + + /* + FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. + + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx", + "version": "^10\\.5\\.\\d$" + } + } + ], + "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX + 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" + } + */ + // QList rules; + + struct VersionFile + { + QString name; + QString id; + QString version; + QString mcVersion; + QString filename; + int order; + }; + QList versionFiles; + +private: + OneSixInstance *m_instance; +}; + +QDebug operator<<(QDebug &dbg, const VersionFinal *version); +QDebug operator<<(QDebug &dbg, const OneSixLibrary *library); -- cgit v1.2.3 From 053b938beb7bb47fc63ec1ec2df519573629e32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 2 Mar 2014 01:51:40 +0100 Subject: Get rid of parse flags --- logic/OneSixVersionBuilder.cpp | 8 +++----- logic/OneSixVersionBuilder.h | 11 +---------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 0d4d66a2..2b05e45a 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -68,7 +68,7 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi { QLOG_INFO() << "Reading" << fileName; VersionFile file; - if (!parseJsonFile(QFileInfo(fileName), false, &file, fileName.endsWith("pack.json") ? IsFTBPackJson : NoFlags)) + if (!parseJsonFile(QFileInfo(fileName), false, &file, fileName.endsWith("pack.json"))) { return false; } @@ -230,8 +230,7 @@ bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) return true; } -bool OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, - VersionFile *out, const ParseFlags flags) +bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool requireOrder, VersionFile* out, bool isFTB) { QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) @@ -252,14 +251,13 @@ bool OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool r return false; } bool isError = false; - *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, flags); + *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, isFTB); if (isError) { QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.") .arg(file.fileName())); - ; } return true; } diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index 8ca2551a..fe77ed9d 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -35,13 +35,6 @@ public: static QMap readOverrideOrders(OneSixInstance *instance); static bool writeOverrideOrders(const QMap &order, OneSixInstance *instance); - enum ParseFlag - { - NoFlags = 0x0, - IsFTBPackJson = 0x1 - }; - Q_DECLARE_FLAGS(ParseFlags, ParseFlag) - private: VersionFinal *m_version; OneSixInstance *m_instance; @@ -50,7 +43,5 @@ private: bool buildInternal(const bool onlyVanilla, const QStringList &external); bool readJsonAndApply(const QJsonObject &obj); - bool parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, const ParseFlags flags = NoFlags); + bool parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, bool isFTB = false); }; - -Q_DECLARE_OPERATORS_FOR_FLAGS(OneSixVersionBuilder::ParseFlags) -- cgit v1.2.3 From 5a344a293323993eabbe2165d01cbb9a4220201c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 2 Mar 2014 02:08:01 +0100 Subject: Gather and store liteloader metadata. --- MultiMC.cpp | 1 + logic/LiteLoaderInstaller.cpp | 2 +- logic/lists/LiteLoaderVersionList.cpp | 55 ++++++++++++++++++++++++++++------- logic/lists/LiteLoaderVersionList.h | 11 ++++++- 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index a0745a87..ddb264d1 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -457,6 +457,7 @@ void MultiMC::initHttpMetaCache() m_metacache->addBase("versions", QDir("versions").absolutePath()); m_metacache->addBase("libraries", QDir("libraries").absolutePath()); m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath()); + m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath()); m_metacache->addBase("skins", QDir("accounts/skins").absolutePath()); m_metacache->addBase("root", QDir(root()).absolutePath()); m_metacache->Load(); diff --git a/logic/LiteLoaderInstaller.cpp b/logic/LiteLoaderInstaller.cpp index 44400e8a..bb4b07ca 100644 --- a/logic/LiteLoaderInstaller.cpp +++ b/logic/LiteLoaderInstaller.cpp @@ -69,7 +69,7 @@ bool LiteLoaderInstaller::add(OneSixInstance *to) obj.insert("+libraries", libraries); obj.insert("name", QString("LiteLoader")); obj.insert("fileId", id()); - obj.insert("version", to->intendedVersionId()); + obj.insert("version", m_version->version); obj.insert("mcVersion", to->intendedVersionId()); QFile file(filename(to->instanceRoot())); diff --git a/logic/lists/LiteLoaderVersionList.cpp b/logic/lists/LiteLoaderVersionList.cpp index b8cea442..ef95eefd 100644 --- a/logic/lists/LiteLoaderVersionList.cpp +++ b/logic/lists/LiteLoaderVersionList.cpp @@ -92,7 +92,6 @@ void LiteLoaderVersionList::updateListData(QList versions) LLListLoadTask::LLListLoadTask(LiteLoaderVersionList *vlist) { m_list = vlist; - vlistReply = nullptr; } LLListLoadTask::~LLListLoadTask() @@ -102,23 +101,49 @@ LLListLoadTask::~LLListLoadTask() void LLListLoadTask::executeTask() { setStatus(tr("Loading LiteLoader version list...")); - auto worker = MMC->qnam(); - vlistReply = worker->get(QNetworkRequest(QUrl(URLConstants::LITELOADER_URL))); - connect(vlistReply, SIGNAL(finished()), this, SLOT(listDownloaded())); + auto job = new NetJob("Version index"); + // we do not care if the version is stale or not. + auto liteloaderEntry = MMC->metacache()->resolveEntry("liteloader", "versions.json"); + + // verify by poking the server. + liteloaderEntry->stale = true; + + job->addNetAction(listDownload = CacheDownload::make(QUrl(URLConstants::LITELOADER_URL), + liteloaderEntry)); + + connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed())); + + listJob.reset(job); + connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded())); + connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); + listJob->start(); +} + +void LLListLoadTask::listFailed() +{ + emitFailed("Failed to load LiteLoader version list."); + return; } void LLListLoadTask::listDownloaded() { - if (vlistReply->error() != QNetworkReply::NoError) + QByteArray data; { - vlistReply->deleteLater(); - emitFailed("Failed to load LiteLoader version list" + vlistReply->errorString()); - return; + auto dlJob = listDownload; + auto filename = std::dynamic_pointer_cast(dlJob)->getTargetFilepath(); + QFile listFile(filename); + if (!listFile.open(QIODevice::ReadOnly)) + { + emitFailed("Failed to open the LiteLoader version list."); + return; + } + data = listFile.readAll(); + listFile.close(); + dlJob.reset(); } QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(vlistReply->readAll(), &jsonError); - vlistReply->deleteLater(); + QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); if (jsonError.error != QJsonParseError::NoError) { @@ -140,7 +165,12 @@ void LLListLoadTask::listDownloaded() emitFailed("Error parsing version list JSON: missing 'versions' object"); return; } - const QJsonObject versions = root.value("versions").toObject(); + + auto meta = root.value("meta").toObject(); + QString description = meta.value("description").toString(tr("This is a lightweight loader for mods that don't change game mechanics.")); + QString defaultUrl = meta.value("url").toString("http://dl.liteloader.com"); + QString authors = meta.value("authors").toString("Mumfrey"); + auto versions = root.value("versions").toObject(); QList tempList; for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt) @@ -170,6 +200,9 @@ void LLListLoadTask::listDownloaded() version->md5 = artefact.value("md5").toString(); version->timestamp = artefact.value("timestamp").toDouble(); version->tweakClass = artefact.value("tweakClass").toString(); + version->authors = authors; + version->description = description; + version->defaultUrl = defaultUrl; const QJsonArray libs = artefact.value("libraries").toArray(); for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt) { diff --git a/logic/lists/LiteLoaderVersionList.h b/logic/lists/LiteLoaderVersionList.h index 8f761caf..bfc913e5 100644 --- a/logic/lists/LiteLoaderVersionList.h +++ b/logic/lists/LiteLoaderVersionList.h @@ -22,6 +22,7 @@ #include "BaseVersionList.h" #include "logic/tasks/Task.h" #include "logic/BaseVersion.h" +#include class LLListLoadTask; class QNetworkReply; @@ -46,6 +47,7 @@ public: return version; } + // important info QString version; QString file; QString mcVersion; @@ -54,6 +56,11 @@ public: bool isLatest; QString tweakClass; QStringList libraries; + + // meta + QString defaultUrl; + QString description; + QString authors; }; typedef std::shared_ptr LiteLoaderVersionPtr; @@ -96,8 +103,10 @@ public: protected slots: void listDownloaded(); + void listFailed(); protected: - QNetworkReply *vlistReply; + NetJobPtr listJob; + CacheDownloadPtr listDownload; LiteLoaderVersionList *m_list; }; -- cgit v1.2.3 From 80d146866c8c5f00c6d790b476a774def71010bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 2 Mar 2014 02:17:55 +0100 Subject: Remove widgets from logic. --- gui/dialogs/OneSixModEditDialog.cpp | 18 +++++++++--------- logic/OneSixInstance.cpp | 6 +++--- logic/OneSixInstance.h | 2 +- logic/OneSixVersionBuilder.cpp | 21 +++++++++++++++++---- logic/OneSixVersionBuilder.h | 4 +--- logic/VersionFinal.cpp | 4 ++-- logic/VersionFinal.h | 2 +- 7 files changed, 34 insertions(+), 23 deletions(-) diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index 67210217..d936f3f1 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -124,7 +124,7 @@ void OneSixModEditDialog::disableVersionControls() void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() { - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } void OneSixModEditDialog::on_removeLibraryBtn_clicked() @@ -137,7 +137,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() } else { - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } } } @@ -145,7 +145,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked() { QDir(m_inst->instanceRoot()).remove("order.json"); - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() { @@ -181,7 +181,7 @@ void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() } else { - m_inst->reloadVersion(this); + m_inst->reloadVersion(); ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent); } } @@ -218,7 +218,7 @@ void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() } else { - m_inst->reloadVersion(this); + m_inst->reloadVersion(); ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent); } } @@ -232,7 +232,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked() return; } QDir(m_inst->instanceRoot()).remove("custom.json"); - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); vselect.setFilter(1, m_inst->currentVersionId()); @@ -277,7 +277,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked() } } } - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } void OneSixModEditDialog::on_liteloaderBtn_clicked() @@ -289,7 +289,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked() return; } QDir(m_inst->instanceRoot()).remove("custom.json"); - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), this); vselect.setFilter(1, m_inst->currentVersionId()); @@ -310,7 +310,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked() } else { - m_inst->reloadVersion(this); + m_inst->reloadVersion(); } } } diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index bd5d559e..0e0be4d8 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -316,14 +316,14 @@ QString OneSixInstance::currentVersionId() const return intendedVersionId(); } -bool OneSixInstance::reloadVersion(QWidget *widgetParent) +bool OneSixInstance::reloadVersion() { I_D(OneSixInstance); - bool ret = d->version->reload(widgetParent, false, externalPatches()); + bool ret = d->version->reload(false, externalPatches()); if (ret) { - ret = d->vanillaVersion->reload(widgetParent, true, externalPatches()); + ret = d->vanillaVersion->reload(true, externalPatches()); } if (ret) { diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 75edec1e..c7ef2ee8 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -54,7 +54,7 @@ public: virtual QDialog *createModEditDialog(QWidget *parent) override; /// reload the full version json files. return true on success! - bool reloadVersion(QWidget *widgetParent = 0); + bool reloadVersion(); /// clears all version information in preparation for an update void clearVersion(); /// get the current full version info diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 2b05e45a..98e4b54e 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -37,13 +37,11 @@ OneSixVersionBuilder::OneSixVersionBuilder() { } -bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, - QWidget *widgetParent, const bool onlyVanilla, const QStringList &external) +bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external) { OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = instance; - builder.m_widgetParent = widgetParent; return builder.buildInternal(onlyVanilla, external); } @@ -52,7 +50,6 @@ bool OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, cons OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = 0; - builder.m_widgetParent = 0; return builder.readJsonAndApply(obj); } @@ -117,11 +114,13 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi auto error = file.applyTo(m_version); if (error != VersionFile::NoApplyError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr( "Error while applying %1. Please check MultiMC-0.log for more info.") .arg(root.absoluteFilePath("version.json"))); + */ return false; } @@ -159,10 +158,12 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi auto error = filePair.second.applyTo(m_version); if (error != VersionFile::NoApplyError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Error while applying %1. Please check MultiMC-0.log " "for more info.").arg(filePair.first)); + */ return false; } } @@ -206,24 +207,30 @@ bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) VersionFile file = VersionFile::fromJson(QJsonDocument(obj), QString(), false, isError); if (isError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Error while reading. Please check MultiMC-0.log for more info.")); + */ return false; } VersionFile::ApplyError error = file.applyTo(m_version); if (error == VersionFile::OtherError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); + */ return false; } else if (error == VersionFile::LauncherVersionError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); + */ return false; } @@ -235,29 +242,35 @@ bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool r QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString())); + */ return false; } QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error); if (error.error != QJsonParseError::NoError) { + /* QMessageBox::critical(m_widgetParent, QObject::tr("Error"), QObject::tr("Unable to parse %1: %2 at %3") .arg(file.fileName(), error.errorString()) .arg(error.offset)); + */ return false; } bool isError = false; *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, isFTB); if (isError) { + /* QMessageBox::critical( m_widgetParent, QObject::tr("Error"), QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.") .arg(file.fileName())); + */ } return true; } diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index fe77ed9d..789fe3f1 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -20,7 +20,6 @@ class VersionFinal; class OneSixInstance; -class QWidget; class QJsonObject; class QFileInfo; class VersionFile; @@ -29,7 +28,7 @@ class OneSixVersionBuilder { OneSixVersionBuilder(); public: - static bool build(VersionFinal *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external); + static bool build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external); static bool readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj); static QMap readOverrideOrders(OneSixInstance *instance); @@ -38,7 +37,6 @@ public: private: VersionFinal *m_version; OneSixInstance *m_instance; - QWidget *m_widgetParent; bool buildInternal(const bool onlyVanilla, const QStringList &external); bool readJsonAndApply(const QJsonObject &obj); diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index ce78e8e3..3aa95ed7 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -26,10 +26,10 @@ VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) clear(); } -bool VersionFinal::reload(QWidget *widgetParent, const bool onlyVanilla, const QStringList &external) +bool VersionFinal::reload(const bool onlyVanilla, const QStringList &external) { beginResetModel(); - bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla, external); + bool ret = OneSixVersionBuilder::build(this, m_instance, onlyVanilla, external); endResetModel(); return ret; } diff --git a/logic/VersionFinal.h b/logic/VersionFinal.h index c9a5f469..e5a38423 100644 --- a/logic/VersionFinal.h +++ b/logic/VersionFinal.h @@ -37,7 +37,7 @@ public: virtual int columnCount(const QModelIndex &parent) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; - bool reload(QWidget *widgetParent, const bool onlyVanilla = false, const QStringList &external = QStringList()); + bool reload(const bool onlyVanilla = false, const QStringList &external = QStringList()); void clear(); void dump() const; -- cgit v1.2.3 From 28ad9befdcac246eb69a434be970abc29a80bc80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 2 Mar 2014 19:12:04 +0100 Subject: Remove a lot of error code and error handling madness. --- CMakeLists.txt | 5 + MMCError.h | 29 +++++ logic/MMCJson.cpp | 53 ++++++++ logic/MMCJson.h | 46 +++++++ logic/OneSixVersionBuilder.cpp | 90 ++----------- logic/VersionFile.cpp | 288 ++++++++++------------------------------- logic/VersionFile.h | 28 ++-- 7 files changed, 230 insertions(+), 309 deletions(-) create mode 100644 MMCError.h create mode 100644 logic/MMCJson.cpp create mode 100644 logic/MMCJson.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 229179cb..d9279bcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,7 @@ SET(MULTIMC_SOURCES MultiMC.h MultiMC.cpp MultiMCVersion.h +MMCError.h # Logging logger/QsDebugOutput.cpp @@ -353,6 +354,10 @@ logic/ModList.cpp logic/InstanceLauncher.h logic/InstanceLauncher.cpp +# JSON parsing helpers +logic/MMCJson.h +logic/MMCJson.cpp + # network stuffs logic/net/NetAction.h logic/net/MD5EtagDownload.h diff --git a/MMCError.h b/MMCError.h new file mode 100644 index 00000000..33591e06 --- /dev/null +++ b/MMCError.h @@ -0,0 +1,29 @@ +#pragma once +#include +#include +#include + +class MMCError : public std::exception +{ +public: + MMCError(QString cause) + { + exceptionCause = cause; + QLOG_ERROR() << errorName() + ": " + cause; + }; + virtual ~MMCError(){}; + virtual const char *what() const noexcept + { + return exceptionCause.toLocal8Bit(); + }; + virtual QString cause() const + { + return exceptionCause; + } + virtual QString errorName() + { + return "MultiMC Error"; + } +private: + QString exceptionCause; +}; \ No newline at end of file diff --git a/logic/MMCJson.cpp b/logic/MMCJson.cpp new file mode 100644 index 00000000..14cde0c1 --- /dev/null +++ b/logic/MMCJson.cpp @@ -0,0 +1,53 @@ +#include "MMCJson.h" +#include + +bool MMCJson::ensureBoolean(const QJsonValue val, const QString what) +{ + if (!val.isBool()) + throw JSONValidationError(what + " is not boolean"); + return val.isBool(); +} + +QJsonValue MMCJson::ensureExists(QJsonValue val, const QString what) +{ + if(val.isNull()) + throw JSONValidationError(what + " does not exist"); + return val; +} + +QJsonArray MMCJson::ensureArray(const QJsonValue val, const QString what) +{ + if (!val.isArray()) + throw JSONValidationError(what + " is not an array"); + return val.toArray(); +} + +double MMCJson::ensureDouble(const QJsonValue val, const QString what) +{ + if (!val.isDouble()) + throw JSONValidationError(what + " is not a number"); + double ret = val.toDouble(); +} + +int MMCJson::ensureInteger(const QJsonValue val, const QString what) +{ + double ret = ensureDouble(val, what); + if (fmod(ret, 1) != 0) + throw JSONValidationError(what + " is not an integer"); + return ret; +} + +QJsonObject MMCJson::ensureObject(const QJsonValue val, const QString what) +{ + if (!val.isObject()) + throw JSONValidationError(what + " is not an object"); + return val.toObject(); +} + +QString MMCJson::ensureString(const QJsonValue val, const QString what) +{ + if (!val.isString()) + throw JSONValidationError(what + " is not a string"); + return val.toString(); +} + diff --git a/logic/MMCJson.h b/logic/MMCJson.h new file mode 100644 index 00000000..3e7342b5 --- /dev/null +++ b/logic/MMCJson.h @@ -0,0 +1,46 @@ +/** + * Some de-bullshitting for Qt JSON failures. + * + * Simple exception-throwing + */ + +#pragma once +#include +#include +#include +#include "MMCError.h" + +class JSONValidationError : public MMCError +{ +public: + JSONValidationError(QString cause) : MMCError(cause) {}; + virtual QString errorName() + { + return "JSONValidationError"; + }; + virtual ~JSONValidationError() {}; +}; + +namespace MMCJson +{ +/// make sure the value exists. throw otherwise. +QJsonValue ensureExists(QJsonValue val, const QString what = "value"); + +/// make sure the value is converted into an object. throw otherwise. +QJsonObject ensureObject(const QJsonValue val, const QString what = "value"); + +/// make sure the value is converted into an array. throw otherwise. +QJsonArray ensureArray(const QJsonValue val, QString what = "value"); + +/// make sure the value is converted into a string. throw otherwise. +QString ensureString(const QJsonValue val, QString what = "value"); + +/// make sure the value is converted into a boolean. throw otherwise. +bool ensureBoolean(const QJsonValue val, QString what = "value"); + +/// make sure the value is converted into an integer. throw otherwise. +int ensureInteger(const QJsonValue val, QString what = "value"); + +/// make sure the value is converted into a double precision floating number. throw otherwise. +double ensureDouble(const QJsonValue val, QString what = "value"); +} diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 98e4b54e..752f2d8f 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -73,10 +73,7 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file.fileId = "org.multimc.external." + file.name; file.version = QString(); file.mcVersion = QString(); - bool isError = false; - auto errorcode = file.applyTo(m_version); - if(errorcode != VersionFile::NoApplyError) - return false; + file.applyTo(m_version); } // else, if there's custom json, we just do that. else if (QFile::exists(root.absoluteFilePath("custom.json"))) @@ -91,9 +88,7 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file.filename = "custom.json"; file.fileId = "org.multimc.custom.json"; file.version = QString(); - auto errorcode = file.applyTo(m_version); - if(errorcode != VersionFile::NoApplyError) - return false; + file.applyTo(m_version); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.") } @@ -111,18 +106,8 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file.fileId = "org.multimc.version.json"; file.version = m_instance->intendedVersionId(); file.mcVersion = m_instance->intendedVersionId(); - auto error = file.applyTo(m_version); - if (error != VersionFile::NoApplyError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr( - "Error while applying %1. Please check MultiMC-0.log for more info.") - .arg(root.absoluteFilePath("version.json"))); - */ - return false; - } + file.applyTo(m_version); + // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json"))); if (onlyVanilla) break; @@ -155,17 +140,8 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi { QLOG_DEBUG() << "Applying file with order" << order; auto filePair = files[order]; - auto error = filePair.second.applyTo(m_version); - if (error != VersionFile::NoApplyError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("Error while applying %1. Please check MultiMC-0.log " - "for more info.").arg(filePair.first)); - */ - return false; - } + filePair.second.applyTo(m_version); + // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(filePair.first)); } } while(0); @@ -203,37 +179,12 @@ bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) { m_version->clear(); - bool isError = false; - VersionFile file = VersionFile::fromJson(QJsonDocument(obj), QString(), false, isError); - if (isError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("Error while reading. Please check MultiMC-0.log for more info.")); - */ - return false; - } - VersionFile::ApplyError error = file.applyTo(m_version); - if (error == VersionFile::OtherError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); - */ - return false; - } - else if (error == VersionFile::LauncherVersionError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); - */ - return false; - } + VersionFile file = VersionFile::fromJson(QJsonDocument(obj), QString(), false); + // QObject::tr("Error while reading. Please check MultiMC-0.log for more info.")); + file.applyTo(m_version); + // QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); + // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); return true; } @@ -242,11 +193,7 @@ bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool r QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString())); - */ + // QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString()); return false; } QJsonParseError error; @@ -261,17 +208,8 @@ bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool r */ return false; } - bool isError = false; - *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, isFTB); - if (isError) - { - /* - QMessageBox::critical( - m_widgetParent, QObject::tr("Error"), - QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.") - .arg(file.fileName())); - */ - } + *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isFTB); + // QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.").arg(file.fileName()); return true; } diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp index 76cf9279..4423e733 100644 --- a/logic/VersionFile.cpp +++ b/logic/VersionFile.cpp @@ -7,19 +7,20 @@ #include "logic/VersionFile.h" #include "logic/OneSixLibrary.h" #include "logic/VersionFinal.h" +#include "MMCJson.h" +using namespace MMCJson; #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, - const QString &filename, bool &isError) + const QString &filename) { - isError = true; Library out; if (!libObj.contains("name")) { - QLOG_ERROR() << filename << "contains a library that doesn't have a 'name' field"; - return out; + throw JSONValidationError(filename + + "contains a library that doesn't have a 'name' field"); } out.name = libObj.value("name").toString(); @@ -45,44 +46,17 @@ VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, readString("MMC-absoluteUrl", out.absoluteUrl); if (libObj.contains("extract")) { - if (!libObj.value("extract").isObject()) - { - QLOG_ERROR() << filename - << "contains a library with an 'extract' field that's not an object"; - return out; - } - QJsonObject extractObj = libObj.value("extract").toObject(); - if (!extractObj.contains("exclude") || !extractObj.value("exclude").isArray()) - { - QLOG_ERROR() << filename << "contains a library with an invalid 'extract' field"; - return out; - } out.applyExcludes = true; - QJsonArray excludeArray = extractObj.value("exclude").toArray(); - for (auto excludeVal : excludeArray) + auto extractObj = ensureObject(libObj.value("extract")); + for (auto excludeVal : ensureArray(extractObj.value("exclude"))) { - if (!excludeVal.isString()) - { - QLOG_WARN() << filename << "contains a library that contains an 'extract' " - "field that contains an invalid 'exclude' entry " - "(skipping)"; - } - else - { - out.excludes.append(excludeVal.toString()); - } + out.excludes.append(ensureString(excludeVal)); } } if (libObj.contains("natives")) { - if (!libObj.value("natives").isObject()) - { - QLOG_ERROR() << filename - << "contains a library with a 'natives' field that's not an object"; - return out; - } out.applyNatives = true; - QJsonObject nativesObj = libObj.value("natives").toObject(); + QJsonObject nativesObj = ensureObject(libObj.value("natives")); for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) { if (!it.value().isString()) @@ -101,24 +75,19 @@ VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, out.applyRules = true; out.rules = rulesFromJsonV4(libObj); } - isError = false; return out; } -VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, - const bool requireOrder, bool &isError, const bool isFTB) +VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB) { VersionFile out; - isError = true; if (doc.isEmpty() || doc.isNull()) { - QLOG_ERROR() << filename << "is empty or null"; - return out; + throw JSONValidationError(filename + " is empty or null"); } if (!doc.isObject()) { - QLOG_ERROR() << "The root of" << filename << "is not an object"; - return out; + throw JSONValidationError("The root of " + filename + " is not an object"); } QJsonObject root = doc.object(); @@ -127,18 +96,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { if (root.contains("order")) { - if (root.value("order").isDouble()) - { - out.order = root.value("order").toDouble(); - } - else - { - QLOG_ERROR() << "'order' field contains an invalid value in" << filename; - return out; - } + out.order = ensureInteger(root.value("order")); } else { + // FIXME: evaluate if we don't want to throw exceptions here instead QLOG_ERROR() << filename << "doesn't contain an order field"; } } @@ -153,19 +115,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { if (root.contains(key)) { - QJsonValue val = root.value(key); - if (!val.isString()) - { - QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; - } - else - { - variable = val.toString(); - } + variable = ensureString(root.value(key)); } }; - // FTB id attribute is completely bogus. We ignore it. + // FIXME: This should be ignored when applying. if (!isFTB) { readString("id", out.id); @@ -180,108 +134,47 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen readString("releaseTime", out.releaseTime); readString("time", out.time); readString("assets", out.assets); + if (root.contains("minimumLauncherVersion")) { - QJsonValue val = root.value("minimumLauncherVersion"); - if (!val.isDouble()) - { - QLOG_WARN() << "minimumLauncherVersion is not an int in" << filename - << "(skipping)"; - } - else - { - out.minimumLauncherVersion = val.toDouble(); - } + out.minimumLauncherVersion = ensureInteger(root.value("minimumLauncherVersion")); } if (root.contains("tweakers")) { - QJsonValue tweakersVal = root.value("tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename << "contains a 'tweakers' field, but it's not an array"; - return out; - } out.shouldOverwriteTweakers = true; - QJsonArray tweakers = root.value("tweakers").toArray(); - for (auto tweakerVal : tweakers) + for (auto tweakerVal : ensureArray(root.value("tweakers"))) { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a 'tweakers' field entry that's not a string"; - return out; - } - out.overwriteTweakers.append(tweakerVal.toString()); + out.overwriteTweakers.append(ensureString(tweakerVal)); } } + if (root.contains("+tweakers")) { - QJsonValue tweakersVal = root.value("+tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename << "contains a '+tweakers' field, but it's not an array"; - return out; - } - QJsonArray tweakers = root.value("+tweakers").toArray(); - for (auto tweakerVal : tweakers) + for (auto tweakerVal : ensureArray(root.value("+tweakers"))) { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a '+tweakers' field entry that's not a string"; - return out; - } - out.addTweakers.append(tweakerVal.toString()); + out.addTweakers.append(ensureString(tweakerVal)); } } + if (root.contains("-tweakers")) { - QJsonValue tweakersVal = root.value("-tweakers"); - if (!tweakersVal.isArray()) - { - QLOG_ERROR() << filename << "contains a '-tweakers' field, but it's not an array"; - return out; - } - out.shouldOverwriteTweakers = true; - QJsonArray tweakers = root.value("-tweakers").toArray(); - for (auto tweakerVal : tweakers) + for (auto tweakerVal : ensureArray(root.value("-tweakers"))) { - if (!tweakerVal.isString()) - { - QLOG_ERROR() << filename - << "contains a '-tweakers' field entry that's not a string"; - return out; - } - out.removeTweakers.append(tweakerVal.toString()); + out.removeTweakers.append(ensureString(tweakerVal)); } } if (root.contains("libraries")) { + // FIXME: This should be done when applying. out.shouldOverwriteLibs = !isFTB; - QJsonValue librariesVal = root.value("libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename << "contains a 'libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) + for (auto libVal : ensureArray(root.value("libraries"))) { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - bool error; - Library lib = Library::fromJson(libObj, filename, error); - if (error) - { - QLOG_ERROR() << "Error while reading a library entry in" << filename; - return out; - } + auto libObj = ensureObject(libVal); + + Library lib = Library::fromJson(libObj, filename); + // FIXME: This should be done when applying. if (isFTB) { lib.hint = "local"; @@ -294,36 +187,18 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } } } + if (root.contains("+libraries")) { - QJsonValue librariesVal = root.value("+libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename << "contains a '+libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) + for (auto libVal : ensureArray(root.value("+libraries"))) { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - bool error; - Library lib = Library::fromJson(libObj, filename, error); - if (error) - { - QLOG_ERROR() << "Error while reading a library entry in" << filename; - return out; - } - if (!libObj.contains("insert")) - { - QLOG_ERROR() << "Missing 'insert' field in '+libraries' field in" << filename; - return out; - } - QJsonValue insertVal = libObj.value("insert"); + QJsonObject libObj = ensureObject(libVal); + QJsonValue insertVal = ensureExists(libObj.value("insert")); + + // parse the library + Library lib = Library::fromJson(libObj, filename); + + // TODO: utility functions for handling this case. templates? QString insertString; { if (insertVal.isString()) @@ -335,8 +210,8 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen QJsonObject insertObj = insertVal.toObject(); if (insertObj.isEmpty()) { - QLOG_ERROR() << "One library has an empty insert object in" << filename; - return out; + throw JSONValidationError("One library has an empty insert object in " + + filename); } insertString = insertObj.keys().first(); lib.insertData = insertObj.value(insertString).toString(); @@ -360,13 +235,12 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } else { - QLOG_ERROR() << "A '+' library in" << filename - << "contains an invalid insert type"; - return out; + throw JSONValidationError("A '+' library in " + filename + + " contains an invalid insert type"); } - if (libObj.contains("MMC-depend") && libObj.value("MMC-depend").isString()) + if (libObj.contains("MMC-depend")) { - const QString dependString = libObj.value("MMC-depend").toString(); + const QString dependString = ensureString(libObj.value("MMC-depend")); if (dependString == "hard") { lib.dependType = Library::Hard; @@ -377,9 +251,8 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } else { - QLOG_ERROR() << "A '+' library in" << filename - << "contains an invalid depend type"; - return out; + throw JSONValidationError("A '+' library in " + filename + + " contains an invalid depend type"); } } out.addLibs.append(lib); @@ -387,36 +260,12 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } if (root.contains("-libraries")) { - QJsonValue librariesVal = root.value("-libraries"); - if (!librariesVal.isArray()) - { - QLOG_ERROR() << filename << "contains a '-libraries' field, but its not an array"; - return out; - } - QJsonArray librariesArray = librariesVal.toArray(); - for (auto libVal : librariesArray) + for (auto libVal : ensureArray(root.value("-libraries"))) { - if (!libVal.isObject()) - { - QLOG_ERROR() << filename << "contains a library that's not an object"; - return out; - } - QJsonObject libObj = libVal.toObject(); - if (!libObj.contains("name")) - { - QLOG_ERROR() << filename << "contains a library without a name"; - return out; - } - if (!libObj.value("name").isString()) - { - QLOG_ERROR() << filename << "contains a library without a valid 'name' field"; - return out; - } - out.removeLibs.append(libObj.value("name").toString()); + auto libObj = ensureObject(libVal); + out.removeLibs.append(ensureString(libObj.value("name"))); } } - - isError = false; return out; } @@ -457,16 +306,15 @@ int VersionFile::findLibrary(QList> haystack, return -1; } -VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) +void VersionFile::applyTo(VersionFinal *version) { if (minimumLauncherVersion != -1) { if (minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION) { - QLOG_ERROR() << filename << "is for a different launcher version (" - << minimumLauncherVersion << "), current supported is" - << CURRENT_MINIMUM_LAUNCHER_VERSION; - return LauncherVersionError; + throw VersionBuildError( + QString("%1 is for a different launcher version (%2), current supported is %3") + .arg(filename, minimumLauncherVersion, CURRENT_MINIMUM_LAUNCHER_VERSION)); } } @@ -475,8 +323,8 @@ VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(version->id) == -1) { - QLOG_ERROR() << filename << "is for a different version of Minecraft"; - return OtherError; + throw VersionBuildError( + QString("%1 is for a different version of Minecraft").arg(filename)); } } @@ -587,7 +435,7 @@ VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) } else { - QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; + QLOG_WARN() << "Couldn't find" << lib.name << "(skipping)"; } break; } @@ -623,10 +471,10 @@ VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) if (ourVersion > otherVersion || (lib.dependType == Library::Hard && ourVersion != otherVersion)) { - QLOG_ERROR() << "Error resolving library dependencies between" - << otherLib->rawName() << "and" << lib.name << "in" - << filename; - return OtherError; + throw VersionBuildError( + QString( + "Error resolving library dependencies between %1 and %2 in %3.") + .arg(otherLib->rawName(), lib.name, filename)); } else { @@ -651,10 +499,10 @@ VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) // it: fail if (lib.dependType == Library::Hard) { - QLOG_ERROR() << "Error resolving library dependencies between" - << otherLib->rawName() << "and" << lib.name << "in" - << filename; - return OtherError; + throw VersionBuildError(QString( + "Error resolving library dependencies between %1 and %2 in %3.") + .arg(otherLib->rawName(), lib.name, + filename)); } } } @@ -697,6 +545,4 @@ VersionFile::ApplyError VersionFile::applyTo(VersionFinal *version) versionFile.filename = filename; versionFile.order = order; version->versionFiles.append(versionFile); - - return NoApplyError; } diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 04694999..37c8c415 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -5,8 +5,21 @@ #include #include "logic/OpSys.h" #include "logic/OneSixRule.h" +#include "MMCError.h" + class VersionFinal; +class VersionBuildError : public MMCError +{ +public: + VersionBuildError(QString cause) : MMCError(cause) {}; + virtual QString errorName() + { + return "VersionBuildError"; + }; + virtual ~VersionBuildError() {}; +}; + struct VersionFile { int order; @@ -65,26 +78,17 @@ struct VersionFile }; DependType dependType = Soft; - static Library fromJson(const QJsonObject &libObj, const QString &filename, - bool &isError); + static Library fromJson(const QJsonObject &libObj, const QString &filename); }; bool shouldOverwriteLibs = false; QList overwriteLibs; QList addLibs; QList removeLibs; - enum ApplyError - { - LauncherVersionError, - OtherError, - NoApplyError - }; - static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, - const bool requireOrder, bool &isError, - const bool isFTB = false); + const bool requireOrder, const bool isFTB = false); static std::shared_ptr createLibrary(const Library &lib); int findLibrary(QList> haystack, const QString &needle); - ApplyError applyTo(VersionFinal *version); + void applyTo(VersionFinal *version); }; \ No newline at end of file -- cgit v1.2.3 From 29cdc9364b0153d04a211adf3eab86076174c0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 3 Mar 2014 01:23:10 +0100 Subject: More code butchery related to version files. No end in sight. --- logic/OneSixInstance.cpp | 19 ++++++---- logic/OneSixVersionBuilder.cpp | 59 +++++++++-------------------- logic/OneSixVersionBuilder.h | 13 ++++--- logic/VersionFile.cpp | 41 ++++++++++---------- logic/VersionFile.h | 85 ++++++++++++++++++++++-------------------- logic/VersionFinal.cpp | 14 ++++--- 6 files changed, 109 insertions(+), 122 deletions(-) diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 0e0be4d8..f6fe49f1 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -27,6 +27,7 @@ #include "icons/IconList.h" #include "MinecraftProcess.h" #include "gui/dialogs/OneSixModEditDialog.h" +#include OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : BaseInstance(new OneSixInstancePrivate(), rootDir, settings, parent) @@ -320,21 +321,23 @@ bool OneSixInstance::reloadVersion() { I_D(OneSixInstance); - bool ret = d->version->reload(false, externalPatches()); - if (ret) - { - ret = d->vanillaVersion->reload(true, externalPatches()); - } - if (ret) + try { + d->version->reload(false, externalPatches()); + d->vanillaVersion->reload(true, externalPatches()); setFlags(flags() & ~VersionBrokenFlag); emit versionReloaded(); + return true; } - else + catch(MMCError error) { + d->version->clear(); + d->vanillaVersion->clear(); setFlags(flags() | VersionBrokenFlag); + //TODO: rethrow to show some error message(s)? + emit versionReloaded(); + return false; } - return ret; } void OneSixInstance::clearVersion() diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 752f2d8f..37467aef 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -30,6 +30,7 @@ #include "OneSixInstance.h" #include "OneSixRule.h" #include "VersionFile.h" +#include "MMCJson.h" #include "modutils.h" #include "logger/QsLog.h" @@ -37,23 +38,23 @@ OneSixVersionBuilder::OneSixVersionBuilder() { } -bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external) +void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external) { OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = instance; - return builder.buildInternal(onlyVanilla, external); + builder.buildInternal(onlyVanilla, external); } -bool OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj) +void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj) { OneSixVersionBuilder builder; builder.m_version = version; builder.m_instance = 0; - return builder.readJsonAndApply(obj); + builder.readJsonAndApply(obj); } -bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringList &external) +void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringList &external) { m_version->clear(); @@ -64,11 +65,7 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi if(!external.isEmpty()) for (auto fileName : external) { QLOG_INFO() << "Reading" << fileName; - VersionFile file; - if (!parseJsonFile(QFileInfo(fileName), false, &file, fileName.endsWith("pack.json"))) - { - return false; - } + VersionFile file = parseJsonFile(QFileInfo(fileName), false, fileName.endsWith("pack.json")); file.name = QFileInfo(fileName).fileName(); file.fileId = "org.multimc.external." + file.name; file.version = QString(); @@ -79,11 +76,7 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi else if (QFile::exists(root.absoluteFilePath("custom.json"))) { QLOG_INFO() << "Reading custom.json"; - VersionFile file; - if (!parseJsonFile(QFileInfo(root.absoluteFilePath("custom.json")), false, &file)) - { - return false; - } + VersionFile file = parseJsonFile(QFileInfo(root.absoluteFilePath("custom.json")), false); file.name = "custom.json"; file.filename = "custom.json"; file.fileId = "org.multimc.custom.json"; @@ -98,11 +91,8 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi // version.json QLOG_INFO() << "Reading version.json"; VersionFile file; - if (!parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false, &file)) - { - return false; - } - file.name = "version.json"; + parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false, &file); + file.name = "Minecraft"; file.fileId = "org.multimc.version.json"; file.version = m_instance->intendedVersionId(); file.mcVersion = m_instance->intendedVersionId(); @@ -120,19 +110,14 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) { QLOG_INFO() << "Reading" << info.fileName(); - VersionFile file; - if (!parseJsonFile(info, true, &file)) - { - return false; - } + VersionFile file = parseJsonFile(info, true); if (overrideOrder.contains(file.fileId)) { file.order = overrideOrder.value(file.fileId); } if (files.contains(file.order)) { - QLOG_ERROR() << file.fileId << "has the same order as" << files[file.order].second.fileId; - return false; + throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file.fileId, files[file.order].second.fileId)); } files.insert(file.order, qMakePair(info.fileName(), file)); } @@ -141,7 +126,6 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi QLOG_DEBUG() << "Applying file with order" << order; auto filePair = files[order]; filePair.second.applyTo(m_version); - // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(filePair.first)); } } while(0); @@ -171,11 +155,9 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi } } } - - return true; } -bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) +void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) { m_version->clear(); @@ -185,32 +167,25 @@ bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) file.applyTo(m_version); // QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); - return true; } -bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool requireOrder, VersionFile* out, bool isFTB) +VersionFile OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB) { QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) { - // QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString()); - return false; + throw JSONValidationError(QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString())); } QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error); if (error.error != QJsonParseError::NoError) { - /* - QMessageBox::critical(m_widgetParent, QObject::tr("Error"), - QObject::tr("Unable to parse %1: %2 at %3") + throw JSONValidationError(QObject::tr("Unable to parse %1: %2 at %3") .arg(file.fileName(), error.errorString()) .arg(error.offset)); - */ - return false; } - *out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isFTB); + return VersionFile::fromJson(doc, file.fileName(), requireOrder, isFTB); // QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.").arg(file.fileName()); - return true; } QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *instance) diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index 789fe3f1..c5ef83f3 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -17,19 +17,20 @@ #include #include +#include "VersionFile.h" class VersionFinal; class OneSixInstance; class QJsonObject; class QFileInfo; -class VersionFile; class OneSixVersionBuilder { OneSixVersionBuilder(); public: - static bool build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external); - static bool readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj); + static void build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, + const QStringList &external); + static void readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj); static QMap readOverrideOrders(OneSixInstance *instance); static bool writeOverrideOrders(const QMap &order, OneSixInstance *instance); @@ -38,8 +39,8 @@ private: VersionFinal *m_version; OneSixInstance *m_instance; - bool buildInternal(const bool onlyVanilla, const QStringList &external); - bool readJsonAndApply(const QJsonObject &obj); + void buildInternal(const bool onlyVanilla, const QStringList &external); + void readJsonAndApply(const QJsonObject &obj); - bool parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, bool isFTB = false); + VersionFile parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB = false); }; diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp index 4423e733..b7695907 100644 --- a/logic/VersionFile.cpp +++ b/logic/VersionFile.cpp @@ -13,10 +13,10 @@ using namespace MMCJson; #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 -VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, +RawLibrary RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) { - Library out; + RawLibrary out; if (!libObj.contains("name")) { throw JSONValidationError(filename + @@ -78,7 +78,8 @@ VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, return out; } -VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB) +VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, + const bool requireOrder, const bool isFTB) { VersionFile out; if (doc.isEmpty() || doc.isNull()) @@ -173,12 +174,12 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { auto libObj = ensureObject(libVal); - Library lib = Library::fromJson(libObj, filename); + RawLibrary lib = RawLibrary::fromJson(libObj, filename); // FIXME: This should be done when applying. if (isFTB) { lib.hint = "local"; - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; out.addLibs.prepend(lib); } else @@ -196,7 +197,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen QJsonValue insertVal = ensureExists(libObj.value("insert")); // parse the library - Library lib = Library::fromJson(libObj, filename); + RawLibrary lib = RawLibrary::fromJson(libObj, filename); // TODO: utility functions for handling this case. templates? QString insertString; @@ -219,19 +220,19 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } if (insertString == "apply") { - lib.insertType = Library::Apply; + lib.insertType = RawLibrary::Apply; } else if (insertString == "prepend") { - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; } else if (insertString == "append") { - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; } else if (insertString == "replace") { - lib.insertType = Library::Replace; + lib.insertType = RawLibrary::Replace; } else { @@ -243,11 +244,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen const QString dependString = ensureString(libObj.value("MMC-depend")); if (dependString == "hard") { - lib.dependType = Library::Hard; + lib.dependType = RawLibrary::Hard; } else if (dependString == "soft") { - lib.dependType = Library::Soft; + lib.dependType = RawLibrary::Soft; } else { @@ -269,7 +270,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen return out; } -std::shared_ptr VersionFile::createLibrary(const VersionFile::Library &lib) +std::shared_ptr VersionFile::createLibrary(const RawLibrary &lib) { std::shared_ptr out(new OneSixLibrary(lib.name)); if (!lib.url.isEmpty()) @@ -396,7 +397,7 @@ void VersionFile::applyTo(VersionFinal *version) { switch (lib.insertType) { - case Library::Apply: + case RawLibrary::Apply: { int index = findLibrary(version->libraries, lib.name); @@ -439,8 +440,8 @@ void VersionFile::applyTo(VersionFinal *version) } break; } - case Library::Append: - case Library::Prepend: + case RawLibrary::Append: + case RawLibrary::Prepend: { const int startOfVersion = lib.name.lastIndexOf(':') + 1; @@ -448,7 +449,7 @@ void VersionFile::applyTo(VersionFinal *version) version->libraries, QString(lib.name).replace(startOfVersion, INT_MAX, '*')); if (index < 0) { - if (lib.insertType == Library::Append) + if (lib.insertType == RawLibrary::Append) { version->libraries.append(createLibrary(lib)); } @@ -469,7 +470,7 @@ void VersionFile::applyTo(VersionFinal *version) // we need a higher version, or we're hard to and the versions aren't // equal if (ourVersion > otherVersion || - (lib.dependType == Library::Hard && ourVersion != otherVersion)) + (lib.dependType == RawLibrary::Hard && ourVersion != otherVersion)) { throw VersionBuildError( QString( @@ -497,7 +498,7 @@ void VersionFile::applyTo(VersionFinal *version) { // our version is smaller than the existing version, but we require // it: fail - if (lib.dependType == Library::Hard) + if (lib.dependType == RawLibrary::Hard) { throw VersionBuildError(QString( "Error resolving library dependencies between %1 and %2 in %3.") @@ -509,7 +510,7 @@ void VersionFile::applyTo(VersionFinal *version) } break; } - case Library::Replace: + case RawLibrary::Replace: { int index = findLibrary(version->libraries, lib.insertData); if (index >= 0) diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 37c8c415..0f183ae8 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -20,8 +20,50 @@ public: virtual ~VersionBuildError() {}; }; +struct RawLibrary +{ + QString name; + QString url; + QString hint; + QString absoluteUrl; + bool applyExcludes = false; + QStringList excludes; + bool applyNatives = false; + QList> natives; + bool applyRules = false; + QList> rules; + + // user for '+' libraries + enum InsertType + { + Apply, + Append, + Prepend, + Replace + }; + InsertType insertType = Append; + QString insertData; + enum DependType + { + Soft, + Hard + }; + DependType dependType = Soft; + + static RawLibrary fromJson(const QJsonObject &libObj, const QString &filename); +}; + struct VersionFile { +public: /* methods */ + static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, + const bool requireOrder, const bool isFTB = false); + + static std::shared_ptr createLibrary(const RawLibrary &lib); + int findLibrary(QList> haystack, const QString &needle); + void applyTo(VersionFinal *version); + +public: /* data */ int order; QString name; QString fileId; @@ -48,47 +90,8 @@ struct VersionFile QStringList addTweakers; QStringList removeTweakers; - struct Library - { - QString name; - QString url; - QString hint; - QString absoluteUrl; - bool applyExcludes = false; - QStringList excludes; - bool applyNatives = false; - QList> natives; - bool applyRules = false; - QList> rules; - - // user for '+' libraries - enum InsertType - { - Apply, - Append, - Prepend, - Replace - }; - InsertType insertType = Append; - QString insertData; - enum DependType - { - Soft, - Hard - }; - DependType dependType = Soft; - - static Library fromJson(const QJsonObject &libObj, const QString &filename); - }; bool shouldOverwriteLibs = false; - QList overwriteLibs; - QList addLibs; + QList overwriteLibs; + QList addLibs; QList removeLibs; - - static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, - const bool requireOrder, const bool isFTB = false); - - static std::shared_ptr createLibrary(const Library &lib); - int findLibrary(QList> haystack, const QString &needle); - void applyTo(VersionFinal *version); }; \ No newline at end of file diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index 3aa95ed7..ec450eda 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -28,10 +28,10 @@ VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) bool VersionFinal::reload(const bool onlyVanilla, const QStringList &external) { + //FIXME: source of epic failure. beginResetModel(); - bool ret = OneSixVersionBuilder::build(this, m_instance, onlyVanilla, external); + OneSixVersionBuilder::build(this, m_instance, onlyVanilla, external); endResetModel(); - return ret; } void VersionFinal::clear() @@ -128,11 +128,15 @@ QList > VersionFinal::getActiveNativeLibs() std::shared_ptr VersionFinal::fromJson(const QJsonObject &obj) { std::shared_ptr version(new VersionFinal(0)); - if (OneSixVersionBuilder::readJsonAndApplyToVersion(version.get(), obj)) + try { - return version; + OneSixVersionBuilder::readJsonAndApplyToVersion(version.get(), obj); } - return 0; + catch(MMCError err) + { + return 0; + } + return version; } QVariant VersionFinal::data(const QModelIndex &index, int role) const -- cgit v1.2.3 From d66f2500a6b4215a135f1e41802f7c7498375c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 3 Mar 2014 01:44:07 +0100 Subject: No end in sight :< --- gui/dialogs/OneSixModEditDialog.cpp | 4 ++++ logic/OneSixVersionBuilder.cpp | 41 ++++++++++++++++++++----------------- logic/OneSixVersionBuilder.h | 1 + 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index d936f3f1..cc383993 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -175,6 +175,7 @@ void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() order[ourId] = ourNewOrder; order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder; + // FIXME: why is GUI code doing this in particular? why isn't this part of a model? if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) { QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); @@ -185,6 +186,8 @@ void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent); } } + +// FIXME: WHY IS THIS DUPLICATED? void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() { QMap order = getExistingOrder(); @@ -212,6 +215,7 @@ void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() order[ourId] = ourNewOrder; order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder; + // FIXME: why is GUI code doing this in particular? why isn't this part of a model? if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) { QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 37467aef..879ff72e 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -130,29 +130,32 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi } while(0); // some final touches + finalizeVersion(); +} + +void OneSixVersionBuilder::finalizeVersion() +{ + if (m_version->assets.isEmpty()) { - if (m_version->assets.isEmpty()) + m_version->assets = "legacy"; + } + if (m_version->minecraftArguments.isEmpty()) + { + QString toCompare = m_version->processArguments.toLower(); + if (toCompare == "legacy") { - m_version->assets = "legacy"; + m_version->minecraftArguments = " ${auth_player_name} ${auth_session}"; } - if (m_version->minecraftArguments.isEmpty()) + else if (toCompare == "username_session") { - QString toCompare = m_version->processArguments.toLower(); - if (toCompare == "legacy") - { - m_version->minecraftArguments = " ${auth_player_name} ${auth_session}"; - } - else if (toCompare == "username_session") - { - m_version->minecraftArguments = - "--username ${auth_player_name} --session ${auth_session}"; - } - else if (toCompare == "username_session_version") - { - m_version->minecraftArguments = "--username ${auth_player_name} " - "--session ${auth_session} " - "--version ${profile_name}"; - } + m_version->minecraftArguments = + "--username ${auth_player_name} --session ${auth_session}"; + } + else if (toCompare == "username_session_version") + { + m_version->minecraftArguments = "--username ${auth_player_name} " + "--session ${auth_session} " + "--version ${profile_name}"; } } } diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index c5ef83f3..c48e8ec5 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -41,6 +41,7 @@ private: void buildInternal(const bool onlyVanilla, const QStringList &external); void readJsonAndApply(const QJsonObject &obj); + void finalizeVersion(); VersionFile parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB = false); }; -- cgit v1.2.3 From 011ea8453015ff4d8fd1f9bed5bed36959c20269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 3 Mar 2014 09:08:32 +0100 Subject: Fix missed version file assignment. --- logic/OneSixVersionBuilder.cpp | 5 ++--- logic/VersionFile.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 879ff72e..0c63dc2a 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -90,8 +90,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi { // version.json QLOG_INFO() << "Reading version.json"; - VersionFile file; - parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false, &file); + VersionFile file = parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false); file.name = "Minecraft"; file.fileId = "org.multimc.version.json"; file.version = m_instance->intendedVersionId(); @@ -124,7 +123,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi for (auto order : files.keys()) { QLOG_DEBUG() << "Applying file with order" << order; - auto filePair = files[order]; + auto & filePair = files[order]; filePair.second.applyTo(m_version); } } while(0); diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 0f183ae8..0475f927 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -64,7 +64,7 @@ public: /* methods */ void applyTo(VersionFinal *version); public: /* data */ - int order; + int order = 0; QString name; QString fileId; QString version; -- cgit v1.2.3 From a4779d32b60c0e324f719bd25c76a94c0384ac2e Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 3 Mar 2014 17:22:23 -0500 Subject: Fix ftb locations on old windows... again. --- MultiMC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 598a3a80..595643f8 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -319,7 +319,7 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - QString ftbDefault = PathCombine(QStandardPaths::writableLocation(QStandardPaths::DataLocation), "/ftblauncher"); + QString ftbDefault = PathCombine(qgetenv("APPDATA"), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -- cgit v1.2.3 From 47bc7e5ee377dacfeb7cf3d13f07cfd24db906fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 5 Mar 2014 01:50:05 +0100 Subject: More refactor. --- gui/dialogs/OneSixModEditDialog.cpp | 2 +- logic/MMCJson.cpp | 7 ++ logic/MMCJson.h | 4 + logic/OneSixLibrary.h | 3 + logic/OneSixVersionBuilder.cpp | 123 ++++++++++++----------- logic/OneSixVersionBuilder.h | 3 +- logic/VersionFile.cpp | 189 +++++++++++++++++------------------- logic/VersionFile.h | 16 +-- logic/VersionFinal.cpp | 42 -------- logic/VersionFinal.h | 10 +- 10 files changed, 184 insertions(+), 215 deletions(-) diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index cc383993..96205d0a 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -357,7 +357,7 @@ QMap OneSixModEditDialog::getExistingOrder() const QMap order; // default { - for (VersionFinal::VersionFile file : m_version->versionFiles) + for (auto & file : m_version->versionFiles) { if (file.id.startsWith("org.multimc.")) { diff --git a/logic/MMCJson.cpp b/logic/MMCJson.cpp index 14cde0c1..80d36204 100644 --- a/logic/MMCJson.cpp +++ b/logic/MMCJson.cpp @@ -44,6 +44,13 @@ QJsonObject MMCJson::ensureObject(const QJsonValue val, const QString what) return val.toObject(); } +QJsonObject MMCJson::ensureObject(const QJsonDocument val, const QString what) +{ + if (!val.isObject()) + throw JSONValidationError(what + " is not an object"); + return val.object(); +} + QString MMCJson::ensureString(const QJsonValue val, const QString what) { if (!val.isString()) diff --git a/logic/MMCJson.h b/logic/MMCJson.h index 3e7342b5..b0d898fc 100644 --- a/logic/MMCJson.h +++ b/logic/MMCJson.h @@ -7,6 +7,7 @@ #pragma once #include #include +#include #include #include "MMCError.h" @@ -29,6 +30,9 @@ QJsonValue ensureExists(QJsonValue val, const QString what = "value"); /// make sure the value is converted into an object. throw otherwise. QJsonObject ensureObject(const QJsonValue val, const QString what = "value"); +/// make sure the document is converted into an object. throw otherwise. +QJsonObject ensureObject(const QJsonDocument val, const QString what = "value"); + /// make sure the value is converted into an array. throw otherwise. QJsonArray ensureArray(const QJsonValue val, QString what = "value"); diff --git a/logic/OneSixLibrary.h b/logic/OneSixLibrary.h index 371ca6f4..3bd21c51 100644 --- a/logic/OneSixLibrary.h +++ b/logic/OneSixLibrary.h @@ -26,6 +26,9 @@ class Rule; +class OneSixLibrary; +typedef std::shared_ptr OneSixLibraryPtr; + class OneSixLibrary { private: diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 0c63dc2a..a6bc5ec7 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -65,23 +65,23 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi if(!external.isEmpty()) for (auto fileName : external) { QLOG_INFO() << "Reading" << fileName; - VersionFile file = parseJsonFile(QFileInfo(fileName), false, fileName.endsWith("pack.json")); - file.name = QFileInfo(fileName).fileName(); - file.fileId = "org.multimc.external." + file.name; - file.version = QString(); - file.mcVersion = QString(); - file.applyTo(m_version); + auto file = parseJsonFile(QFileInfo(fileName), false, fileName.endsWith("pack.json")); + file->name = QFileInfo(fileName).fileName(); + file->fileId = "org.multimc.external." + file->name; + file->version = QString(); + file->mcVersion = QString(); + file->applyTo(m_version); } // else, if there's custom json, we just do that. else if (QFile::exists(root.absoluteFilePath("custom.json"))) { QLOG_INFO() << "Reading custom.json"; - VersionFile file = parseJsonFile(QFileInfo(root.absoluteFilePath("custom.json")), false); - file.name = "custom.json"; - file.filename = "custom.json"; - file.fileId = "org.multimc.custom.json"; - file.version = QString(); - file.applyTo(m_version); + auto file = parseJsonFile(QFileInfo(root.absoluteFilePath("custom.json")), false); + file->name = "custom.json"; + file->filename = "custom.json"; + file->fileId = "org.multimc.custom.json"; + file->version = QString(); + file->applyTo(m_version); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.") } @@ -90,12 +90,12 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi { // version.json QLOG_INFO() << "Reading version.json"; - VersionFile file = parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false); - file.name = "Minecraft"; - file.fileId = "org.multimc.version.json"; - file.version = m_instance->intendedVersionId(); - file.mcVersion = m_instance->intendedVersionId(); - file.applyTo(m_version); + auto file = parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false); + file->name = "Minecraft"; + file->fileId = "org.multimc.version.json"; + file->version = m_instance->intendedVersionId(); + file->mcVersion = m_instance->intendedVersionId(); + file->applyTo(m_version); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json"))); if (onlyVanilla) @@ -105,26 +105,26 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi // load all, put into map for ordering, apply in the right order QMap overrideOrder = readOverrideOrders(m_instance); - QMap> files; + QMap> files; for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) { QLOG_INFO() << "Reading" << info.fileName(); - VersionFile file = parseJsonFile(info, true); - if (overrideOrder.contains(file.fileId)) + auto file = parseJsonFile(info, true); + if (overrideOrder.contains(file->fileId)) { - file.order = overrideOrder.value(file.fileId); + file->order = overrideOrder.value(file->fileId); } - if (files.contains(file.order)) + if (files.contains(file->order)) { - throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file.fileId, files[file.order].second.fileId)); + throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file->fileId, files[file->order].second->fileId)); } - files.insert(file.order, qMakePair(info.fileName(), file)); + files.insert(file->order, qMakePair(info.fileName(), file)); } for (auto order : files.keys()) { QLOG_DEBUG() << "Applying file with order" << order; auto & filePair = files[order]; - filePair.second.applyTo(m_version); + filePair.second->applyTo(m_version); } } while(0); @@ -163,15 +163,15 @@ void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) { m_version->clear(); - VersionFile file = VersionFile::fromJson(QJsonDocument(obj), QString(), false); + auto file = VersionFile::fromJson(QJsonDocument(obj), QString(), false); // QObject::tr("Error while reading. Please check MultiMC-0.log for more info.")); - file.applyTo(m_version); + file->applyTo(m_version); // QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); } -VersionFile OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB) +VersionFilePtr OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB) { QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) @@ -193,39 +193,50 @@ VersionFile OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *instance) { QMap out; - if (QDir(instance->instanceRoot()).exists("order.json")) + + // make sure the order file exists + if (!QDir(instance->instanceRoot()).exists("order.json")) + return out; + + // and it can be opened + QFile orderFile(instance->instanceRoot() + "/order.json"); + if (!orderFile.open(QFile::ReadOnly)) { - QFile orderFile(instance->instanceRoot() + "/order.json"); - if (!orderFile.open(QFile::ReadOnly)) - { - QLOG_ERROR() << "Couldn't open" << orderFile.fileName() - << " for reading:" << orderFile.errorString(); - QLOG_WARN() << "Ignoring overriden order"; - } - else + QLOG_ERROR() << "Couldn't open" << orderFile.fileName() + << " for reading:" << orderFile.errorString(); + QLOG_WARN() << "Ignoring overriden order"; + return out; + } + + // and it's valid JSON + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson(orderFile.readAll(), &error); + if (error.error != QJsonParseError::NoError ) + { + QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ":" << error.errorString(); + QLOG_WARN() << "Ignoring overriden order"; + return out; + } + + // and then read it and process it if all above is true. + try + { + auto obj = MMCJson::ensureObject(doc); + for (auto it = obj.begin(); it != obj.end(); ++it) { - QJsonParseError error; - QJsonDocument doc = QJsonDocument::fromJson(orderFile.readAll(), &error); - if (error.error != QJsonParseError::NoError || !doc.isObject()) + if (it.key().startsWith("org.multimc.")) { - QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ":" - << error.errorString(); - QLOG_WARN() << "Ignoring overriden order"; - } - else - { - QJsonObject obj = doc.object(); - for (auto it = obj.begin(); it != obj.end(); ++it) - { - if (it.key().startsWith("org.multimc.")) - { - continue; - } - out.insert(it.key(), it.value().toDouble()); - } + continue; } + out.insert(it.key(), MMCJson::ensureInteger(it.value())); } } + catch (JSONValidationError err) + { + QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ": bad file format"; + QLOG_WARN() << "Ignoring overriden order"; + return out; + } return out; } diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index c48e8ec5..8be3d9d3 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -43,5 +43,6 @@ private: void readJsonAndApply(const QJsonObject &obj); void finalizeVersion(); - VersionFile parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB = false); + VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, + bool isFTB = false); }; diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp index b7695907..40dcb0c3 100644 --- a/logic/VersionFile.cpp +++ b/logic/VersionFile.cpp @@ -13,16 +13,15 @@ using namespace MMCJson; #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 -RawLibrary RawLibrary::fromJson(const QJsonObject &libObj, - const QString &filename) +RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) { - RawLibrary out; + RawLibraryPtr out(new RawLibrary()); if (!libObj.contains("name")) { throw JSONValidationError(filename + "contains a library that doesn't have a 'name' field"); } - out.name = libObj.value("name").toString(); + out->name = libObj.value("name").toString(); auto readString = [libObj, filename](const QString & key, QString & variable) { @@ -40,22 +39,22 @@ RawLibrary RawLibrary::fromJson(const QJsonObject &libObj, } }; - readString("url", out.url); - readString("MMC-hint", out.hint); - readString("MMC-absulute_url", out.absoluteUrl); - readString("MMC-absoluteUrl", out.absoluteUrl); + readString("url", out->url); + readString("MMC-hint", out->hint); + readString("MMC-absulute_url", out->absoluteUrl); + readString("MMC-absoluteUrl", out->absoluteUrl); if (libObj.contains("extract")) { - out.applyExcludes = true; + out->applyExcludes = true; auto extractObj = ensureObject(libObj.value("extract")); for (auto excludeVal : ensureArray(extractObj.value("exclude"))) { - out.excludes.append(ensureString(excludeVal)); + out->excludes.append(ensureString(excludeVal)); } } if (libObj.contains("natives")) { - out.applyNatives = true; + out->applyNatives = true; QJsonObject nativesObj = ensureObject(libObj.value("natives")); for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) { @@ -66,22 +65,22 @@ RawLibrary RawLibrary::fromJson(const QJsonObject &libObj, OpSys opSys = OpSys_fromString(it.key()); if (opSys != Os_Other) { - out.natives.append(qMakePair(opSys, it.value().toString())); + out->natives.append(qMakePair(opSys, it.value().toString())); } } } if (libObj.contains("rules")) { - out.applyRules = true; - out.rules = rulesFromJsonV4(libObj); + out->applyRules = true; + out->rules = rulesFromJsonV4(libObj); } return out; } -VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, +VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB) { - VersionFile out; + VersionFilePtr out(new VersionFile()); if (doc.isEmpty() || doc.isNull()) { throw JSONValidationError(filename + " is empty or null"); @@ -97,7 +96,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { if (root.contains("order")) { - out.order = ensureInteger(root.value("order")); + out->order = ensureInteger(root.value("order")); } else { @@ -106,11 +105,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } } - out.name = root.value("name").toString(); - out.fileId = root.value("fileId").toString(); - out.version = root.value("version").toString(); - out.mcVersion = root.value("mcVersion").toString(); - out.filename = filename; + out->name = root.value("name").toString(); + out->fileId = root.value("fileId").toString(); + out->version = root.value("version").toString(); + out->mcVersion = root.value("mcVersion").toString(); + out->filename = filename; auto readString = [root, filename](const QString & key, QString & variable) { @@ -123,30 +122,30 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen // FIXME: This should be ignored when applying. if (!isFTB) { - readString("id", out.id); + readString("id", out->id); } - readString("mainClass", out.mainClass); - readString("processArguments", out.processArguments); - readString("minecraftArguments", out.overwriteMinecraftArguments); - readString("+minecraftArguments", out.addMinecraftArguments); - readString("-minecraftArguments", out.removeMinecraftArguments); - readString("type", out.type); - readString("releaseTime", out.releaseTime); - readString("time", out.time); - readString("assets", out.assets); + readString("mainClass", out->mainClass); + readString("processArguments", out->processArguments); + readString("minecraftArguments", out->overwriteMinecraftArguments); + readString("+minecraftArguments", out->addMinecraftArguments); + readString("-minecraftArguments", out->removeMinecraftArguments); + readString("type", out->type); + readString("releaseTime", out->releaseTime); + readString("time", out->time); + readString("assets", out->assets); if (root.contains("minimumLauncherVersion")) { - out.minimumLauncherVersion = ensureInteger(root.value("minimumLauncherVersion")); + out->minimumLauncherVersion = ensureInteger(root.value("minimumLauncherVersion")); } if (root.contains("tweakers")) { - out.shouldOverwriteTweakers = true; + out->shouldOverwriteTweakers = true; for (auto tweakerVal : ensureArray(root.value("tweakers"))) { - out.overwriteTweakers.append(ensureString(tweakerVal)); + out->overwriteTweakers.append(ensureString(tweakerVal)); } } @@ -154,7 +153,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { for (auto tweakerVal : ensureArray(root.value("+tweakers"))) { - out.addTweakers.append(ensureString(tweakerVal)); + out->addTweakers.append(ensureString(tweakerVal)); } } @@ -162,29 +161,29 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { for (auto tweakerVal : ensureArray(root.value("-tweakers"))) { - out.removeTweakers.append(ensureString(tweakerVal)); + out->removeTweakers.append(ensureString(tweakerVal)); } } if (root.contains("libraries")) { // FIXME: This should be done when applying. - out.shouldOverwriteLibs = !isFTB; + out->shouldOverwriteLibs = !isFTB; for (auto libVal : ensureArray(root.value("libraries"))) { auto libObj = ensureObject(libVal); - RawLibrary lib = RawLibrary::fromJson(libObj, filename); + auto lib = RawLibrary::fromJson(libObj, filename); // FIXME: This should be done when applying. if (isFTB) { - lib.hint = "local"; - lib.insertType = RawLibrary::Prepend; - out.addLibs.prepend(lib); + lib->hint = "local"; + lib->insertType = RawLibrary::Prepend; + out->addLibs.prepend(lib); } else { - out.overwriteLibs.append(lib); + out->overwriteLibs.append(lib); } } } @@ -197,7 +196,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen QJsonValue insertVal = ensureExists(libObj.value("insert")); // parse the library - RawLibrary lib = RawLibrary::fromJson(libObj, filename); + auto lib = RawLibrary::fromJson(libObj, filename); // TODO: utility functions for handling this case. templates? QString insertString; @@ -215,24 +214,24 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen filename); } insertString = insertObj.keys().first(); - lib.insertData = insertObj.value(insertString).toString(); + lib->insertData = insertObj.value(insertString).toString(); } } if (insertString == "apply") { - lib.insertType = RawLibrary::Apply; + lib->insertType = RawLibrary::Apply; } else if (insertString == "prepend") { - lib.insertType = RawLibrary::Prepend; + lib->insertType = RawLibrary::Prepend; } else if (insertString == "append") { - lib.insertType = RawLibrary::Prepend; + lib->insertType = RawLibrary::Prepend; } else if (insertString == "replace") { - lib.insertType = RawLibrary::Replace; + lib->insertType = RawLibrary::Replace; } else { @@ -244,11 +243,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen const QString dependString = ensureString(libObj.value("MMC-depend")); if (dependString == "hard") { - lib.dependType = RawLibrary::Hard; + lib->dependType = RawLibrary::Hard; } else if (dependString == "soft") { - lib.dependType = RawLibrary::Soft; + lib->dependType = RawLibrary::Soft; } else { @@ -256,7 +255,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen " contains an invalid depend type"); } } - out.addLibs.append(lib); + out->addLibs.append(lib); } } if (root.contains("-libraries")) @@ -264,37 +263,36 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen for (auto libVal : ensureArray(root.value("-libraries"))) { auto libObj = ensureObject(libVal); - out.removeLibs.append(ensureString(libObj.value("name"))); + out->removeLibs.append(ensureString(libObj.value("name"))); } } return out; } -std::shared_ptr VersionFile::createLibrary(const RawLibrary &lib) +OneSixLibraryPtr VersionFile::createLibrary(RawLibraryPtr lib) { - std::shared_ptr out(new OneSixLibrary(lib.name)); - if (!lib.url.isEmpty()) + std::shared_ptr out(new OneSixLibrary(lib->name)); + if (!lib->url.isEmpty()) { - out->setBaseUrl(lib.url); + out->setBaseUrl(lib->url); } - out->setHint(lib.hint); - if (!lib.absoluteUrl.isEmpty()) + out->setHint(lib->hint); + if (!lib->absoluteUrl.isEmpty()) { - out->setAbsoluteUrl(lib.absoluteUrl); + out->setAbsoluteUrl(lib->absoluteUrl); } - out->setAbsoluteUrl(lib.absoluteUrl); - out->extract_excludes = lib.excludes; - for (auto native : lib.natives) + out->setAbsoluteUrl(lib->absoluteUrl); + out->extract_excludes = lib->excludes; + for (auto native : lib->natives) { out->addNative(native.first, native.second); } - out->setRules(lib.rules); + out->setRules(lib->rules); out->finalize(); return out; } -int VersionFile::findLibrary(QList> haystack, - const QString &needle) +int VersionFile::findLibrary(QList haystack, const QString &needle) { for (int i = 0; i < haystack.size(); ++i) { @@ -395,48 +393,48 @@ void VersionFile::applyTo(VersionFinal *version) } for (auto lib : addLibs) { - switch (lib.insertType) + switch (lib->insertType) { case RawLibrary::Apply: { - int index = findLibrary(version->libraries, lib.name); + int index = findLibrary(version->libraries, lib->name); if (index >= 0) { auto library = version->libraries[index]; - if (!lib.url.isNull()) + if (!lib->url.isNull()) { - library->setBaseUrl(lib.url); + library->setBaseUrl(lib->url); } - if (!lib.hint.isNull()) + if (!lib->hint.isNull()) { - library->setHint(lib.hint); + library->setHint(lib->hint); } - if (!lib.absoluteUrl.isNull()) + if (!lib->absoluteUrl.isNull()) { - library->setAbsoluteUrl(lib.absoluteUrl); + library->setAbsoluteUrl(lib->absoluteUrl); } - if (lib.applyExcludes) + if (lib->applyExcludes) { - library->extract_excludes = lib.excludes; + library->extract_excludes = lib->excludes; } - if (lib.applyNatives) + if (lib->applyNatives) { library->clearSuffixes(); - for (auto native : lib.natives) + for (auto native : lib->natives) { library->addNative(native.first, native.second); } } - if (lib.applyRules) + if (lib->applyRules) { - library->setRules(lib.rules); + library->setRules(lib->rules); } library->finalize(); } else { - QLOG_WARN() << "Couldn't find" << lib.name << "(skipping)"; + QLOG_WARN() << "Couldn't find" << lib->name << "(skipping)"; } break; } @@ -444,12 +442,12 @@ void VersionFile::applyTo(VersionFinal *version) case RawLibrary::Prepend: { - const int startOfVersion = lib.name.lastIndexOf(':') + 1; + const int startOfVersion = lib->name.lastIndexOf(':') + 1; const int index = findLibrary( - version->libraries, QString(lib.name).replace(startOfVersion, INT_MAX, '*')); + version->libraries, QString(lib->name).replace(startOfVersion, INT_MAX, '*')); if (index < 0) { - if (lib.insertType == RawLibrary::Append) + if (lib->insertType == RawLibrary::Append) { version->libraries.append(createLibrary(lib)); } @@ -461,7 +459,7 @@ void VersionFile::applyTo(VersionFinal *version) else { auto otherLib = version->libraries.at(index); - const Util::Version ourVersion = lib.name.mid(startOfVersion, INT_MAX); + const Util::Version ourVersion = lib->name.mid(startOfVersion, INT_MAX); const Util::Version otherVersion = otherLib->version(); // if the existing version is a hard dependency we can either use it or // fail, but we can't change it @@ -470,12 +468,12 @@ void VersionFile::applyTo(VersionFinal *version) // we need a higher version, or we're hard to and the versions aren't // equal if (ourVersion > otherVersion || - (lib.dependType == RawLibrary::Hard && ourVersion != otherVersion)) + (lib->dependType == RawLibrary::Hard && ourVersion != otherVersion)) { throw VersionBuildError( QString( "Error resolving library dependencies between %1 and %2 in %3.") - .arg(otherLib->rawName(), lib.name, filename)); + .arg(otherLib->rawName(), lib->name, filename)); } else { @@ -498,11 +496,11 @@ void VersionFile::applyTo(VersionFinal *version) { // our version is smaller than the existing version, but we require // it: fail - if (lib.dependType == RawLibrary::Hard) + if (lib->dependType == RawLibrary::Hard) { throw VersionBuildError(QString( "Error resolving library dependencies between %1 and %2 in %3.") - .arg(otherLib->rawName(), lib.name, + .arg(otherLib->rawName(), lib->name, filename)); } } @@ -512,14 +510,14 @@ void VersionFile::applyTo(VersionFinal *version) } case RawLibrary::Replace: { - int index = findLibrary(version->libraries, lib.insertData); + int index = findLibrary(version->libraries, lib->insertData); if (index >= 0) { version->libraries.replace(index, createLibrary(lib)); } else { - QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)"; + QLOG_WARN() << "Couldn't find" << lib->insertData << "(skipping)"; } break; } @@ -537,13 +535,4 @@ void VersionFile::applyTo(VersionFinal *version) QLOG_WARN() << "Couldn't find" << lib << "(skipping)"; } } - - VersionFinal::VersionFile versionFile; - versionFile.name = name; - versionFile.id = fileId; - versionFile.version = this->version; - versionFile.mcVersion = mcVersion; - versionFile.filename = filename; - versionFile.order = order; - version->versionFiles.append(versionFile); } diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 0475f927..504fcbff 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -20,6 +20,8 @@ public: virtual ~VersionBuildError() {}; }; +struct RawLibrary; +typedef std::shared_ptr RawLibraryPtr; struct RawLibrary { QString name; @@ -50,17 +52,19 @@ struct RawLibrary }; DependType dependType = Soft; - static RawLibrary fromJson(const QJsonObject &libObj, const QString &filename); + static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename); }; +struct VersionFile; +typedef std::shared_ptr VersionFilePtr; struct VersionFile { public: /* methods */ - static VersionFile fromJson(const QJsonDocument &doc, const QString &filename, + static VersionFilePtr fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB = false); - static std::shared_ptr createLibrary(const RawLibrary &lib); - int findLibrary(QList> haystack, const QString &needle); + static OneSixLibraryPtr createLibrary(RawLibraryPtr lib); + int findLibrary(QList haystack, const QString &needle); void applyTo(VersionFinal *version); public: /* data */ @@ -91,7 +95,7 @@ public: /* data */ QStringList removeTweakers; bool shouldOverwriteLibs = false; - QList overwriteLibs; - QList addLibs; + QList overwriteLibs; + QList addLibs; QList removeLibs; }; \ No newline at end of file diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index ec450eda..8d668014 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -52,26 +52,6 @@ void VersionFinal::clear() endResetModel(); } -void VersionFinal::dump() const -{ - qDebug().nospace() << "VersionFinal(" - << "\n\tid=" << id - << "\n\ttime=" << time - << "\n\treleaseTime=" << releaseTime - << "\n\ttype=" << type - << "\n\tassets=" << assets - << "\n\tprocessArguments=" << processArguments - << "\n\tminecraftArguments=" << minecraftArguments - << "\n\tminimumLauncherVersion=" << minimumLauncherVersion - << "\n\tmainClass=" << mainClass - << "\n\tlibraries="; - for (auto lib : libraries) - { - qDebug().nospace() << "\n\t\t" << lib.get(); - } - qDebug().nospace() << "\n)"; -} - bool VersionFinal::canRemove(const int index) const { if (index < versionFiles.size()) @@ -201,25 +181,3 @@ int VersionFinal::columnCount(const QModelIndex &parent) const { return 2; } - -QDebug operator<<(QDebug &dbg, const VersionFinal *version) -{ - version->dump(); - return dbg.maybeSpace(); -} -QDebug operator<<(QDebug &dbg, const OneSixLibrary *library) -{ - dbg.nospace() << "OneSixLibrary(" - << "\n\t\t\trawName=" << library->rawName() - << "\n\t\t\tname=" << library->name() - << "\n\t\t\tversion=" << library->version() - << "\n\t\t\ttype=" << library->type() - << "\n\t\t\tisActive=" << library->isActive() - << "\n\t\t\tisNative=" << library->isNative() - << "\n\t\t\tdownloadUrl=" << library->downloadUrl() - << "\n\t\t\tstoragePath=" << library->storagePath() - << "\n\t\t\tabsolutePath=" << library->absoluteUrl() - << "\n\t\t\thint=" << library->hint(); - dbg.nospace() << "\n\t\t)"; - return dbg.maybeSpace(); -} diff --git a/logic/VersionFinal.h b/logic/VersionFinal.h index e5a38423..b19cd6f9 100644 --- a/logic/VersionFinal.h +++ b/logic/VersionFinal.h @@ -22,6 +22,7 @@ #include #include "OneSixLibrary.h" +#include "VersionFile.h" class OneSixInstance; @@ -118,15 +119,6 @@ public: */ // QList rules; - struct VersionFile - { - QString name; - QString id; - QString version; - QString mcVersion; - QString filename; - int order; - }; QList versionFiles; private: -- cgit v1.2.3 From 97ad7d287c8d99aae6e5f030e1d5669b36ee254b Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:20:45 -0500 Subject: Use windows api to prevent encoding problems. --- MultiMC.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 595643f8..51fd84ac 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -38,6 +38,10 @@ #include "logger/QsLog.h" #include +#ifdef Q_OS_WIN32 +#include "windows.h" +#endif + using namespace Util::Commandline; MultiMC::MultiMC(int &argc, char **argv, bool root_override) @@ -319,7 +323,12 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - QString ftbDefault = PathCombine(qgetenv("APPDATA"), "ftblauncher"); + wchar_t buf[1000]; + if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) + { + QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is corrupt. If you aren't on windows, you have a problem."; + } + QString ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -- cgit v1.2.3 From bb6894893d3da021ea0f2e30615fe9ed72502e5b Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:27:18 -0500 Subject: Fix it - it did it even if the op failed. --- MultiMC.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 51fd84ac..ff4b186a 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -1,4 +1,3 @@ - #include "MultiMC.h" #include #include @@ -324,11 +323,15 @@ void MultiMC::initGlobalSettings() QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) wchar_t buf[1000]; + QString ftbDefault; if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) { - QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is corrupt. If you aren't on windows, you have a problem."; + QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; + } + else + { + ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); } - QString ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -- cgit v1.2.3 From 6e964acde507640a3ce218cdd2393b1b49acd925 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:35:35 -0500 Subject: Use a constant for the buffer size. --- MultiMC.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index ff4b186a..6c5c4db6 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -38,7 +38,8 @@ #include #ifdef Q_OS_WIN32 -#include "windows.h" +#include +static const int APPDATA_BUFFER_SIZE = 1024; #endif using namespace Util::Commandline; @@ -322,9 +323,9 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - wchar_t buf[1000]; + wchar_t buf[APPDATA_BUFFER_SIZE]; QString ftbDefault; - if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) + if(!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) { QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; } -- cgit v1.2.3 From 0cc682c629a4e471495114584bb85be9c73b40ee Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Fri, 7 Mar 2014 16:15:38 +0100 Subject: Fix a few paste upload bugs Fixes https://www.pivotaltracker.com/story/show/66994990 --- logic/net/PasteUpload.cpp | 11 +++++------ logic/net/PasteUpload.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/logic/net/PasteUpload.cpp b/logic/net/PasteUpload.cpp index fa54d084..402eb400 100644 --- a/logic/net/PasteUpload.cpp +++ b/logic/net/PasteUpload.cpp @@ -25,7 +25,7 @@ void PasteUpload::executeTask() m_reply = std::shared_ptr(rep); connect(rep, &QNetworkReply::downloadProgress, [&](qint64 value, qint64 max) - { setProgress(value / max * 100); }); + { setProgress(value / qMax((qint64)1, max) * 100); }); connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished())); @@ -52,10 +52,9 @@ void PasteUpload::downloadFinished() emitFailed(jsonError.errorString()); return; } - QString error; - if (!parseResult(doc, &error)) + if (!parseResult(doc)) { - emitFailed(error); + emitFailed(tr("paste.ee returned an error. Please consult the logs for more information")); return; } } @@ -69,13 +68,13 @@ void PasteUpload::downloadFinished() emitSucceeded(); } -bool PasteUpload::parseResult(QJsonDocument doc, QString *parseError) +bool PasteUpload::parseResult(QJsonDocument doc) { auto object = doc.object(); auto status = object.value("status").toString("error"); if (status == "error") { - parseError = new QString(object.value("error").toString()); + QLOG_ERROR() << "paste.ee reported error:" << QString(object.value("error").toString()); return false; } // FIXME: not the place for GUI things. diff --git a/logic/net/PasteUpload.h b/logic/net/PasteUpload.h index 917a0016..83876c17 100644 --- a/logic/net/PasteUpload.h +++ b/logic/net/PasteUpload.h @@ -14,7 +14,7 @@ protected: virtual void executeTask(); private: - bool parseResult(QJsonDocument doc, QString *parseError); + bool parseResult(QJsonDocument doc); QString m_text; QString m_error; QWidget *m_window; -- cgit v1.2.3 From 96ee20072f4e20e279089c6b6e8de63d2da1f94e Mon Sep 17 00:00:00 2001 From: robotbrain Date: Fri, 7 Mar 2014 10:37:57 -0500 Subject: Add project files I use to gitignore. Its easier than opening a new pr for it. :P --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2ef0d673..d49ca85b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ MultiMC5.kdev4 MultiMC.pro.user CMakeLists.txt.user CMakeLists.txt.user.* +/.project +/.settings # Build dirs build -- cgit v1.2.3 From 91faaa5b591d7d4203591994718c2ed21d5b4d6e Mon Sep 17 00:00:00 2001 From: robotbrain Date: Fri, 7 Mar 2014 19:44:15 -0500 Subject: Fix logging when system language is not en_US. --- logic/MinecraftProcess.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index 89cd71ed..e26459ab 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -350,6 +350,7 @@ void MinecraftProcess::arm() args << QString("-Xms%1m").arg(settings.get("MinMemAlloc").toInt()); args << QString("-Xmx%1m").arg(settings.get("MaxMemAlloc").toInt()); args << QString("-XX:PermSize=%1m").arg(settings.get("PermGen").toInt()); + args << "-Duser.language=en"; if(!m_nativeFolder.isEmpty()) args << QString("-Djava.library.path=%1").arg(m_nativeFolder); args << "-jar" << PathCombine(MMC->bin(), "jars", "NewLaunch.jar"); -- cgit v1.2.3 From 44f21406e91c68b230d38441b950eb7c3d6a8ec5 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sun, 9 Mar 2014 08:18:50 +0100 Subject: Some pre/post related stuff Reload the onesix version config after the commands (addresses https://www.pivotaltracker.com/story/show/60360652) Add a few more variables and also substitute them in the command (fixes https://www.pivotaltracker.com/story/show/66994828) --- logic/BaseInstance.cpp | 6 ++ logic/BaseInstance.h | 2 + logic/MinecraftProcess.cpp | 198 ++++++++++++++++++++++++++++----------------- logic/MinecraftProcess.h | 7 ++ logic/OneSixInstance.cpp | 5 ++ logic/OneSixInstance.h | 2 + 6 files changed, 148 insertions(+), 72 deletions(-) diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp index d78f1ea0..aea91ef2 100644 --- a/logic/BaseInstance.cpp +++ b/logic/BaseInstance.cpp @@ -169,6 +169,12 @@ bool BaseInstance::canLaunch() const return !(flags() & VersionBrokenFlag); } +bool BaseInstance::reload() +{ + // TODO reload the instance settings + return true; +} + QString BaseInstance::baseJar() const { I_D(BaseInstance); diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index 27f939bc..195fd339 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -190,6 +190,8 @@ public: bool canLaunch() const; + virtual bool reload(); + signals: /*! * \brief Signal emitted when properties relevant to the instance view change diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index 89cd71ed..1001cee5 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -49,9 +49,11 @@ MinecraftProcess::MinecraftProcess(BaseInstance *inst) : m_instance(inst) #endif // export some infos - env.insert("INST_NAME", inst->name()); - env.insert("INST_ID", inst->id()); - env.insert("INST_DIR", QDir(inst->instanceRoot()).absolutePath()); + auto variables = getVariables(); + for (auto it = variables.begin(); it != variables.end(); ++it) + { + env.insert(it.key(), it.value()); + } this->setProcessEnvironment(env); m_prepostlaunchprocess.setProcessEnvironment(env); @@ -63,10 +65,10 @@ MinecraftProcess::MinecraftProcess(BaseInstance *inst) : m_instance(inst) // Log prepost launch command output (can be disabled.) if (m_instance->settings().get("LogPrePostOutput").toBool()) { - connect(&m_prepostlaunchprocess, &QProcess::readyReadStandardError, - this, &MinecraftProcess::on_prepost_stdErr); - connect(&m_prepostlaunchprocess, &QProcess::readyReadStandardOutput, - this, &MinecraftProcess::on_prepost_stdOut); + connect(&m_prepostlaunchprocess, &QProcess::readyReadStandardError, this, + &MinecraftProcess::on_prepost_stdErr); + connect(&m_prepostlaunchprocess, &QProcess::readyReadStandardOutput, this, + &MinecraftProcess::on_prepost_stdOut); } } @@ -79,10 +81,10 @@ void MinecraftProcess::setWorkdir(QString path) QString MinecraftProcess::censorPrivateInfo(QString in) { - if(!m_session) + if (!m_session) return in; - if(m_session->session != "-") + if (m_session->session != "-") in.replace(m_session->session, ""); in.replace(m_session->access_token, ""); in.replace(m_session->client_token, ""); @@ -113,7 +115,7 @@ MessageLevel::Enum MinecraftProcess::guessLevel(const QString &line, MessageLeve level = MessageLevel::Fatal; if (line.contains("[DEBUG]")) level = MessageLevel::Debug; - if(line.contains("overwriting existing")) + if (line.contains("overwriting existing")) level = MessageLevel::Fatal; return level; } @@ -139,17 +141,15 @@ MessageLevel::Enum MinecraftProcess::getLevel(const QString &levelName) return MessageLevel::Message; } -void MinecraftProcess::logOutput(const QStringList &lines, - MessageLevel::Enum defaultLevel, +void MinecraftProcess::logOutput(const QStringList &lines, MessageLevel::Enum defaultLevel, bool guessLevel, bool censor) { for (int i = 0; i < lines.size(); ++i) logOutput(lines[i], defaultLevel, guessLevel, censor); } -void MinecraftProcess::logOutput(QString line, - MessageLevel::Enum defaultLevel, - bool guessLevel, bool censor) +void MinecraftProcess::logOutput(QString line, MessageLevel::Enum defaultLevel, bool guessLevel, + bool censor) { MessageLevel::Enum level = defaultLevel; @@ -251,33 +251,7 @@ void MinecraftProcess::finish(int code, ExitStatus status) m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code)); // run post-exit - QString postlaunch_cmd = m_instance->settings().get("PostExitCommand").toString(); - if (!postlaunch_cmd.isEmpty()) - { - emit log(tr("Running Post-Launch command: %1").arg(postlaunch_cmd)); - m_prepostlaunchprocess.start(postlaunch_cmd); - m_prepostlaunchprocess.waitForFinished(); - // Flush console window - if (!m_err_leftover.isEmpty()) - { - logOutput(m_err_leftover, MessageLevel::PrePost); - m_err_leftover.clear(); - } - if (!m_out_leftover.isEmpty()) - { - logOutput(m_out_leftover, MessageLevel::PrePost); - m_out_leftover.clear(); - } - if (m_prepostlaunchprocess.exitStatus() != NormalExit) - { - emit log(tr("Post-Launch command failed with code %1.\n\n").arg(m_prepostlaunchprocess.exitCode()), - MessageLevel::Error); - emit postlaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(), - m_prepostlaunchprocess.exitStatus()); - } - else - emit log(tr("Post-Launch command ran successfully.\n\n")); - } + postLaunch(); m_instance->cleanupAfterRun(); emit ended(m_instance, code, status); } @@ -288,14 +262,12 @@ void MinecraftProcess::killMinecraft() kill(); } -void MinecraftProcess::arm() +bool MinecraftProcess::preLaunch() { - emit log("MultiMC version: " + MMC->version().toString() + "\n\n"); - emit log("Minecraft folder is:\n" + workingDirectory() + "\n\n"); - QString prelaunch_cmd = m_instance->settings().get("PreLaunchCommand").toString(); if (!prelaunch_cmd.isEmpty()) { + prelaunch_cmd = substituteVariables(prelaunch_cmd); // Launch emit log(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd)); m_prepostlaunchprocess.start(prelaunch_cmd); @@ -315,46 +287,128 @@ void MinecraftProcess::arm() // Process return values if (m_prepostlaunchprocess.exitStatus() != NormalExit) { - emit log(tr("Pre-Launch command failed with code %1.\n\n").arg(m_prepostlaunchprocess.exitCode()), + emit log(tr("Pre-Launch command failed with code %1.\n\n") + .arg(m_prepostlaunchprocess.exitCode()), MessageLevel::Fatal); m_instance->cleanupAfterRun(); emit prelaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(), m_prepostlaunchprocess.exitStatus()); - return; + return false; } else emit log(tr("Pre-Launch command ran successfully.\n\n")); + + return m_instance->reload(); + } + return true; +} +bool MinecraftProcess::postLaunch() +{ + QString postlaunch_cmd = m_instance->settings().get("PostExitCommand").toString(); + if (!postlaunch_cmd.isEmpty()) + { + postlaunch_cmd = substituteVariables(postlaunch_cmd); + emit log(tr("Running Post-Launch command: %1").arg(postlaunch_cmd)); + m_prepostlaunchprocess.start(postlaunch_cmd); + m_prepostlaunchprocess.waitForFinished(); + // Flush console window + if (!m_err_leftover.isEmpty()) + { + logOutput(m_err_leftover, MessageLevel::PrePost); + m_err_leftover.clear(); + } + if (!m_out_leftover.isEmpty()) + { + logOutput(m_out_leftover, MessageLevel::PrePost); + m_out_leftover.clear(); + } + if (m_prepostlaunchprocess.exitStatus() != NormalExit) + { + emit log(tr("Post-Launch command failed with code %1.\n\n") + .arg(m_prepostlaunchprocess.exitCode()), + MessageLevel::Error); + emit postlaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(), + m_prepostlaunchprocess.exitStatus()); + } + else + emit log(tr("Post-Launch command ran successfully.\n\n")); + + return m_instance->reload(); } + return true; +} - m_instance->setLastLaunch(); - auto &settings = m_instance->settings(); +QMap MinecraftProcess::getVariables() const +{ + QMap out; + out.insert("INST_NAME", m_instance->name()); + out.insert("INST_ID", m_instance->id()); + out.insert("INST_DIR", QDir(m_instance->instanceRoot()).absolutePath()); + out.insert("INST_MC_DIR", QDir(m_instance->minecraftRoot()).absolutePath()); + out.insert("INST_JAVA", m_instance->settings().get("JavaPath").toString()); + out.insert("INST_JAVA_ARGS", javaArguments().join(' ')); + return out; +} +QString MinecraftProcess::substituteVariables(const QString &cmd) const +{ + QString out = cmd; + auto variables = getVariables(); + for (auto it = variables.begin(); it != variables.end(); ++it) + { + out.replace("$" + it.key(), it.value()); + } + auto env = QProcessEnvironment::systemEnvironment(); + for (auto var : env.keys()) + { + out.replace("$" + var, env.value(var)); + } + return out; +} - //////////// java arguments //////////// +QStringList MinecraftProcess::javaArguments() const +{ QStringList args; + + // custom args go first. we want to override them if we have our own here. + args.append(m_instance->extraArguments()); + +// OSX dock icon and name +#ifdef OSX + args << "-Xdock:icon=icon.png"; + args << QString("-Xdock:name=\"%1\"").arg(m_instance->windowTitle()); +#endif + +// HACK: Stupid hack for Intel drivers. See: https://mojang.atlassian.net/browse/MCL-767 +#ifdef Q_OS_WIN32 + args << QString("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_" + "minecraft.exe.heapdump"); +#endif + + args << QString("-Xms%1m").arg(m_instance->settings().get("MinMemAlloc").toInt()); + args << QString("-Xmx%1m").arg(m_instance->settings().get("MaxMemAlloc").toInt()); + args << QString("-XX:PermSize=%1m").arg(m_instance->settings().get("PermGen").toInt()); + if (!m_nativeFolder.isEmpty()) + args << QString("-Djava.library.path=%1").arg(m_nativeFolder); + args << "-jar" << PathCombine(MMC->bin(), "jars", "NewLaunch.jar"); + + return args; +} + +void MinecraftProcess::arm() +{ + emit log("MultiMC version: " + MMC->version().toString() + "\n\n"); + emit log("Minecraft folder is:\n" + workingDirectory() + "\n\n"); + + if (!preLaunch()) { - // custom args go first. we want to override them if we have our own here. - args.append(m_instance->extraArguments()); - - // OSX dock icon and name - #ifdef OSX - args << "-Xdock:icon=icon.png"; - args << QString("-Xdock:name=\"%1\"").arg(m_instance->windowTitle()); - #endif - - // HACK: Stupid hack for Intel drivers. See: https://mojang.atlassian.net/browse/MCL-767 - #ifdef Q_OS_WIN32 - args << QString("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_" - "minecraft.exe.heapdump"); - #endif - - args << QString("-Xms%1m").arg(settings.get("MinMemAlloc").toInt()); - args << QString("-Xmx%1m").arg(settings.get("MaxMemAlloc").toInt()); - args << QString("-XX:PermSize=%1m").arg(settings.get("PermGen").toInt()); - if(!m_nativeFolder.isEmpty()) - args << QString("-Djava.library.path=%1").arg(m_nativeFolder); - args << "-jar" << PathCombine(MMC->bin(), "jars", "NewLaunch.jar"); + return; } + m_instance->setLastLaunch(); + auto &settings = m_instance->settings(); + + QStringList args = javaArguments(); + QString JavaPath = m_instance->settings().get("JavaPath").toString(); emit log("Java path is:\n" + JavaPath + "\n\n"); QString allArgs = args.join(", "); diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h index 56340962..d91dad56 100644 --- a/logic/MinecraftProcess.h +++ b/logic/MinecraftProcess.h @@ -131,6 +131,13 @@ protected: QString launchScript; QString m_nativeFolder; + bool preLaunch(); + bool postLaunch(); + QMap getVariables() const; + QString substituteVariables(const QString &cmd) const; + + QStringList javaArguments() const; + protected slots: void finish(int, QProcess::ExitStatus status); diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 10411c56..4f8fef5b 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -413,6 +413,11 @@ bool OneSixInstance::providesVersionFile() const return false; } +bool OneSixInstance::reload() +{ + return BaseInstance::reload() && reloadVersion(); +} + QString OneSixInstance::loaderModsDir() const { return PathCombine(minecraftRoot(), "mods"); diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 06fd9de3..fafb34a0 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -75,6 +75,8 @@ public: virtual QStringList externalPatches() const; virtual bool providesVersionFile() const; + bool reload() override; + signals: void versionReloaded(); -- cgit v1.2.3 From f1dc4568020d222803d54fdcece324a14c9266c7 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sun, 9 Mar 2014 08:43:08 +0100 Subject: Also reload the instance cfg While this should work, there don't seem to be any places where the signals are listened for, so changes probably will only be available when calling Setting::get TODO: Fix that ^ --- depends/settings/inisettingsobject.cpp | 5 +++++ depends/settings/inisettingsobject.h | 2 ++ depends/settings/settingsobject.cpp | 9 +++++++++ depends/settings/settingsobject.h | 6 ++++++ logic/BaseInstance.cpp | 3 +-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/depends/settings/inisettingsobject.cpp b/depends/settings/inisettingsobject.cpp index 5e52a56f..2cee8e3c 100644 --- a/depends/settings/inisettingsobject.cpp +++ b/depends/settings/inisettingsobject.cpp @@ -28,6 +28,11 @@ void INISettingsObject::setFilePath(const QString &filePath) m_filePath = filePath; } +bool INISettingsObject::reload() +{ + return m_ini.loadFile(m_filePath) && SettingsObject::reload(); +} + void INISettingsObject::changeSetting(const Setting &setting, QVariant value) { if (contains(setting.id())) diff --git a/depends/settings/inisettingsobject.h b/depends/settings/inisettingsobject.h index 8badc0c6..12370896 100644 --- a/depends/settings/inisettingsobject.h +++ b/depends/settings/inisettingsobject.h @@ -47,6 +47,8 @@ public: */ virtual void setFilePath(const QString &filePath); + bool reload() override; + protected slots: virtual void changeSetting(const Setting &setting, QVariant value); diff --git a/depends/settings/settingsobject.cpp b/depends/settings/settingsobject.cpp index 43fc989a..0e3030df 100644 --- a/depends/settings/settingsobject.cpp +++ b/depends/settings/settingsobject.cpp @@ -126,6 +126,15 @@ bool SettingsObject::contains(const QString &id) return m_settings.contains(id); } +bool SettingsObject::reload() +{ + for (auto setting : m_settings.values()) + { + setting->set(setting->get()); + } + return true; +} + void SettingsObject::connectSignals(const Setting &setting) { connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)), diff --git a/depends/settings/settingsobject.h b/depends/settings/settingsobject.h index 27746f2d..b1b26b09 100644 --- a/depends/settings/settingsobject.h +++ b/depends/settings/settingsobject.h @@ -113,6 +113,12 @@ public: */ bool contains(const QString &id); + /*! + * \brief Reloads the settings and emit signals for changed settings + * \return True if reloading was successful + */ + virtual bool reload(); + signals: /*! * \brief Signal emitted when one of this SettingsObject object's settings changes. diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp index aea91ef2..c565ab59 100644 --- a/logic/BaseInstance.cpp +++ b/logic/BaseInstance.cpp @@ -171,8 +171,7 @@ bool BaseInstance::canLaunch() const bool BaseInstance::reload() { - // TODO reload the instance settings - return true; + return settings().reload(); } QString BaseInstance::baseJar() const -- cgit v1.2.3 From ffff2cd3248a574d3d666731580ac7b8c33e1735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 9 Mar 2014 17:38:42 +0100 Subject: Remove version patch reordering. Remove the main class display from onesix edit mods. --- gui/dialogs/OneSixModEditDialog.cpp | 114 +++--------------------------------- gui/dialogs/OneSixModEditDialog.ui | 50 ++++++++-------- logic/OneSixVersionBuilder.cpp | 10 ++-- logic/VersionFinal.cpp | 10 ++-- logic/VersionFinal.h | 5 +- 5 files changed, 45 insertions(+), 144 deletions(-) diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index 96205d0a..c211d3e1 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -110,7 +110,6 @@ void OneSixModEditDialog::updateVersionControls() { ui->forgeBtn->setEnabled(true); ui->liteloaderBtn->setEnabled(true); - ui->mainClassEdit->setText(m_version->mainClass); } void OneSixModEditDialog::disableVersionControls() @@ -119,7 +118,6 @@ void OneSixModEditDialog::disableVersionControls() ui->liteloaderBtn->setEnabled(false); ui->reloadLibrariesBtn->setEnabled(false); ui->removeLibraryBtn->setEnabled(false); - ui->mainClassEdit->setText(""); } void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() @@ -131,6 +129,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() { if (ui->libraryTreeView->currentIndex().isValid()) { + // FIXME: use actual model, not reloading. if (!m_version->remove(ui->libraryTreeView->currentIndex().row())) { QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file")); @@ -144,97 +143,31 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked() { - QDir(m_inst->instanceRoot()).remove("order.json"); - m_inst->reloadVersion(); + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } + void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() { - - QMap order = getExistingOrder(); - if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) - { - return; - } - const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); - const QString ourId = m_version->versionFileId(ourRow); - const int ourOrder = order[ourId]; - if (ourId.isNull() || ourId.startsWith("org.multimc.")) - { - return; - } - - QMap sortedOrder = invert(order); - - QList sortedOrders = sortedOrder.keys(); - const int ourIndex = sortedOrders.indexOf(ourOrder); - if (ourIndex <= 0) - { - return; - } - const int ourNewOrder = sortedOrders.at(ourIndex - 1); - order[ourId] = ourNewOrder; - order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder; - - // FIXME: why is GUI code doing this in particular? why isn't this part of a model? - if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) - { - QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); - } - else - { - m_inst->reloadVersion(); - ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent); - } + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } -// FIXME: WHY IS THIS DUPLICATED? void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() { - QMap order = getExistingOrder(); - if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) - { - return; - } - const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); - const QString ourId = m_version->versionFileId(ourRow); - const int ourOrder = order[ourId]; - if (ourId.isNull() || ourId.startsWith("org.multimc.")) - { - return; - } - - QMap sortedOrder = invert(order); - - QList sortedOrders = sortedOrder.keys(); - const int ourIndex = sortedOrders.indexOf(ourOrder); - if ((ourIndex + 1) >= sortedOrders.size()) - { - return; - } - const int ourNewOrder = sortedOrders.at(ourIndex + 1); - order[ourId] = ourNewOrder; - order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder; - - // FIXME: why is GUI code doing this in particular? why isn't this part of a model? - if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) - { - QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); - } - else - { - m_inst->reloadVersion(); - ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent); - } + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } void OneSixModEditDialog::on_forgeBtn_clicked() { + // FIXME: use actual model, not reloading. Move logic to model. + + // FIXME: model::isCustom(); if (QDir(m_inst->instanceRoot()).exists("custom.json")) { if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) { return; } + // FIXME: model::revertToBase(); QDir(m_inst->instanceRoot()).remove("custom.json"); m_inst->reloadVersion(); } @@ -351,35 +284,6 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent) return QDialog::eventFilter(ui->resPackTreeView, keyEvent); } -QMap OneSixModEditDialog::getExistingOrder() const -{ - - QMap order; - // default - { - for (auto & file : m_version->versionFiles) - { - if (file.id.startsWith("org.multimc.")) - { - continue; - } - order.insert(file.id, file.order); - } - } - // overriden - { - QMap overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_inst); - for (auto id : order.keys()) - { - if (overridenOrder.contains(id)) - { - order[id] = overridenOrder[id]; - } - } - } - return order; -} - bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() != QEvent::KeyPress) diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui index eaf8f7fd..b606dcd2 100644 --- a/gui/dialogs/OneSixModEditDialog.ui +++ b/gui/dialogs/OneSixModEditDialog.ui @@ -48,24 +48,6 @@ - - - - - - Main Class: - - - - - - - false - - - - - @@ -108,13 +90,6 @@ - - - - Reset order - - - @@ -124,6 +99,12 @@ + + false + + + This isn't implemented yet. + Move up @@ -131,11 +112,30 @@ + + false + + + This isn't implemented yet. + Move down + + + + false + + + This isn't implemented yet. + + + Reset order + + + diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index a6bc5ec7..8abeb0d8 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -71,6 +71,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file->version = QString(); file->mcVersion = QString(); file->applyTo(m_version); + m_version->versionFiles.append(file); } // else, if there's custom json, we just do that. else if (QFile::exists(root.absoluteFilePath("custom.json"))) @@ -82,6 +83,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file->fileId = "org.multimc.custom.json"; file->version = QString(); file->applyTo(m_version); + m_version->versionFiles.append(file); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.") } @@ -96,6 +98,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file->version = m_instance->intendedVersionId(); file->mcVersion = m_instance->intendedVersionId(); file->applyTo(m_version); + m_version->versionFiles.append(file); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json"))); if (onlyVanilla) @@ -103,17 +106,12 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi // patches/ // load all, put into map for ordering, apply in the right order - QMap overrideOrder = readOverrideOrders(m_instance); QMap> files; for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) { QLOG_INFO() << "Reading" << info.fileName(); auto file = parseJsonFile(info, true); - if (overrideOrder.contains(file->fileId)) - { - file->order = overrideOrder.value(file->fileId); - } if (files.contains(file->order)) { throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file->fileId, files[file->order].second->fileId)); @@ -125,6 +123,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi QLOG_DEBUG() << "Applying file with order" << order; auto & filePair = files[order]; filePair.second->applyTo(m_version); + m_version->versionFiles.append(filePair.second); } } while(0); @@ -167,6 +166,7 @@ void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) // QObject::tr("Error while reading. Please check MultiMC-0.log for more info.")); file->applyTo(m_version); + m_version->versionFiles.append(file); // QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); } diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index 8d668014..48601d57 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -56,7 +56,7 @@ bool VersionFinal::canRemove(const int index) const { if (index < versionFiles.size()) { - return versionFiles.at(index).id != "org.multimc.version.json"; + return versionFiles.at(index)->fileId != "org.multimc.version.json"; } return false; } @@ -67,14 +67,14 @@ QString VersionFinal::versionFileId(const int index) const { return QString(); } - return versionFiles.at(index).id; + return versionFiles.at(index)->fileId; } bool VersionFinal::remove(const int index) { if (canRemove(index)) { - return QFile::remove(versionFiles.at(index).filename); + return QFile::remove(versionFiles.at(index)->filename); } return false; } @@ -135,9 +135,9 @@ QVariant VersionFinal::data(const QModelIndex &index, int role) const switch (column) { case 0: - return versionFiles.at(row).name; + return versionFiles.at(row)->name; case 1: - return versionFiles.at(row).version; + return versionFiles.at(row)->version; default: return QVariant(); } diff --git a/logic/VersionFinal.h b/logic/VersionFinal.h index b19cd6f9..99fd5ff0 100644 --- a/logic/VersionFinal.h +++ b/logic/VersionFinal.h @@ -119,11 +119,8 @@ public: */ // QList rules; - QList versionFiles; + QList versionFiles; private: OneSixInstance *m_instance; }; - -QDebug operator<<(QDebug &dbg, const VersionFinal *version); -QDebug operator<<(QDebug &dbg, const OneSixLibrary *library); -- cgit v1.2.3 From b2c803a378695026f12aabc3729eb2139bee1b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 9 Mar 2014 23:42:25 +0100 Subject: Improve reporting of version file errors.x --- MMCError.h | 8 +-- gui/dialogs/OneSixModEditDialog.cpp | 60 ++++++++++++----- gui/dialogs/OneSixModEditDialog.h | 4 +- logic/MMCJson.h | 4 -- logic/OneSixFTBInstance.cpp | 9 ++- logic/OneSixInstance.cpp | 17 +++-- logic/OneSixInstance.h | 8 ++- logic/OneSixUpdate.cpp | 40 ++++++----- logic/OneSixVersionBuilder.cpp | 129 +++++++++++++++++++----------------- logic/VersionFile.cpp | 11 ++- logic/VersionFile.h | 36 ++++++++-- logic/VersionFinal.cpp | 2 +- 12 files changed, 202 insertions(+), 126 deletions(-) diff --git a/MMCError.h b/MMCError.h index 33591e06..7b2bd0c4 100644 --- a/MMCError.h +++ b/MMCError.h @@ -9,7 +9,7 @@ public: MMCError(QString cause) { exceptionCause = cause; - QLOG_ERROR() << errorName() + ": " + cause; + QLOG_ERROR() << "Exception: " + cause; }; virtual ~MMCError(){}; virtual const char *what() const noexcept @@ -20,10 +20,6 @@ public: { return exceptionCause; } - virtual QString errorName() - { - return "MultiMC Error"; - } private: QString exceptionCause; -}; \ No newline at end of file +}; diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index c211d3e1..78585a05 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -42,8 +42,7 @@ #include "logic/LiteLoaderInstaller.h" #include "logic/OneSixVersionBuilder.h" -template -QMap invert(const QMap &in) +template QMap invert(const QMap &in) { QMap out; for (auto it = in.begin(); it != in.end(); ++it) @@ -96,7 +95,8 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) m_resourcepacks->startWatching(); } - connect(m_inst, &OneSixInstance::versionReloaded, this, &OneSixModEditDialog::updateVersionControls); + connect(m_inst, &OneSixInstance::versionReloaded, this, + &OneSixModEditDialog::updateVersionControls); } OneSixModEditDialog::~OneSixModEditDialog() @@ -120,9 +120,30 @@ void OneSixModEditDialog::disableVersionControls() ui->removeLibraryBtn->setEnabled(false); } +bool OneSixModEditDialog::reloadInstanceVersion() +{ + try + { + m_inst->reloadVersion(); + return true; + } + catch (MMCError &e) + { + QMessageBox::critical(this, tr("Error"), e.cause()); + return false; + } + catch (...) + { + QMessageBox::critical( + this, tr("Error"), + tr("Failed to load the version description file for reasons unknown.")); + return false; + } +} + void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() { - m_inst->reloadVersion(); + reloadInstanceVersion(); } void OneSixModEditDialog::on_removeLibraryBtn_clicked() @@ -136,7 +157,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() } else { - m_inst->reloadVersion(); + reloadInstanceVersion(); } } } @@ -163,18 +184,20 @@ void OneSixModEditDialog::on_forgeBtn_clicked() // FIXME: model::isCustom(); if (QDir(m_inst->instanceRoot()).exists("custom.json")) { - if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) + if (QMessageBox::question(this, tr("Revert?"), + tr("This action will remove your custom.json. Continue?")) != + QMessageBox::Yes) { return; } // FIXME: model::revertToBase(); QDir(m_inst->instanceRoot()).remove("custom.json"); - m_inst->reloadVersion(); + reloadInstanceVersion(); } VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); vselect.setFilter(1, m_inst->currentVersionId()); vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + - m_inst->currentVersionId()); + m_inst->currentVersionId()); if (vselect.exec() && vselect.selectedVersion()) { ForgeVersionPtr forgeVersion = @@ -214,28 +237,32 @@ void OneSixModEditDialog::on_forgeBtn_clicked() } } } - m_inst->reloadVersion(); + reloadInstanceVersion(); } void OneSixModEditDialog::on_liteloaderBtn_clicked() { + // FIXME: model... if (QDir(m_inst->instanceRoot()).exists("custom.json")) { - if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) + if (QMessageBox::question(this, tr("Revert?"), + tr("This action will remove your custom.json. Continue?")) != + QMessageBox::Yes) { return; } QDir(m_inst->instanceRoot()).remove("custom.json"); - m_inst->reloadVersion(); + reloadInstanceVersion(); } - VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), this); + VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), + this); vselect.setFilter(1, m_inst->currentVersionId()); vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + - m_inst->currentVersionId()); + m_inst->currentVersionId()); if (vselect.exec() && vselect.selectedVersion()) { LiteLoaderVersionPtr liteloaderVersion = - std::dynamic_pointer_cast(vselect.selectedVersion()); + std::dynamic_pointer_cast(vselect.selectedVersion()); if (!liteloaderVersion) return; LiteLoaderInstaller liteloader(liteloaderVersion); @@ -247,7 +274,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked() } else { - m_inst->reloadVersion(); + reloadInstanceVersion(); } } } @@ -369,7 +396,8 @@ void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previou ui->frame->updateWithMod(m); } -void OneSixModEditDialog::versionCurrent(const QModelIndex ¤t, const QModelIndex &previous) +void OneSixModEditDialog::versionCurrent(const QModelIndex ¤t, + const QModelIndex &previous) { if (!current.isValid()) { diff --git a/gui/dialogs/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h index 1f3f9f67..e106c6fe 100644 --- a/gui/dialogs/OneSixModEditDialog.h +++ b/gui/dialogs/OneSixModEditDialog.h @@ -57,6 +57,8 @@ protected: bool eventFilter(QObject *obj, QEvent *ev); bool loaderListFilter(QKeyEvent *ev); bool resourcePackListFilter(QKeyEvent *ev); + /// FIXME: this shouldn't be necessary! + bool reloadInstanceVersion(); private: Ui::OneSixModEditDialog *ui; @@ -66,8 +68,6 @@ private: EnabledItemFilter *main_model; OneSixInstance *m_inst; - QMap getExistingOrder() const; - public slots: void loaderCurrent(QModelIndex current, QModelIndex previous); diff --git a/logic/MMCJson.h b/logic/MMCJson.h index b0d898fc..f2cc4b31 100644 --- a/logic/MMCJson.h +++ b/logic/MMCJson.h @@ -15,10 +15,6 @@ class JSONValidationError : public MMCError { public: JSONValidationError(QString cause) : MMCError(cause) {}; - virtual QString errorName() - { - return "JSONValidationError"; - }; virtual ~JSONValidationError() {}; }; diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp index cdb3f53e..8f70ed08 100644 --- a/logic/OneSixFTBInstance.cpp +++ b/logic/OneSixFTBInstance.cpp @@ -17,7 +17,14 @@ OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *set void OneSixFTBInstance::init() { - reloadVersion(); + try + { + reloadVersion(); + } + catch(MMCError & e) + { + // QLOG_ERROR() << "Caught exception on instance init: " << e.cause(); + } } void OneSixFTBInstance::copy(const QDir &newDir) diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index f6fe49f1..3c1f6545 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -41,9 +41,17 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, void OneSixInstance::init() { + // FIXME: why is this decided here? what does this even mean? if (QDir(instanceRoot()).exists("version.json")) { - reloadVersion(); + try + { + reloadVersion(); + } + catch(MMCError & e) + { + // QLOG_ERROR() << "Caught exception on instance init: " << e.cause(); + } } else { @@ -317,7 +325,7 @@ QString OneSixInstance::currentVersionId() const return intendedVersionId(); } -bool OneSixInstance::reloadVersion() +void OneSixInstance::reloadVersion() { I_D(OneSixInstance); @@ -327,16 +335,15 @@ bool OneSixInstance::reloadVersion() d->vanillaVersion->reload(true, externalPatches()); setFlags(flags() & ~VersionBrokenFlag); emit versionReloaded(); - return true; } - catch(MMCError error) + catch(MMCError & error) { d->version->clear(); d->vanillaVersion->clear(); setFlags(flags() | VersionBrokenFlag); //TODO: rethrow to show some error message(s)? emit versionReloaded(); - return false; + throw; } } diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index c7ef2ee8..d2bc9b01 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -53,8 +53,12 @@ public: virtual QDialog *createModEditDialog(QWidget *parent) override; - /// reload the full version json files. return true on success! - bool reloadVersion(); + /** + * reload the full version json files. return true on success! + * + * throws various exceptions :3 + */ + void reloadVersion(); /// clears all version information in preparation for an update void clearVersion(); /// get the current full version info diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 750aeabb..65f30cda 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -48,7 +48,7 @@ void OneSixUpdate::executeTask() QDir mcDir(m_inst->minecraftRoot()); if (!mcDir.exists() && !mcDir.mkpath(".")) { - emitFailed("Failed to create bin folder."); + emitFailed(tr("Failed to create folder for minecraft binaries.")); return; } @@ -60,7 +60,7 @@ void OneSixUpdate::executeTask() if (targetVersion == nullptr) { // don't do anything if it was invalid - emitFailed("The specified Minecraft version is invalid. Choose a different one."); + emitFailed(tr("The specified Minecraft version is invalid. Choose a different one.")); return; } versionFileStart(); @@ -108,20 +108,19 @@ void OneSixUpdate::versionFileFinished() QSaveFile vfile1(version1); if (!vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly)) { - emitFailed("Can't open " + version1 + " for writing."); + emitFailed(tr("Can't open %1 for writing.").arg(version1)); return; } auto data = std::dynamic_pointer_cast(DlJob)->m_data; qint64 actual = 0; if ((actual = vfile1.write(data)) != data.size()) { - emitFailed("Failed to write into " + version1 + ". Written " + actual + " out of " + - data.size() + '.'); + emitFailed(tr("Failed to write into %1. Written %2 out of %3.").arg(version1).arg(actual).arg(data.size())); return; } if (!vfile1.commit()) { - emitFailed("Can't commit changes to " + version1); + emitFailed(tr("Can't commit changes to %1").arg(version1)); return; } } @@ -136,14 +135,13 @@ void OneSixUpdate::versionFileFinished() { finfo.remove(); } - inst->reloadVersion(); - + // NOTE: Version is reloaded in jarlibStart jarlibStart(); } void OneSixUpdate::versionFileFailed() { - emitFailed("Failed to download the version description. Try again."); + emitFailed(tr("Failed to download the version description. Try again.")); } void OneSixUpdate::assetIndexStart() @@ -180,7 +178,7 @@ void OneSixUpdate::assetIndexFinished() QString asset_fname = "assets/indexes/" + assetName + ".json"; if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index)) { - emitFailed("Failed to read the assets index!"); + emitFailed(tr("Failed to read the assets index!")); } QList dls; @@ -216,7 +214,7 @@ void OneSixUpdate::assetIndexFinished() void OneSixUpdate::assetIndexFailed() { - emitFailed("Failed to download the assets index!"); + emitFailed(tr("Failed to download the assets index!")); } void OneSixUpdate::assetsFinished() @@ -226,7 +224,7 @@ void OneSixUpdate::assetsFinished() void OneSixUpdate::assetsFailed() { - emitFailed("Failed to download assets!"); + emitFailed(tr("Failed to download assets!")); } void OneSixUpdate::jarlibStart() @@ -234,11 +232,18 @@ void OneSixUpdate::jarlibStart() setStatus(tr("Getting the library files from Mojang...")); QLOG_INFO() << m_inst->name() << ": downloading libraries"; OneSixInstance *inst = (OneSixInstance *)m_inst; - bool successful = inst->reloadVersion(); - if (!successful) + try + { + inst->reloadVersion(); + } + catch(MMCError & e) + { + emitFailed(e.cause()); + return; + } + catch(...) { - emitFailed("Failed to load the version description file. It might be " - "corrupted, missing or simply too new."); + emitFailed(tr("Failed to load the version description file for reasons unknown.")); return; } @@ -326,6 +331,5 @@ void OneSixUpdate::jarlibFailed() { QStringList failed = jarlibDownloadJob->getFailedFiles(); QString failed_all = failed.join("\n"); - emitFailed("Failed to download the following files:\n" + failed_all + - "\n\nPlease try again."); + emitFailed(tr("Failed to download the following files:\n%1\n\nPlease try again.").arg(failed_all)); } diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 8abeb0d8..8eacbce4 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -38,7 +38,8 @@ OneSixVersionBuilder::OneSixVersionBuilder() { } -void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external) +void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, + const bool onlyVanilla, const QStringList &external) { OneSixVersionBuilder builder; builder.m_version = version; @@ -46,7 +47,8 @@ void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance builder.buildInternal(onlyVanilla, external); } -void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj) +void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, + const QJsonObject &obj) { OneSixVersionBuilder builder; builder.m_version = version; @@ -62,17 +64,19 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi QDir patches(root.absoluteFilePath("patches/")); // if we do external files, do just those. - if(!external.isEmpty()) for (auto fileName : external) - { - QLOG_INFO() << "Reading" << fileName; - auto file = parseJsonFile(QFileInfo(fileName), false, fileName.endsWith("pack.json")); - file->name = QFileInfo(fileName).fileName(); - file->fileId = "org.multimc.external." + file->name; - file->version = QString(); - file->mcVersion = QString(); - file->applyTo(m_version); - m_version->versionFiles.append(file); - } + if (!external.isEmpty()) + for (auto fileName : external) + { + QLOG_INFO() << "Reading" << fileName; + auto file = + parseJsonFile(QFileInfo(fileName), false, fileName.endsWith("pack.json")); + file->name = QFileInfo(fileName).fileName(); + file->fileId = "org.multimc.external." + file->name; + file->version = QString(); + file->mcVersion = QString(); + file->applyTo(m_version); + m_version->versionFiles.append(file); + } // else, if there's custom json, we just do that. else if (QFile::exists(root.absoluteFilePath("custom.json"))) { @@ -84,48 +88,52 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi file->version = QString(); file->applyTo(m_version); m_version->versionFiles.append(file); - // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); + // QObject::tr("The version descriptors of this instance are not compatible with the + // current version of MultiMC")); // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.") } // version.json -> patches/*.json -> user.json - else do - { - // version.json - QLOG_INFO() << "Reading version.json"; - auto file = parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false); - file->name = "Minecraft"; - file->fileId = "org.multimc.version.json"; - file->version = m_instance->intendedVersionId(); - file->mcVersion = m_instance->intendedVersionId(); - file->applyTo(m_version); - m_version->versionFiles.append(file); - // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json"))); + else + do + { + // version.json + QLOG_INFO() << "Reading version.json"; + auto file = parseJsonFile(QFileInfo(root.absoluteFilePath("version.json")), false); + file->name = "Minecraft"; + file->fileId = "org.multimc.version.json"; + file->version = m_instance->intendedVersionId(); + file->mcVersion = m_instance->intendedVersionId(); + file->applyTo(m_version); + m_version->versionFiles.append(file); + // QObject::tr("Error while applying %1. Please check MultiMC-0.log for more + // info.").arg(root.absoluteFilePath("version.json"))); - if (onlyVanilla) - break; + if (onlyVanilla) + break; - // patches/ - // load all, put into map for ordering, apply in the right order + // patches/ + // load all, put into map for ordering, apply in the right order - QMap> files; - for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) - { - QLOG_INFO() << "Reading" << info.fileName(); - auto file = parseJsonFile(info, true); - if (files.contains(file->order)) + QMap> files; + for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) { - throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file->fileId, files[file->order].second->fileId)); + QLOG_INFO() << "Reading" << info.fileName(); + auto file = parseJsonFile(info, true); + if (files.contains(file->order)) + { + throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg( + file->fileId, files[file->order].second->fileId)); + } + files.insert(file->order, qMakePair(info.fileName(), file)); } - files.insert(file->order, qMakePair(info.fileName(), file)); - } - for (auto order : files.keys()) - { - QLOG_DEBUG() << "Applying file with order" << order; - auto & filePair = files[order]; - filePair.second->applyTo(m_version); - m_version->versionFiles.append(filePair.second); - } - } while(0); + for (auto order : files.keys()) + { + QLOG_DEBUG() << "Applying file with order" << order; + auto &filePair = files[order]; + filePair.second->applyTo(m_version); + m_version->versionFiles.append(filePair.second); + } + } while (0); // some final touches finalizeVersion(); @@ -168,26 +176,30 @@ void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) file->applyTo(m_version); m_version->versionFiles.append(file); // QObject::tr("Error while applying. Please check MultiMC-0.log for more info.")); - // QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC")); + // QObject::tr("The version descriptors of this instance are not compatible with the current + // version of MultiMC")); } -VersionFilePtr OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB) +VersionFilePtr OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, + const bool requireOrder, bool isFTB) { QFile file(fileInfo.absoluteFilePath()); if (!file.open(QFile::ReadOnly)) { - throw JSONValidationError(QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString())); + throw JSONValidationError(QObject::tr("Unable to open the version file %1: %2.") + .arg(fileInfo.fileName(), file.errorString())); } QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error); if (error.error != QJsonParseError::NoError) { - throw JSONValidationError(QObject::tr("Unable to parse %1: %2 at %3") - .arg(file.fileName(), error.errorString()) - .arg(error.offset)); + throw JSONValidationError(QObject::tr("Unable to process the version file %1: %2 at %3.") + .arg(fileInfo.fileName(), error.errorString()) + .arg(error.offset)); } return VersionFile::fromJson(doc, file.fileName(), requireOrder, isFTB); - // QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.").arg(file.fileName()); + // QObject::tr("Error while reading %1. Please check MultiMC-0.log for more + // info.").arg(file.fileName()); } QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *instance) @@ -203,7 +215,7 @@ QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *inst if (!orderFile.open(QFile::ReadOnly)) { QLOG_ERROR() << "Couldn't open" << orderFile.fileName() - << " for reading:" << orderFile.errorString(); + << " for reading:" << orderFile.errorString(); QLOG_WARN() << "Ignoring overriden order"; return out; } @@ -211,9 +223,9 @@ QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *inst // and it's valid JSON QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(orderFile.readAll(), &error); - if (error.error != QJsonParseError::NoError ) + if (error.error != QJsonParseError::NoError) { - QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ":" << error.errorString(); + QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ":" << error.errorString(); QLOG_WARN() << "Ignoring overriden order"; return out; } @@ -231,7 +243,7 @@ QMap OneSixVersionBuilder::readOverrideOrders(OneSixInstance *inst out.insert(it.key(), MMCJson::ensureInteger(it.value())); } } - catch (JSONValidationError err) + catch (JSONValidationError &err) { QLOG_ERROR() << "Couldn't parse" << orderFile.fileName() << ": bad file format"; QLOG_WARN() << "Ignoring overriden order"; @@ -262,4 +274,3 @@ bool OneSixVersionBuilder::writeOverrideOrders(const QMap &order, orderFile.write(QJsonDocument(obj).toJson(QJsonDocument::Indented)); return true; } - diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp index 40dcb0c3..831b086e 100644 --- a/logic/VersionFile.cpp +++ b/logic/VersionFile.cpp @@ -311,9 +311,7 @@ void VersionFile::applyTo(VersionFinal *version) { if (minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION) { - throw VersionBuildError( - QString("%1 is for a different launcher version (%2), current supported is %3") - .arg(filename, minimumLauncherVersion, CURRENT_MINIMUM_LAUNCHER_VERSION)); + throw LauncherVersionError(minimumLauncherVersion, CURRENT_MINIMUM_LAUNCHER_VERSION); } } @@ -322,8 +320,7 @@ void VersionFile::applyTo(VersionFinal *version) if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(version->id) == -1) { - throw VersionBuildError( - QString("%1 is for a different version of Minecraft").arg(filename)); + throw MinecraftVersionMismatch(fileId, mcVersion, version->id); } } @@ -471,7 +468,7 @@ void VersionFile::applyTo(VersionFinal *version) (lib->dependType == RawLibrary::Hard && ourVersion != otherVersion)) { throw VersionBuildError( - QString( + QObject::tr( "Error resolving library dependencies between %1 and %2 in %3.") .arg(otherLib->rawName(), lib->name, filename)); } @@ -498,7 +495,7 @@ void VersionFile::applyTo(VersionFinal *version) // it: fail if (lib->dependType == RawLibrary::Hard) { - throw VersionBuildError(QString( + throw VersionBuildError(QObject::tr( "Error resolving library dependencies between %1 and %2 in %3.") .arg(otherLib->rawName(), lib->name, filename)); diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 504fcbff..67d22b23 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -13,13 +13,39 @@ class VersionBuildError : public MMCError { public: VersionBuildError(QString cause) : MMCError(cause) {}; - virtual QString errorName() - { - return "VersionBuildError"; - }; virtual ~VersionBuildError() {}; }; +/** + * the base version file was meant for a newer version of the vanilla launcher than we support + */ +class LauncherVersionError : public VersionBuildError +{ +public: + LauncherVersionError(int actual, int supported) + : VersionBuildError(QObject::tr( + "The base version file of this instance was meant for a newer (%1) " + "version of the vanilla launcher than this version of MultiMC supports (%2).") + .arg(actual) + .arg(supported)) {}; + virtual ~LauncherVersionError() {}; +}; + +/** + * some patch was intended for a different version of minecraft + */ +class MinecraftVersionMismatch : public VersionBuildError +{ +public: + MinecraftVersionMismatch(QString fileId, QString mcVersion, QString parentMcVersion) + : VersionBuildError(QObject::tr("The patch %1 is for a different version of Minecraft " + "(%2) than that of the instance (%3).") + .arg(fileId) + .arg(mcVersion) + .arg(parentMcVersion)) {}; + virtual ~MinecraftVersionMismatch() {}; +}; + struct RawLibrary; typedef std::shared_ptr RawLibraryPtr; struct RawLibrary @@ -61,7 +87,7 @@ struct VersionFile { public: /* methods */ static VersionFilePtr fromJson(const QJsonDocument &doc, const QString &filename, - const bool requireOrder, const bool isFTB = false); + const bool requireOrder, const bool isFTB = false); static OneSixLibraryPtr createLibrary(RawLibraryPtr lib); int findLibrary(QList haystack, const QString &needle); diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index 48601d57..a057ecdd 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -112,7 +112,7 @@ std::shared_ptr VersionFinal::fromJson(const QJsonObject &obj) { OneSixVersionBuilder::readJsonAndApplyToVersion(version.get(), obj); } - catch(MMCError err) + catch(MMCError & err) { return 0; } -- cgit v1.2.3 From 5328cc7bbee5044b41355ff702af9c62971acc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 10 Mar 2014 00:14:30 +0100 Subject: Add missing include for math.h --- logic/MMCJson.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/logic/MMCJson.cpp b/logic/MMCJson.cpp index 80d36204..25cc2de3 100644 --- a/logic/MMCJson.cpp +++ b/logic/MMCJson.cpp @@ -1,5 +1,6 @@ #include "MMCJson.h" #include +#include bool MMCJson::ensureBoolean(const QJsonValue val, const QString what) { -- cgit v1.2.3 From d11f10ea1ed54336254838ff068258d2d42e0774 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 10 Mar 2014 18:55:54 +0100 Subject: Fix a compiling error by adding noexcept --- MMCError.h | 2 +- logic/MMCJson.h | 2 +- logic/VersionFile.h | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MMCError.h b/MMCError.h index 7b2bd0c4..1f72b7a4 100644 --- a/MMCError.h +++ b/MMCError.h @@ -11,7 +11,7 @@ public: exceptionCause = cause; QLOG_ERROR() << "Exception: " + cause; }; - virtual ~MMCError(){}; + virtual ~MMCError() noexcept {} virtual const char *what() const noexcept { return exceptionCause.toLocal8Bit(); diff --git a/logic/MMCJson.h b/logic/MMCJson.h index f2cc4b31..71ded435 100644 --- a/logic/MMCJson.h +++ b/logic/MMCJson.h @@ -15,7 +15,7 @@ class JSONValidationError : public MMCError { public: JSONValidationError(QString cause) : MMCError(cause) {}; - virtual ~JSONValidationError() {}; + virtual ~JSONValidationError() noexcept {} }; namespace MMCJson diff --git a/logic/VersionFile.h b/logic/VersionFile.h index 67d22b23..169a2066 100644 --- a/logic/VersionFile.h +++ b/logic/VersionFile.h @@ -13,7 +13,7 @@ class VersionBuildError : public MMCError { public: VersionBuildError(QString cause) : MMCError(cause) {}; - virtual ~VersionBuildError() {}; + virtual ~VersionBuildError() noexcept {} }; /** @@ -28,7 +28,7 @@ public: "version of the vanilla launcher than this version of MultiMC supports (%2).") .arg(actual) .arg(supported)) {}; - virtual ~LauncherVersionError() {}; + virtual ~LauncherVersionError() noexcept {} }; /** @@ -43,7 +43,7 @@ public: .arg(fileId) .arg(mcVersion) .arg(parentMcVersion)) {}; - virtual ~MinecraftVersionMismatch() {}; + virtual ~MinecraftVersionMismatch() noexcept {} }; struct RawLibrary; @@ -124,4 +124,4 @@ public: /* data */ QList overwriteLibs; QList addLibs; QList removeLibs; -}; \ No newline at end of file +}; -- cgit v1.2.3