summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-06-23 22:10:32 +0200
committerPetr Mrázek <peterix@gmail.com>2013-06-23 22:10:32 +0200
commit27b1de0d6d196d9d0f6c284e0cb772c077688c3e (patch)
treedaf8998763f549c28cac6be272fe50f70c00be0d
parentd9195bff3a6088bb0f116d61fc8c961e3ba4e3f2 (diff)
downloadMultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar
MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.gz
MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.lz
MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.xz
MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.zip
Implement some bits and pieces, disable dead buttons.
-rw-r--r--gui/mainwindow.cpp61
-rw-r--r--gui/mainwindow.h9
-rw-r--r--gui/mainwindow.ui25
-rw-r--r--gui/taskdialog.h2
-rw-r--r--libmultimc/include/instversion.h13
-rw-r--r--libmultimc/include/minecraftversion.h40
-rw-r--r--libmultimc/src/gameupdatetask.cpp3
-rw-r--r--libmultimc/src/instversion.cpp6
-rw-r--r--libmultimc/src/minecraftversion.cpp73
-rw-r--r--libmultimc/src/minecraftversionlist.cpp14
10 files changed, 127 insertions, 119 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index e60155c6..dda12941 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -64,7 +64,8 @@
// Opens the given file in the default application.
// TODO: Move this somewhere.
-void openInDefaultProgram ( QString filename );
+void openFileInDefaultProgram ( QString filename );
+void openDirInDefaultProgram ( QString dirpath, bool ensureExists = false );
MainWindow::MainWindow ( QWidget *parent ) :
QMainWindow ( parent ),
@@ -224,16 +225,22 @@ void MainWindow::on_actionChangeInstGroup_triggered()
Instance* inst = selectedInstance();
if(inst)
{
+ bool ok = false;
QString name ( inst->group() );
- name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ), QLineEdit::Normal, name );
- inst->setGroup(name);
+ QInputDialog dlg(this);
+ dlg.result();
+ name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ),
+ QLineEdit::Normal, name, &ok );
+ if(ok)
+ inst->setGroup(name);
}
}
void MainWindow::on_actionViewInstanceFolder_triggered()
{
- openInDefaultProgram ( globalSettings->get ( "InstanceDir" ).toString() );
+ QString str = globalSettings->get ( "InstanceDir" ).toString();
+ openDirInDefaultProgram ( str );
}
void MainWindow::on_actionRefresh_triggered()
@@ -243,7 +250,7 @@ void MainWindow::on_actionRefresh_triggered()
void MainWindow::on_actionViewCentralModsFolder_triggered()
{
- openInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() );
+ openDirInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() , true);
}
void MainWindow::on_actionCheckUpdate_triggered()
@@ -282,6 +289,37 @@ void MainWindow::on_mainToolBar_visibilityChanged ( bool )
ui->mainToolBar->setVisible ( true );
}
+void MainWindow::on_actionDeleteInstance_triggered()
+{
+
+}
+
+void MainWindow::on_actionRenameInstance_triggered()
+{
+ Instance* inst = selectedInstance();
+ if(inst)
+ {
+ bool ok = false;
+ QString name ( inst->name() );
+ name = QInputDialog::getText ( this, tr ( "Instance name" ), tr ( "Enter a new instance name." ),
+ QLineEdit::Normal, name, &ok );
+ //FIXME: dialog should do the validation!!!
+ if(ok && name.length() && name.length() <= 25)
+ inst->setName(name);
+ }
+}
+
+void MainWindow::on_actionViewSelectedInstFolder_triggered()
+{
+ Instance* inst = selectedInstance();
+ if(inst)
+ {
+ QString str = inst->rootDir();
+ openDirInDefaultProgram ( QDir(str).absolutePath() );
+ }
+}
+
+
void MainWindow::closeEvent ( QCloseEvent *event )
{
// Save the window state and geometry.
@@ -449,7 +487,18 @@ void MainWindow::openWebPage ( QUrl url )
browser->exec();
}
-void openInDefaultProgram ( QString filename )
+void openDirInDefaultProgram ( QString path, bool ensureExists )
+{
+ QDir parentPath;
+ QDir dir( path );
+ if(!dir.exists())
+ {
+ parentPath.mkpath(dir.absolutePath());
+ }
+ QDesktopServices::openUrl ( "file:///" + dir.absolutePath() );
+}
+
+void openFileInDefaultProgram ( QString filename )
{
QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() );
}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index a9a4d395..b861cbe7 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -63,6 +63,8 @@ private slots:
void on_actionChangeInstGroup_triggered();
void on_actionViewInstanceFolder_triggered();
+
+ void on_actionViewSelectedInstFolder_triggered();
void on_actionRefresh_triggered();
@@ -82,8 +84,11 @@ private slots:
void on_actionLaunchInstance_triggered();
-
- void on_actionMakeDesktopShortcut_triggered();
+ void on_actionDeleteInstance_triggered();
+
+ void on_actionRenameInstance_triggered();
+
+ void on_actionMakeDesktopShortcut_triggered();
void on_actionChangeInstMCVersion_triggered();
diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui
index fe6de6c9..44b8a31f 100644
--- a/gui/mainwindow.ui
+++ b/gui/mainwindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
- <height>400</height>
+ <width>692</width>
+ <height>596</height>
</rect>
</property>
<property name="windowTitle">
@@ -271,6 +271,9 @@
</property>
</action>
<action name="actionChangeInstIcon">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Change Icon</string>
</property>
@@ -282,6 +285,9 @@
</property>
</action>
<action name="actionEditInstNotes">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Edit Notes</string>
</property>
@@ -293,6 +299,9 @@
</property>
</action>
<action name="actionInstanceSettings">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Settings</string>
</property>
@@ -304,6 +313,9 @@
</property>
</action>
<action name="actionMakeDesktopShortcut">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Make Shortcut</string>
</property>
@@ -315,6 +327,9 @@
</property>
</action>
<action name="actionManageInstSaves">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Manage Saves</string>
</property>
@@ -326,6 +341,9 @@
</property>
</action>
<action name="actionEditInstMods">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Edit Mods</string>
</property>
@@ -359,6 +377,9 @@
</property>
</action>
<action name="actionRebuildInstJar">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Rebuild Jar</string>
</property>
diff --git a/gui/taskdialog.h b/gui/taskdialog.h
index faf3ed90..86cd4b54 100644
--- a/gui/taskdialog.h
+++ b/gui/taskdialog.h
@@ -45,8 +45,6 @@ public slots:
void changeStatus(const QString& status);
void changeProgress(int progress);
- void test() { qDebug("Lol"); }
-
signals:
diff --git a/libmultimc/include/instversion.h b/libmultimc/include/instversion.h
index 009bd412..af632939 100644
--- a/libmultimc/include/instversion.h
+++ b/libmultimc/include/instversion.h
@@ -50,18 +50,6 @@ class LIBMULTIMC_EXPORT InstVersion : public QObject
Q_PROPERTY(QString typeName READ typeName)
/*!
- * Whether or not this is a meta version.
- * Meta versions are not real versions, merely versions that act as aliases
- * for other versions.
- * For example: There could be a meta version called "Latest" that always
- * points to the latest version. The user would pick this version and when
- * a new version came out, it would point to the new one and update the instance
- * automatically.
- */
- Q_PROPERTY(bool isMeta READ isMeta)
-
-
- /*!
* Gets the version's timestamp.
* This is primarily used for sorting versions in a list.
*/
@@ -93,7 +81,6 @@ public:
virtual QString name() const;
virtual QString typeName() const = 0;
virtual qint64 timestamp() const;
- virtual bool isMeta() const;
virtual InstVersionList *versionList() const;
diff --git a/libmultimc/include/minecraftversion.h b/libmultimc/include/minecraftversion.h
index fd11b316..6f9b7879 100644
--- a/libmultimc/include/minecraftversion.h
+++ b/libmultimc/include/minecraftversion.h
@@ -30,6 +30,11 @@ class LIBMULTIMC_EXPORT MinecraftVersion : public InstVersion
Q_PROPERTY(VersionType versionType READ versionType WRITE setVersionType)
/*!
+ * This version's launcher. Used to identify the launcher version this is intended for.
+ */
+ Q_PROPERTY(LauncherVersion versionType READ launcherVersion WRITE setLauncherVersion)
+
+ /*!
* The URL that this version will be downloaded from.
*/
Q_PROPERTY(QString downloadURL READ downloadURL)
@@ -39,10 +44,6 @@ class LIBMULTIMC_EXPORT MinecraftVersion : public InstVersion
*/
Q_PROPERTY(QString etag READ etag)
- /*!
- * True if this is a version from the new Minecraft launcher's version list.
- */
- Q_PROPERTY(bool isForNewLauncher READ isForNewLauncher WRITE setIsForNewLauncher)
public:
explicit MinecraftVersion(QString descriptor,
@@ -52,15 +53,6 @@ public:
QString etag,
InstVersionList *parent = 0);
- /*!
- * Creates a meta version that links to the given version.
- * This is *NOT* a copy constructor.
- * \param linkedVersion the version that the meta version will link to.
- */
- explicit MinecraftVersion(const MinecraftVersion *linkedVersion);
-
- MinecraftVersion(const MinecraftVersion &other, QObject *parent);
-
static InstVersion *mcnVersion(QString rawName, QString niceName);
enum VersionType
@@ -69,10 +61,14 @@ public:
Stable,
CurrentStable,
Snapshot,
- MCNostalgia,
- MetaCustom,
- MetaLatestSnapshot,
- MetaLatestStable
+ MCNostalgia
+ };
+
+ enum LauncherVersion
+ {
+ Unknown = -1,
+ Legacy = 0, // the legacy launcher that's been around since ... forever
+ Launcher16 = 1, // current launcher as of 26/06/2013
};
virtual QString descriptor() const;
@@ -80,24 +76,22 @@ public:
virtual QString typeName() const;
virtual qint64 timestamp() const;
- virtual bool isForNewLauncher() const;
- virtual void setIsForNewLauncher(bool val);
-
virtual VersionType versionType() const;
virtual void setVersionType(VersionType typeName);
+ virtual LauncherVersion launcherVersion() const;
+ virtual void setLauncherVersion(LauncherVersion launcherVersion);
+
virtual QString downloadURL() const;
virtual QString etag() const;
- virtual bool isMeta() const;
virtual InstVersion *copyVersion(InstVersionList *newParent) const;
private:
- InstVersion *m_linkedVersion;
-
QString m_dlUrl;
QString m_etag;
VersionType m_type;
+ LauncherVersion m_launcherVersion;
bool m_isNewLauncherVersion;
};
diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp
index 114f4ede..c718ce71 100644
--- a/libmultimc/src/gameupdatetask.cpp
+++ b/libmultimc/src/gameupdatetask.cpp
@@ -73,7 +73,8 @@ void GameUpdateTask::executeTask()
// we're downloading from.
QString jarFilename = "minecraft";
- if (targetVersion->isForNewLauncher())
+ // FIXME: this is NOT enough
+ if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16)
jarFilename = targetVersion->descriptor();
QUrl mcJarURL = targetVersion->downloadURL() + jarFilename + ".jar";
diff --git a/libmultimc/src/instversion.cpp b/libmultimc/src/instversion.cpp
index ebd76c7a..4e42c364 100644
--- a/libmultimc/src/instversion.cpp
+++ b/libmultimc/src/instversion.cpp
@@ -51,12 +51,6 @@ bool InstVersion::isGreaterThan(const InstVersion &other) const
return timestamp() > other.timestamp();
}
-bool InstVersion::isMeta() const
-{
- return false;
-}
-
-
QString InstVersion::descriptor() const
{
return m_descriptor;
diff --git a/libmultimc/src/minecraftversion.cpp b/libmultimc/src/minecraftversion.cpp
index 7dee802f..36ba87f8 100644
--- a/libmultimc/src/minecraftversion.cpp
+++ b/libmultimc/src/minecraftversion.cpp
@@ -23,29 +23,9 @@ MinecraftVersion::MinecraftVersion(QString descriptor,
InstVersionList *parent) :
InstVersion(descriptor, name, timestamp, parent), m_dlUrl(dlUrl), m_etag(etag)
{
- m_linkedVersion = NULL;
m_isNewLauncherVersion = false;
}
-MinecraftVersion::MinecraftVersion(const MinecraftVersion *linkedVersion) :
- InstVersion(linkedVersion->descriptor(), linkedVersion->name(), linkedVersion->timestamp(),
- linkedVersion->versionList())
-{
- m_linkedVersion = (MinecraftVersion *)linkedVersion;
-}
-
-MinecraftVersion::MinecraftVersion(const MinecraftVersion &other, QObject *parent) :
- InstVersion(other, parent)
-{
- if (other.m_linkedVersion)
- m_linkedVersion = other.m_linkedVersion;
- else
- {
- m_dlUrl = other.downloadURL();
- m_etag = other.etag();
- }
-}
-
QString MinecraftVersion::descriptor() const
{
return m_descriptor;
@@ -58,9 +38,6 @@ QString MinecraftVersion::name() const
QString MinecraftVersion::typeName() const
{
- if (m_linkedVersion)
- return m_linkedVersion->typeName();
-
switch (versionType())
{
case OldSnapshot:
@@ -78,17 +55,6 @@ QString MinecraftVersion::typeName() const
case MCNostalgia:
return "MCNostalgia";
- case MetaCustom:
- // Not really sure what this does, but it was in the code for v4,
- // so it must be important... Right?
- return "Custom Meta Version";
-
- case MetaLatestSnapshot:
- return "Latest Snapshot";
-
- case MetaLatestStable:
- return "Latest Stable";
-
default:
return QString("Unknown Type %1").arg(versionType());
}
@@ -99,16 +65,6 @@ qint64 MinecraftVersion::timestamp() const
return m_timestamp;
}
-bool MinecraftVersion::isForNewLauncher() const
-{
- return m_isNewLauncherVersion;
-}
-
-void MinecraftVersion::setIsForNewLauncher(bool val)
-{
- m_isNewLauncherVersion = val;
-}
-
MinecraftVersion::VersionType MinecraftVersion::versionType() const
{
return m_type;
@@ -129,26 +85,21 @@ QString MinecraftVersion::etag() const
return m_etag;
}
-bool MinecraftVersion::isMeta() const
+MinecraftVersion::LauncherVersion MinecraftVersion::launcherVersion() const
{
- return versionType() == MetaCustom ||
- versionType() == MetaLatestSnapshot ||
- versionType() == MetaLatestStable;
+ return m_launcherVersion;
+};
+
+void MinecraftVersion::setLauncherVersion(LauncherVersion launcherVersion)
+{
+ m_launcherVersion = launcherVersion;
}
InstVersion *MinecraftVersion::copyVersion(InstVersionList *newParent) const
{
- if (isMeta())
- {
- MinecraftVersion *version = new MinecraftVersion((MinecraftVersion *)m_linkedVersion);
- return version;
- }
- else
- {
- MinecraftVersion *version = new MinecraftVersion(
- descriptor(), name(), timestamp(), downloadURL(), etag(), newParent);
- version->setVersionType(versionType());
- version->setIsForNewLauncher(isForNewLauncher());
- return version;
- }
+ MinecraftVersion *version = new MinecraftVersion(
+ descriptor(), name(), timestamp(), downloadURL(), etag(), newParent);
+ version->setVersionType(versionType());
+ version->setLauncherVersion(launcherVersion());
+ return version;
}
diff --git a/libmultimc/src/minecraftversionlist.cpp b/libmultimc/src/minecraftversionlist.cpp
index 71deb471..17737b1e 100644
--- a/libmultimc/src/minecraftversionlist.cpp
+++ b/libmultimc/src/minecraftversionlist.cpp
@@ -200,6 +200,7 @@ void MCVListLoadTask::setSubStatus(const QString msg)
setStatus("Loading instance version list: " + msg);
}
+// FIXME: we should have a local cache of the version list and a local cache of version data
bool MCVListLoadTask::loadFromVList()
{
QNetworkReply *vlistReply = netMgr->get(QNetworkRequest(QUrl(QString(MCVLIST_URLBASE) +
@@ -276,10 +277,15 @@ bool MCVListLoadTask::loadFromVList()
else
versionType = MinecraftVersion::Stable;
}
- else
+ else if(versionTypeStr == "snapshot")
{
versionType = MinecraftVersion::Snapshot;
}
+ else
+ {
+ // we don't know what to do with this...
+ continue;
+ }
// Get the download URL.
QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
@@ -289,7 +295,7 @@ bool MCVListLoadTask::loadFromVList()
MinecraftVersion *mcVersion = new MinecraftVersion(
versionID, versionID, versionTime.toMSecsSinceEpoch(),
dlUrl, "");
- mcVersion->setIsForNewLauncher(true);
+ mcVersion->setLauncherVersion(MinecraftVersion::Launcher16);
mcVersion->setVersionType(versionType);
tempList.append(mcVersion);
}
@@ -340,7 +346,7 @@ bool MCVListLoadTask::loadFromAssets()
QDomNodeList contents = doc.elementsByTagName("Contents");
QRegExp mcRegex("/minecraft.jar$");
- QRegExp snapshotRegex("[0-9][0-9]w[0-9][0-9][a-z]|pre|rc");
+ QRegExp snapshotRegex("[0-9][0-9]w[0-9][0-9][a-z]?|pre|rc");
for (int i = 0; i < contents.length(); i++)
{
@@ -443,6 +449,8 @@ bool MCVListLoadTask::loadMCNostalgia()
{
QNetworkReply *mcnReply = netMgr->get(QNetworkRequest(QUrl(QString(MCN_URLBASE) + "?pversion=1&list=True")));
NetUtils::waitForNetRequest(mcnReply);
+ processedMCNReply = true;
+ updateStuff();
return true;
}