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 <QFileDialog>
|
||||
//#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
@ -343,3 +344,35 @@ void LegacyModEditDialog::on_buttonBox_rejected()
|
||||
{
|
||||
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/net/DownloadJob.h>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class LegacyModEditDialog;
|
||||
}
|
||||
|
||||
@ -31,7 +32,8 @@ public:
|
||||
explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0);
|
||||
~LegacyModEditDialog();
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
|
||||
void on_addJarBtn_clicked();
|
||||
void on_rmJarBtn_clicked();
|
||||
@ -50,14 +52,21 @@ private slots:
|
||||
void on_addTexPackBtn_clicked();
|
||||
void on_rmTexPackBtn_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?
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
bool jarListFilter(QKeyEvent *ev);
|
||||
bool coreListFilter(QKeyEvent *ev);
|
||||
bool loaderListFilter(QKeyEvent *ev);
|
||||
bool texturePackListFilter(QKeyEvent *ev);
|
||||
|
||||
private:
|
||||
Ui::LegacyModEditDialog *ui;
|
||||
std::shared_ptr<ModList> m_mods;
|
||||
|
@ -57,6 +57,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="jarWebsite">
|
||||
<property name="text">
|
||||
<string>Website</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="jarModsButtonSpacer">
|
||||
<property name="orientation">
|
||||
@ -116,6 +123,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="coreWebsite">
|
||||
<property name="text">
|
||||
<string>Website</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="coreModsButtonSpacer">
|
||||
<property name="orientation">
|
||||
@ -171,6 +185,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loaderWebsite">
|
||||
<property name="text">
|
||||
<string>Website</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="mlModsButtonSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "ModEditDialogCommon.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
bool lastfirst(QModelIndexList &list, int &first, int &last)
|
||||
{
|
||||
if (!list.size())
|
||||
@ -15,3 +18,23 @@ bool lastfirst (QModelIndexList & list, int & first, int & last)
|
||||
}
|
||||
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
|
||||
#include <QAbstractItemModel>
|
||||
#include <logic/Mod.h>
|
||||
|
||||
bool lastfirst (QModelIndexList & list, int & first, int & last);
|
||||
|
||||
void showWebsiteForMod(QWidget * parentDlg, Mod& m);
|
@ -30,6 +30,7 @@
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QDesktopServices>
|
||||
|
||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
|
||||
@ -296,3 +297,13 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked()
|
||||
{
|
||||
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_customizeBtn_clicked();
|
||||
void on_revertBtn_clicked();
|
||||
void on_loaderWebsite_clicked();
|
||||
void updateVersionControls();
|
||||
void disableVersionControls();
|
||||
protected:
|
||||
|
@ -184,6 +184,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loaderWebsite">
|
||||
<property name="text">
|
||||
<string>Website</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -118,8 +118,10 @@ void Mod::ReadMCModInfo(QByteArray contents)
|
||||
m_id = firstObj.value("modid").toString();
|
||||
m_name = firstObj.value("name").toString();
|
||||
m_version = firstObj.value("version").toString();
|
||||
m_homeurl = firstObj.value("url").toString();
|
||||
return;
|
||||
};
|
||||
}
|
||||
;
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
|
||||
// this is the very old format that had just the array
|
||||
@ -150,6 +152,7 @@ void Mod::ReadForgeInfo(QByteArray contents)
|
||||
// Read the data
|
||||
m_name = "Minecraft Forge";
|
||||
m_id = "Forge";
|
||||
m_homeurl = "http://www.minecraftforge.net/forum/";
|
||||
INIFile ini;
|
||||
if (!ini.loadFile(contents))
|
||||
return;
|
||||
@ -212,7 +215,6 @@ bool Mod::destroy()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString Mod::version() const
|
||||
{
|
||||
switch (type())
|
||||
|
41
logic/Mod.h
41
logic/Mod.h
@ -30,15 +30,38 @@ public:
|
||||
|
||||
Mod(const QFileInfo &file);
|
||||
|
||||
QFileInfo filename() const { return m_file; }
|
||||
QString id() const { 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; };
|
||||
QFileInfo filename() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
QString id() const
|
||||
{
|
||||
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 homeurl() const
|
||||
{
|
||||
return m_homeurl;
|
||||
}
|
||||
|
||||
// delete all the files of this mod
|
||||
bool destroy();
|
||||
@ -54,11 +77,14 @@ public:
|
||||
}
|
||||
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:
|
||||
void ReadMCModInfo(QByteArray contents);
|
||||
void ReadForgeInfo(QByteArray contents);
|
||||
|
||||
protected:
|
||||
|
||||
// FIXME: what do do with those? HMM...
|
||||
@ -72,6 +98,7 @@ protected:
|
||||
QString m_name;
|
||||
QString m_version;
|
||||
QString m_mcversion;
|
||||
QString m_homeurl;
|
||||
|
||||
ModType m_type;
|
||||
};
|
||||
|
@ -32,10 +32,8 @@
|
||||
#define ASSETS_URLBASE "http://assets.minecraft.net/"
|
||||
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
|
||||
|
||||
MinecraftVersionList::MinecraftVersionList(QObject *parent) :
|
||||
BaseVersionList(parent)
|
||||
MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Task *MinecraftVersionList::getLoadTask()
|
||||
@ -109,7 +107,6 @@ inline QDateTime timeFromS3Time(QString str)
|
||||
return QDateTime::fromString(str, Qt::ISODate);
|
||||
}
|
||||
|
||||
|
||||
MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist)
|
||||
{
|
||||
m_list = vlist;
|
||||
@ -151,7 +148,6 @@ void MCVListLoadTask::executeTask()
|
||||
connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
|
||||
}
|
||||
|
||||
|
||||
void MCVListLoadTask::list_downloaded()
|
||||
{
|
||||
if (vlistReply->error() != QNetworkReply::NoError)
|
||||
@ -204,7 +200,8 @@ void MCVListLoadTask::list_downloaded()
|
||||
// Now, get the array of versions.
|
||||
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;
|
||||
}
|
||||
QJsonArray versions = root.value("versions").toArray();
|
||||
@ -243,13 +240,15 @@ void MCVListLoadTask::list_downloaded()
|
||||
// OneSix or Legacy. use filter to determine type
|
||||
if (versionTypeStr == "release")
|
||||
{
|
||||
versionType = legacyWhitelist.contains(versionID)?MinecraftVersion::Legacy:MinecraftVersion::OneSix;
|
||||
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||
: MinecraftVersion::OneSix;
|
||||
is_latest = (versionID == latestReleaseID);
|
||||
is_snapshot = false;
|
||||
}
|
||||
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_snapshot = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user