Add mod website button thing feature widget. It is super effective.
This commit is contained in:
parent
a58912eaf7
commit
05e2da51d8
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
//#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -343,3 +344,35 @@ void LegacyModEditDialog::on_buttonBox_rejected()
|
|||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME: too much copypasta makes peterix a sad hacker. BUT IT'S SO DELICIOUS!
|
||||||
|
|
||||||
|
void LegacyModEditDialog::on_coreWebsite_clicked()
|
||||||
|
{
|
||||||
|
int first, last;
|
||||||
|
auto list = ui->coreModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (!lastfirst(list, first, last))
|
||||||
|
return;
|
||||||
|
showWebsiteForMod(this, m_coremods->operator[](first));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LegacyModEditDialog::on_jarWebsite_clicked()
|
||||||
|
{
|
||||||
|
int first, last;
|
||||||
|
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (!lastfirst(list, first, last))
|
||||||
|
return;
|
||||||
|
showWebsiteForMod(this, m_jarmods->operator[](first));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LegacyModEditDialog::on_loaderWebsite_clicked()
|
||||||
|
{
|
||||||
|
int first, last;
|
||||||
|
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (!lastfirst(list, first, last))
|
||||||
|
return;
|
||||||
|
showWebsiteForMod(this, m_mods->operator[](first));
|
||||||
|
}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
#include "logic/LegacyInstance.h"
|
#include "logic/LegacyInstance.h"
|
||||||
#include <logic/net/DownloadJob.h>
|
#include <logic/net/DownloadJob.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class LegacyModEditDialog;
|
class LegacyModEditDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +32,8 @@ public:
|
|||||||
explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0);
|
explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0);
|
||||||
~LegacyModEditDialog();
|
~LegacyModEditDialog();
|
||||||
|
|
||||||
private slots:
|
private
|
||||||
|
slots:
|
||||||
|
|
||||||
void on_addJarBtn_clicked();
|
void on_addJarBtn_clicked();
|
||||||
void on_rmJarBtn_clicked();
|
void on_rmJarBtn_clicked();
|
||||||
@ -50,14 +52,21 @@ private slots:
|
|||||||
void on_addTexPackBtn_clicked();
|
void on_addTexPackBtn_clicked();
|
||||||
void on_rmTexPackBtn_clicked();
|
void on_rmTexPackBtn_clicked();
|
||||||
void on_viewTexPackBtn_clicked();
|
void on_viewTexPackBtn_clicked();
|
||||||
|
|
||||||
|
void on_jarWebsite_clicked();
|
||||||
|
void on_loaderWebsite_clicked();
|
||||||
|
void on_coreWebsite_clicked();
|
||||||
|
|
||||||
// Questionable: SettingsDialog doesn't need this for some reason?
|
// Questionable: SettingsDialog doesn't need this for some reason?
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
bool jarListFilter(QKeyEvent *ev);
|
bool jarListFilter(QKeyEvent *ev);
|
||||||
bool coreListFilter(QKeyEvent *ev);
|
bool coreListFilter(QKeyEvent *ev);
|
||||||
bool loaderListFilter(QKeyEvent *ev);
|
bool loaderListFilter(QKeyEvent *ev);
|
||||||
bool texturePackListFilter(QKeyEvent *ev);
|
bool texturePackListFilter(QKeyEvent *ev);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LegacyModEditDialog *ui;
|
Ui::LegacyModEditDialog *ui;
|
||||||
std::shared_ptr<ModList> m_mods;
|
std::shared_ptr<ModList> m_mods;
|
||||||
|
@ -57,6 +57,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="jarWebsite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Website</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="jarModsButtonSpacer">
|
<spacer name="jarModsButtonSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -116,6 +123,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="coreWebsite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Website</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="coreModsButtonSpacer">
|
<spacer name="coreModsButtonSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -171,6 +185,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loaderWebsite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Website</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="mlModsButtonSpacer">
|
<spacer name="mlModsButtonSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#include "ModEditDialogCommon.h"
|
#include "ModEditDialogCommon.h"
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
bool lastfirst(QModelIndexList &list, int &first, int &last)
|
bool lastfirst(QModelIndexList &list, int &first, int &last)
|
||||||
{
|
{
|
||||||
if (!list.size())
|
if (!list.size())
|
||||||
@ -15,3 +18,23 @@ bool lastfirst (QModelIndexList & list, int & first, int & last)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showWebsiteForMod(QWidget *parentDlg, Mod &m)
|
||||||
|
{
|
||||||
|
QString url = m.homeurl();
|
||||||
|
if (url.size())
|
||||||
|
{
|
||||||
|
// catch the cases where the protocol is missing
|
||||||
|
if(!url.startsWith("http"))
|
||||||
|
{
|
||||||
|
url = "http://" + url;
|
||||||
|
}
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(
|
||||||
|
parentDlg, parentDlg->tr("How sad!"),
|
||||||
|
parentDlg->tr("The mod author didn't provide a website link for this mod."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <logic/Mod.h>
|
||||||
|
|
||||||
bool lastfirst (QModelIndexList & list, int & first, int & last);
|
bool lastfirst (QModelIndexList & list, int & first, int & last);
|
||||||
|
|
||||||
|
void showWebsiteForMod(QWidget * parentDlg, Mod& m);
|
@ -30,6 +30,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||||
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
|
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
|
||||||
@ -296,3 +297,13 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked()
|
|||||||
{
|
{
|
||||||
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_loaderWebsite_clicked()
|
||||||
|
{
|
||||||
|
int first, last;
|
||||||
|
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (!lastfirst(list, first, last))
|
||||||
|
return;
|
||||||
|
showWebsiteForMod(this, m_mods->operator[](first));
|
||||||
|
}
|
||||||
|
@ -44,6 +44,7 @@ private slots:
|
|||||||
void on_forgeBtn_clicked();
|
void on_forgeBtn_clicked();
|
||||||
void on_customizeBtn_clicked();
|
void on_customizeBtn_clicked();
|
||||||
void on_revertBtn_clicked();
|
void on_revertBtn_clicked();
|
||||||
|
void on_loaderWebsite_clicked();
|
||||||
void updateVersionControls();
|
void updateVersionControls();
|
||||||
void disableVersionControls();
|
void disableVersionControls();
|
||||||
protected:
|
protected:
|
||||||
|
@ -184,6 +184,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loaderWebsite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Website</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -118,8 +118,10 @@ void Mod::ReadMCModInfo(QByteArray contents)
|
|||||||
m_id = firstObj.value("modid").toString();
|
m_id = firstObj.value("modid").toString();
|
||||||
m_name = firstObj.value("name").toString();
|
m_name = firstObj.value("name").toString();
|
||||||
m_version = firstObj.value("version").toString();
|
m_version = firstObj.value("version").toString();
|
||||||
|
m_homeurl = firstObj.value("url").toString();
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
|
||||||
// this is the very old format that had just the array
|
// this is the very old format that had just the array
|
||||||
@ -150,6 +152,7 @@ void Mod::ReadForgeInfo(QByteArray contents)
|
|||||||
// Read the data
|
// Read the data
|
||||||
m_name = "Minecraft Forge";
|
m_name = "Minecraft Forge";
|
||||||
m_id = "Forge";
|
m_id = "Forge";
|
||||||
|
m_homeurl = "http://www.minecraftforge.net/forum/";
|
||||||
INIFile ini;
|
INIFile ini;
|
||||||
if (!ini.loadFile(contents))
|
if (!ini.loadFile(contents))
|
||||||
return;
|
return;
|
||||||
@ -212,7 +215,6 @@ bool Mod::destroy()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Mod::version() const
|
QString Mod::version() const
|
||||||
{
|
{
|
||||||
switch (type())
|
switch (type())
|
||||||
|
41
logic/Mod.h
41
logic/Mod.h
@ -30,15 +30,38 @@ public:
|
|||||||
|
|
||||||
Mod(const QFileInfo &file);
|
Mod(const QFileInfo &file);
|
||||||
|
|
||||||
QFileInfo filename() const { return m_file; }
|
QFileInfo filename() const
|
||||||
QString id() const { return m_id; }
|
{
|
||||||
ModType type() const { return m_type; }
|
return m_file;
|
||||||
QString mcversion() const { return m_mcversion; };
|
}
|
||||||
bool valid() {return m_type != MOD_UNKNOWN;}
|
QString id() const
|
||||||
QString name() const {return m_name; };
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
ModType type() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
QString mcversion() const
|
||||||
|
{
|
||||||
|
return m_mcversion;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
bool valid()
|
||||||
|
{
|
||||||
|
return m_type != MOD_UNKNOWN;
|
||||||
|
}
|
||||||
|
QString name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
QString version() const;
|
QString version() const;
|
||||||
|
|
||||||
|
QString homeurl() const
|
||||||
|
{
|
||||||
|
return m_homeurl;
|
||||||
|
}
|
||||||
|
|
||||||
// delete all the files of this mod
|
// delete all the files of this mod
|
||||||
bool destroy();
|
bool destroy();
|
||||||
@ -54,11 +77,14 @@ public:
|
|||||||
}
|
}
|
||||||
bool strongCompare(const Mod &other) const
|
bool strongCompare(const Mod &other) const
|
||||||
{
|
{
|
||||||
return filename() == other.filename() && id() == other.id() && version() == other.version() && type() == other.type();
|
return filename() == other.filename() && id() == other.id() &&
|
||||||
|
version() == other.version() && type() == other.type();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReadMCModInfo(QByteArray contents);
|
void ReadMCModInfo(QByteArray contents);
|
||||||
void ReadForgeInfo(QByteArray contents);
|
void ReadForgeInfo(QByteArray contents);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// FIXME: what do do with those? HMM...
|
// FIXME: what do do with those? HMM...
|
||||||
@ -72,6 +98,7 @@ protected:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_version;
|
QString m_version;
|
||||||
QString m_mcversion;
|
QString m_mcversion;
|
||||||
|
QString m_homeurl;
|
||||||
|
|
||||||
ModType m_type;
|
ModType m_type;
|
||||||
};
|
};
|
||||||
|
@ -32,10 +32,8 @@
|
|||||||
#define ASSETS_URLBASE "http://assets.minecraft.net/"
|
#define ASSETS_URLBASE "http://assets.minecraft.net/"
|
||||||
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
|
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
|
||||||
|
|
||||||
MinecraftVersionList::MinecraftVersionList(QObject *parent) :
|
MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent)
|
||||||
BaseVersionList(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Task *MinecraftVersionList::getLoadTask()
|
Task *MinecraftVersionList::getLoadTask()
|
||||||
@ -109,7 +107,6 @@ inline QDateTime timeFromS3Time(QString str)
|
|||||||
return QDateTime::fromString(str, Qt::ISODate);
|
return QDateTime::fromString(str, Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist)
|
MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist)
|
||||||
{
|
{
|
||||||
m_list = vlist;
|
m_list = vlist;
|
||||||
@ -151,7 +148,6 @@ void MCVListLoadTask::executeTask()
|
|||||||
connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
|
connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MCVListLoadTask::list_downloaded()
|
void MCVListLoadTask::list_downloaded()
|
||||||
{
|
{
|
||||||
if (vlistReply->error() != QNetworkReply::NoError)
|
if (vlistReply->error() != QNetworkReply::NoError)
|
||||||
@ -204,7 +200,8 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
// Now, get the array of versions.
|
// Now, get the array of versions.
|
||||||
if (!root.value("versions").isArray())
|
if (!root.value("versions").isArray())
|
||||||
{
|
{
|
||||||
emitFailed("Error parsing version list JSON: version list object is missing 'versions' array");
|
emitFailed(
|
||||||
|
"Error parsing version list JSON: version list object is missing 'versions' array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonArray versions = root.value("versions").toArray();
|
QJsonArray versions = root.value("versions").toArray();
|
||||||
@ -243,13 +240,15 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
// OneSix or Legacy. use filter to determine type
|
// OneSix or Legacy. use filter to determine type
|
||||||
if (versionTypeStr == "release")
|
if (versionTypeStr == "release")
|
||||||
{
|
{
|
||||||
versionType = legacyWhitelist.contains(versionID)?MinecraftVersion::Legacy:MinecraftVersion::OneSix;
|
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||||
|
: MinecraftVersion::OneSix;
|
||||||
is_latest = (versionID == latestReleaseID);
|
is_latest = (versionID == latestReleaseID);
|
||||||
is_snapshot = false;
|
is_snapshot = false;
|
||||||
}
|
}
|
||||||
else if (versionTypeStr == "snapshot") // It's a snapshot... yay
|
else if (versionTypeStr == "snapshot") // It's a snapshot... yay
|
||||||
{
|
{
|
||||||
versionType = legacyWhitelist.contains(versionID)?MinecraftVersion::Legacy:MinecraftVersion::OneSix;
|
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||||
|
: MinecraftVersion::OneSix;
|
||||||
is_latest = (versionID == latestSnapshotID);
|
is_latest = (versionID == latestSnapshotID);
|
||||||
is_snapshot = true;
|
is_snapshot = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user