NOISSUE Refactors and moving of things

This commit is contained in:
Petr Mrázek
2015-01-27 22:31:07 +01:00
parent 593111b144
commit 791221e923
88 changed files with 1894 additions and 1668 deletions

View File

@ -7,10 +7,10 @@
#include <QScrollBar>
#include <QShortcut>
#include "logic/MinecraftProcess.h"
#include "logic/BaseProcess.h"
#include "gui/GuiUtil.h"
LogPage::LogPage(MinecraftProcess *proc, QWidget *parent)
LogPage::LogPage(BaseProcess *proc, QWidget *parent)
: QWidget(parent), ui(new Ui::LogPage), m_process(proc)
{
ui->setupUi(this);

View File

@ -19,7 +19,7 @@
#include "logic/BaseInstance.h"
#include "logic/net/NetJob.h"
#include "logic/MinecraftProcess.h"
#include "logic/BaseProcess.h"
#include "BasePage.h"
#include <MultiMC.h>
@ -36,7 +36,7 @@ class LogPage : public QWidget, public BasePage
Q_OBJECT
public:
explicit LogPage(MinecraftProcess *proc, QWidget *parent = 0);
explicit LogPage(BaseProcess *proc, QWidget *parent = 0);
virtual ~LogPage();
virtual QString displayName() const override
{
@ -78,7 +78,7 @@ private slots:
private:
Ui::LogPage *ui;
MinecraftProcess *m_process;
BaseProcess *m_process;
int m_last_scroll_value = 0;
bool m_scroll_active = true;
int m_saved_offset = 0;

View File

@ -30,7 +30,7 @@
#include "gui/dialogs/ModEditDialogCommon.h"
#include "logic/ModList.h"
#include "logic/Mod.h"
#include "logic/VersionFilterData.h"
#include "logic/minecraft/VersionFilterData.h"
ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id,
QString iconName, QString displayName, QString helpPage,
@ -80,7 +80,7 @@ bool CoreModFolderPage::shouldDisplay() const
auto inst = dynamic_cast<OneSixInstance *>(m_inst);
if (!inst)
return true;
auto version = inst->getFullVersion();
auto version = inst->getMinecraftProfile();
if (!version)
return true;
if (version->m_releaseTime < g_VersionFilterData.legacyCutoffDate)

View File

@ -21,17 +21,17 @@
#include "gui/GuiUtil.h"
#include "logic/RecursiveFileSystemWatcher.h"
#include "logic/BaseInstance.h"
#include <pathutils.h>
OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent)
: QWidget(parent), ui(new Ui::OtherLogsPage), m_instance(instance),
OtherLogsPage::OtherLogsPage(QString path, QWidget *parent)
: QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path),
m_watcher(new RecursiveFileSystemWatcher(this))
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_watcher->setFileExpression("(.*\\.log(\\.[0-9]*)?$)|(crash-.*\\.txt)");
m_watcher->setRootDir(QDir::current().absoluteFilePath(m_instance->minecraftRoot()));
m_watcher->setRootDir(QDir::current().absoluteFilePath(m_path));
connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this,
&OtherLogsPage::populateSelectLogBox);
@ -76,7 +76,7 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
file = ui->selectLogBox->itemText(index);
}
if (file.isEmpty() || !QFile::exists(m_instance->minecraftRoot() + "/" + file))
if (file.isEmpty() || !QFile::exists(PathCombine(m_path, file)))
{
m_currentFile = QString();
ui->text->clear();
@ -92,7 +92,7 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
void OtherLogsPage::on_btnReload_clicked()
{
QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
QFile file(PathCombine(m_path, m_currentFile));
if (!file.open(QFile::ReadOnly))
{
setControlsEnabled(false);
@ -132,7 +132,7 @@ void OtherLogsPage::on_btnDelete_clicked()
{
return;
}
QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
QFile file(PathCombine(m_path, m_currentFile));
if (!file.remove())
{
QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2")

View File

@ -27,14 +27,12 @@ class OtherLogsPage;
class RecursiveFileSystemWatcher;
class BaseInstance;
class OtherLogsPage : public QWidget, public BasePage
{
Q_OBJECT
public:
explicit OtherLogsPage(BaseInstance *instance, QWidget *parent = 0);
explicit OtherLogsPage(QString path, QWidget *parent = 0);
~OtherLogsPage();
QString id() const override
@ -66,7 +64,7 @@ private slots:
private:
Ui::OtherLogsPage *ui;
BaseInstance *m_instance;
QString m_path;
RecursiveFileSystemWatcher *m_watcher;
QString m_currentFile;

View File

@ -4,7 +4,7 @@
class ResourcePackPage : public ModFolderPage
{
public:
explicit ResourcePackPage(BaseInstance *instance, QWidget *parent = 0)
explicit ResourcePackPage(MinecraftInstance *instance, QWidget *parent = 0)
: ModFolderPage(instance, instance->resourcePackList(), "resourcepacks",
"resourcepacks", tr("Resource packs"), "Resource-packs", parent)
{

View File

@ -209,7 +209,7 @@ public:
}
};
ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent)
ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
: QWidget(parent), ui(new Ui::ScreenshotsPage)
{
m_model.reset(new QFileSystemModel());
@ -219,7 +219,7 @@ ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent)
m_model->setReadOnly(false);
m_model->setNameFilters({"*.png"});
m_model->setNameFilterDisables(false);
m_folder = PathCombine(instance->minecraftRoot(), "screenshots");
m_folder = path;
m_valid = ensureFolderPathExists(m_folder);
ui->setupUi(this);

View File

@ -37,7 +37,7 @@ class ScreenshotsPage : public QWidget, public BasePage
Q_OBJECT
public:
explicit ScreenshotsPage(BaseInstance *instance, QWidget *parent = 0);
explicit ScreenshotsPage(QString path, QWidget *parent = 0);
virtual ~ScreenshotsPage();
virtual void opened() override;

View File

@ -4,7 +4,7 @@
class TexturePackPage : public ModFolderPage
{
public:
explicit TexturePackPage(BaseInstance *instance, QWidget *parent = 0)
explicit TexturePackPage(MinecraftInstance *instance, QWidget *parent = 0)
: ModFolderPage(instance, instance->texturePackList(), "texturepacks", "resourcepacks",
tr("Texture packs"), "Texture-packs", parent)
{

View File

@ -38,7 +38,7 @@
#include <QUrl>
#include "logic/ModList.h"
#include "logic/minecraft/InstanceVersion.h"
#include "logic/minecraft/MinecraftProfile.h"
#include "logic/EnabledItemFilter.h"
#include "logic/forge/ForgeVersionList.h"
#include "logic/forge/ForgeInstaller.h"
@ -65,7 +65,7 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_version = m_inst->getFullVersion();
m_version = m_inst->getMinecraftProfile();
if (m_version)
{
main_model = new EnabledItemFilter(this);
@ -109,11 +109,11 @@ void VersionPage::disableVersionControls()
ui->removeLibraryBtn->setEnabled(false);
}
bool VersionPage::reloadInstanceVersion()
bool VersionPage::reloadMinecraftProfile()
{
try
{
m_inst->reloadVersion();
m_inst->reloadProfile();
return true;
}
catch (MMCError &e)
@ -132,7 +132,7 @@ bool VersionPage::reloadInstanceVersion()
void VersionPage::on_reloadLibrariesBtn_clicked()
{
reloadInstanceVersion();
reloadMinecraftProfile();
}
void VersionPage::on_removeLibraryBtn_clicked()
@ -202,7 +202,7 @@ void VersionPage::on_moveLibraryUpBtn_clicked()
try
{
const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
m_version->move(row, InstanceVersion::MoveUp);
m_version->move(row, MinecraftProfile::MoveUp);
}
catch (MMCError &e)
{
@ -219,7 +219,7 @@ void VersionPage::on_moveLibraryDownBtn_clicked()
try
{
const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
m_version->move(row, InstanceVersion::MoveDown);
m_version->move(row, MinecraftProfile::MoveDown);
}
catch (MMCError &e)
{
@ -244,7 +244,7 @@ void VersionPage::on_changeMCVersionBtn_clicked()
return;
}
if (m_inst->versionIsCustom())
if (!m_version->isVanilla())
{
auto result = CustomMessageBox::selectable(
this, tr("Are you sure?"),
@ -256,7 +256,7 @@ void VersionPage::on_changeMCVersionBtn_clicked()
if (result != QMessageBox::Ok)
return;
m_version->revertToVanilla();
reloadInstanceVersion();
reloadMinecraftProfile();
}
m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor());
@ -272,31 +272,6 @@ void VersionPage::on_changeMCVersionBtn_clicked()
void VersionPage::on_forgeBtn_clicked()
{
// FIXME: use actual model, not reloading. Move logic to model.
if (m_version->hasFtbPack())
{
if (QMessageBox::question(
this, tr("Revert?"),
tr("This action will remove the FTB pack version patch. Continue?")) !=
QMessageBox::Yes)
{
return;
}
m_version->removeFtbPack();
reloadInstanceVersion();
}
if (m_version->hasDeprecatedVersionFiles())
{
if (QMessageBox::question(this, tr("Revert?"),
tr("This action will remove deprecated version files "
"(custom.json and version.json). Continue?")) !=
QMessageBox::Yes)
{
return;
}
m_version->removeDeprecatedVersionFiles();
reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
vselect.setExactFilter(1, m_inst->currentVersionId());
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
@ -311,30 +286,6 @@ void VersionPage::on_forgeBtn_clicked()
void VersionPage::on_liteloaderBtn_clicked()
{
if (m_version->hasFtbPack())
{
if (QMessageBox::question(
this, tr("Revert?"),
tr("This action will remove the FTB pack version patch. Continue?")) !=
QMessageBox::Yes)
{
return;
}
m_version->removeFtbPack();
reloadInstanceVersion();
}
if (m_version->hasDeprecatedVersionFiles())
{
if (QMessageBox::question(this, tr("Revert?"),
tr("This action will remove deprecated version files "
"(custom.json and version.json). Continue?")) !=
QMessageBox::Yes)
{
return;
}
m_version->removeDeprecatedVersionFiles();
reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
this);
vselect.setExactFilter(1, m_inst->currentVersionId());
@ -364,8 +315,7 @@ void VersionPage::versionCurrent(const QModelIndex &current, const QModelIndex &
ui->moveLibraryUpBtn->setEnabled(enabled);
}
QString selectedId = m_version->versionFileId(current.row());
if (selectedId == "net.minecraft" || selectedId == "org.multimc.custom.json" ||
selectedId == "org.multimc.version.json")
if (selectedId == "net.minecraft")
{
ui->changeMCVersionBtn->setEnabled(true);
}

View File

@ -67,11 +67,11 @@ slots:
protected:
/// FIXME: this shouldn't be necessary!
bool reloadInstanceVersion();
bool reloadMinecraftProfile();
private:
Ui::VersionPage *ui;
std::shared_ptr<InstanceVersion> m_version;
std::shared_ptr<MinecraftProfile> m_version;
EnabledItemFilter *main_model;
OneSixInstance *m_inst;
NetJobPtr forgeJob;