diff options
| author | Andrew <forkk@forkk.net> | 2013-01-25 12:35:14 -0600 |
|---|---|---|
| committer | Andrew <forkk@forkk.net> | 2013-01-25 12:35:14 -0600 |
| commit | f5ee069ea989a07915eb20c62ec4e812dfa9e701 (patch) | |
| tree | 7d2895bf49925aa6ef7cc91caf9a01de694b2eee | |
| parent | 3b422b54aa13be4eb59c80b1f7bb2a514aac583f (diff) | |
| parent | 00893b3cfc68f12c09e84643d255044a488b0eb6 (diff) | |
| download | PrismLauncher-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.gz PrismLauncher-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.bz2 PrismLauncher-f5ee069ea989a07915eb20c62ec4e812dfa9e701.zip | |
Merge branch 'master' of git://github.com/peterix/MultiMC5
82 files changed, 17996 insertions, 122 deletions
@@ -1 +1,6 @@ Thumbs.db +.kdev4 +MultiMC5.kdev4 +build +resources/CMakeFiles +resources/MultiMCLauncher.jar diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..05513f2c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,162 @@ +cmake_minimum_required(VERSION 2.8.9) +project(multimc5) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + + +#### Check for machine endianness #### +INCLUDE(TestBigEndian) +TEST_BIG_ENDIAN(BIGENDIAN) +IF(${BIGENDIAN}) + ADD_DEFINITIONS(-DMULTIMC_BIG_ENDIAN) +ENDIF(${BIGENDIAN}) + +# First, include header overrides +include_directories(hacks) + +#### Find the required Qt parts #### +find_package(Qt5Widgets) +#find_package(Qt5Declarative) + +include_directories(${Qt5Widgets_INCLUDE_DIRS}) + +# find ZLIB for quazip +find_package(ZLIB REQUIRED) + +# Find boost. +set(Boost_USE_STATIC_LIBS ON) +MESSAGE(STATUS "** Finding Boost...") +find_package(Boost 1.46.0 REQUIRED) +MESSAGE(STATUS "** Boost Include: ${Boost_INCLUDE_DIR}") +MESSAGE(STATUS "** Boost Libraries: ${Boost_LIBRARY_DIRS}") + +# Include boost. +include_directories("${Boost_INCLUDE_DIRS}") + +# Add quazip +add_subdirectory(quazip) + +# Add bspatch +add_subdirectory(patchlib) +include_directories(patchlib) + +# add the java launcher +add_subdirectory(launcher) + +IF(UNIX) + # assume GCC, add C++0x/C++11 stuff + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +ELSEIF(MINGW) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") +ENDIF() + +# Set the path where CMake will look for modules. +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") + + +set(MultiMC_VERSION_MAJOR 5) +set(MultiMC_VERSION_MINOR 0) +set(MultiMC_VERSION_REV 0) + +SET(MultiMC_VERSION_BUILD 0 CACHE STRING "Build number.") +message(STATUS "MultiMC build #${MultiMC_VERSION_BUILD}") + +IF (DEFINED MultiMC_BUILD_TAG) + message(STATUS "Build tag: ${MultiMC_BUILD_TAG}") +ELSE () + message(STATUS "No build tag specified.") +ENDIF () + +if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + set (MultiMC_ARCH "x64" + CACHE STRING "Architecture we're building for.") +else() + set (MultiMC_ARCH "x86" + CACHE STRING "Architecture we're building for.") +endif() +message (STATUS "Architecture is ${MultiMC_ARCH}") + +SET(MultiMC_Extra_Label "") + +IF (WIN32) + SET(MultiMC_JOB_NAME "MultiMC4Windows" CACHE STRING "Jenkins job name.") +ELSEIF(UNIX AND APPLE) + SET(MultiMC_JOB_NAME "MultiMC4OSX" CACHE STRING "Jenkins job name.") + # This is here because the scheme doesn't exactly apply to every kind of build... + SET(MultiMC_Extra_Label ",label=osx") +ELSE() + SET(MultiMC_JOB_NAME "MultiMC4Linux" CACHE STRING "Jenkins job name.") +ENDIF() + +SET(MultiMC_JOB_URL "http://ci.forkk.net/job/${MultiMC_JOB_NAME}/arch=${MultiMC_ARCH}${MultiMC_Extra_Label}/" + CACHE STRING "URL of the jenkins job to pull updates from.") +message(STATUS "Job URL: ${MultiMC_JOB_URL}") + +configure_file("${PROJECT_SOURCE_DIR}/config.h.in" + "${PROJECT_BINARY_DIR}/config.h") + + +SET(MULTIMC_SOURCES +main.cpp + +data/appsettings.cpp +data/inifile.cpp +data/instancebase.cpp +data/instancemodel.cpp +data/settingsbase.cpp +data/stdinstance.cpp + +gui/mainwindow.cpp +gui/modeditwindow.cpp +gui/settingsdialog.cpp + +util/pathutils.cpp + +java/javautils.cpp +java/annotations.cpp +) + +SET(MULTIMC_HEADERS +gui/mainwindow.h +gui/modeditwindow.h +gui/settingsdialog.h + +data/appsettings.h +data/inifile.h +data/instancebase.h +data/instancemodel.h +data/settingsbase.h +data/settingsmacros.h +data/settingsmacrosundef.h +data/stdinstance.h + +util/pathutils.h + +multimc_pragma.h + +java/annotations.h +java/classfile.h +java/constants.h +java/endian.h +java/errors.h +java/javautils.h +java/membuffer.h +) + +SET(MULTIMC5_UIS +gui/mainwindow.ui +gui/modeditwindow.ui +gui/settingsdialog.ui +) + +SET_SOURCE_FILES_PROPERTIES(resources/MultiMCLauncher.jar GENERATED) + +QT5_WRAP_UI(MULTIMC_UI ${MULTIMC5_UIS}) +QT5_ADD_RESOURCES(MULTIMC_QRC multimc.qrc) + +add_executable(multimc5 ${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC}) +qt5_use_modules(multimc5 Widgets) +target_link_libraries(multimc5 quazip patchlib) +add_dependencies(multimc5 MultiMCLauncher) +install(TARGETS multimc5 RUNTIME DESTINATION bin) diff --git a/config.h.in b/config.h.in new file mode 100644 index 00000000..de53ac93 --- /dev/null +++ b/config.h.in @@ -0,0 +1,17 @@ +#define VERSION_MAJOR @MultiMC_VERSION_MAJOR@ +#define VERSION_MINOR @MultiMC_VERSION_MINOR@ +#define VERSION_REVISION @MultiMC_VERSION_REV@ +#define VERSION_BUILD @MultiMC_VERSION_BUILD@ + +#define VERSION_STR "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_REV@.@MultiMC_VERSION_BUILD@" + +#define x86 1 +#define x64 2 + +#define ARCH @MultiMC_ARCH@ + +#define JENKINS_BUILD_TAG "@MultiMC_BUILD_TAG@" + +#define JENKINS_JOB_URL "@MultiMC_JOB_URL@" + +#define USE_HTTPS @MultiMC_USE_HTTPS@ diff --git a/data/inifile.cpp b/data/inifile.cpp index df94e43e..2d68caf6 100644 --- a/data/inifile.cpp +++ b/data/inifile.cpp @@ -49,12 +49,23 @@ bool INIFile::loadFile(QString fileName) QStringList lines = in.readAll().split('\n'); for (int i = 0; i < lines.count(); i++) { + QString & lineRaw = lines[i]; // Ignore comments. - QString line = lines[i].left('#').trimmed(); + QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed(); - QString key = line.section('=', 0).trimmed(); - QVariant value(line.section('=', 1).trimmed()); + int eqPos = line.indexOf('='); + if(eqPos == -1) + continue; + QString key = line.left(eqPos).trimmed(); + QString valueStr = line.right(line.length() - eqPos - 1).trimmed(); + QVariant value(valueStr); + /* + QString dbg = key; + dbg += " = "; + dbg += valueStr; + qDebug(dbg.toLocal8Bit()); + */ this->operator [](key) = value; } diff --git a/data/instancebase.cpp b/data/instancebase.cpp index 15dc54f4..a5ef35a2 100644 --- a/data/instancebase.cpp +++ b/data/instancebase.cpp @@ -16,6 +16,7 @@ #include "instancebase.h" #include <QFileInfo> +#include <QDir> #include "../util/pathutils.h" @@ -23,10 +24,27 @@ InstanceBase::InstanceBase(QString dir, QObject *parent) : QObject(parent), rootDir(dir) { - QFileInfo cfgFile; + QFileInfo cfgFile(PathCombine(rootDir, "instance.cfg")); if (cfgFile.exists()) - config.loadFile(PathCombine(rootDir, "instance.cfg")); + { + if(!config.loadFile(cfgFile.absoluteFilePath())) + { + QString debugmsg("Can't load instance config file for instance "); + debugmsg+= getInstID(); + qDebug(debugmsg.toLocal8Bit()); + } + } + else + { + QString debugmsg("Can't find instance config file for instance "); + debugmsg+= getInstID(); + debugmsg += " : "; + debugmsg += + debugmsg+=" ... is this an instance even?"; + qDebug(debugmsg.toLocal8Bit()); + } + currentGroup = nullptr; } QString InstanceBase::getRootDir() const @@ -47,3 +65,45 @@ void InstanceBase::setInstName(QString name) { config.set("name", name); } + +QString InstanceBase::getInstID() const +{ + return QDir(rootDir).dirName(); +} + +InstanceModelItem* InstanceBase::getParent() const +{ + return currentGroup; +} + +QVariant InstanceBase::data ( int role ) const +{ + switch(role) + { + case Qt::DisplayRole: + return getInstName(); + default: + return QVariant(); + } +} +int InstanceBase::getRow() const +{ + return currentGroup->getIndexOf((InstanceBase*)this); +} + +InstanceModelItem* InstanceBase::getChild ( int index ) const +{ + return nullptr; +} +InstanceModel* InstanceBase::getModel() const +{ + return currentGroup->getModel(); +} +IMI_type InstanceBase::getModelItemType() const +{ + return IMI_Instance; +} +int InstanceBase::numChildren() const +{ + return 0; +} diff --git a/data/instancebase.h b/data/instancebase.h index 8c61aee0..fa043c5f 100644 --- a/data/instancebase.h +++ b/data/instancebase.h @@ -20,9 +20,11 @@ #include <QString> #include "../data/inifile.h" +#include "instancemodel.h" -class InstanceBase : public QObject +class InstanceBase : public QObject, public InstanceModelItem { + friend class InstanceGroup; Q_OBJECT public: explicit InstanceBase(QString rootDir, QObject *parent = 0); @@ -32,13 +34,25 @@ public: QString getInstName() const; void setInstName(QString name); -protected: + QString getInstID() const; + virtual IMI_type getModelItemType() const; + virtual InstanceModelItem* getParent() const; + virtual int numChildren() const; + virtual InstanceModelItem* getChild ( int index ) const; + virtual InstanceModel* getModel() const; + virtual QVariant data ( int column ) const; + virtual int getRow() const; private: - QString rootDir; + void setGroup ( InstanceGroup* group ) + { + currentGroup = group; + }; + QString rootDir; INIFile config; + InstanceGroup * currentGroup; }; #endif // INSTANCEBASE_H diff --git a/data/instancelist.cpp b/data/instancelist.cpp deleted file mode 100644 index 7385ba86..00000000 --- a/data/instancelist.cpp +++ /dev/null @@ -1,52 +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 "instancelist.h" - -#include <QDir> -#include <QDirIterator> - -#include "stdinstance.h" - -#include "../util/pathutils.h" - -InstanceList::InstanceList() : - QList() -{ - -} - -void InstanceList::addInstance(InstanceBase *inst) -{ - append(inst); -} - -void InstanceList::loadInstances(QString dir) -{ - qDebug("Loading instances"); - QDir instDir(dir); - QDirIterator iter(instDir); - - while (iter.hasNext()) - { - QString subDir = iter.next(); - if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) - { - // TODO Differentiate between different instance types. - InstanceBase* inst = new StdInstance(subDir); - addInstance(inst); - } - } -} diff --git a/data/instancemodel.cpp b/data/instancemodel.cpp new file mode 100644 index 00000000..239be5c5 --- /dev/null +++ b/data/instancemodel.cpp @@ -0,0 +1,403 @@ +/* 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 "instancemodel.h" + +#include <QString> +#include <QDir> +#include <QDirIterator> +#include "stdinstance.h" + +#include "../util/pathutils.h" + +#include <boost/property_tree/json_parser.hpp> +#include <boost/foreach.hpp> + + +#define GROUP_FILE_FORMAT_VERSION 1 + +InstanceModel::InstanceModel( QObject* parent ) : + QAbstractItemModel() +{ +} + +InstanceModel::~InstanceModel() +{ + saveGroupInfo(); + for(int i = 0; i < groups.size(); i++) + { + delete groups[i]; + } +} + +void InstanceModel::addInstance( InstanceBase* inst, const QString& groupName ) +{ + auto group = getGroupByName(groupName); + group->addInstance(inst); +} + +void InstanceGroup::addInstance ( InstanceBase* inst ) +{ + instances.append(inst); + inst->setGroup(this); + // TODO: notify model. +} + + +void InstanceModel::initialLoad(QString dir) +{ + groupFile = dir + "/instgroups.json"; + implicitGroup = new InstanceGroup("Ungrouped", this); + groups.append(implicitGroup); + + // temporary map from instance ID to group name + QMap<QString, QString> groupMap; + + using namespace boost::property_tree; + ptree pt; + + try + { + read_json(groupFile.toStdString(), pt); + + if (pt.get_optional<int>("formatVersion") != GROUP_FILE_FORMAT_VERSION) + { + // TODO: Discard old formats. + } + + BOOST_FOREACH(const |
