GH-2352 Add Minecraft folder button for instances, rearrange buttons by importance

This commit is contained in:
Petr Mrázek 2018-07-27 23:57:09 +02:00
parent 14f85813c8
commit e4c33458f2
12 changed files with 84 additions and 45 deletions

View File

@ -102,6 +102,12 @@ public:
/// Path to the instance's root directory.
QString instanceRoot() const;
/// Path to the instance's game root directory.
virtual QString gameRoot() const
{
return instanceRoot();
}
QString name() const;
void setName(QString val);

View File

@ -146,7 +146,7 @@ QSet<QString> MinecraftInstance::traits() const
return profile->getTraits();
}
QString MinecraftInstance::minecraftRoot() const
QString MinecraftInstance::gameRoot() const
{
QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft"));
QFileInfo dotMCDir(FS::PathCombine(instanceRoot(), ".minecraft"));
@ -159,7 +159,7 @@ QString MinecraftInstance::minecraftRoot() const
QString MinecraftInstance::binRoot() const
{
return FS::PathCombine(minecraftRoot(), "bin");
return FS::PathCombine(gameRoot(), "bin");
}
QString MinecraftInstance::getNativePath() const
@ -176,7 +176,7 @@ QString MinecraftInstance::getLocalLibraryPath() const
QString MinecraftInstance::loaderModsDir() const
{
return FS::PathCombine(minecraftRoot(), "mods");
return FS::PathCombine(gameRoot(), "mods");
}
QString MinecraftInstance::modsCacheLocation() const
@ -186,22 +186,22 @@ QString MinecraftInstance::modsCacheLocation() const
QString MinecraftInstance::coreModsDir() const
{
return FS::PathCombine(minecraftRoot(), "coremods");
return FS::PathCombine(gameRoot(), "coremods");
}
QString MinecraftInstance::resourcePacksDir() const
{
return FS::PathCombine(minecraftRoot(), "resourcepacks");
return FS::PathCombine(gameRoot(), "resourcepacks");
}
QString MinecraftInstance::texturePacksDir() const
{
return FS::PathCombine(minecraftRoot(), "texturepacks");
return FS::PathCombine(gameRoot(), "texturepacks");
}
QString MinecraftInstance::instanceConfigFolder() const
{
return FS::PathCombine(minecraftRoot(), "config");
return FS::PathCombine(gameRoot(), "config");
}
QString MinecraftInstance::jarModsDir() const
@ -211,12 +211,12 @@ QString MinecraftInstance::jarModsDir() const
QString MinecraftInstance::libDir() const
{
return FS::PathCombine(minecraftRoot(), "lib");
return FS::PathCombine(gameRoot(), "lib");
}
QString MinecraftInstance::worldDir() const
{
return FS::PathCombine(minecraftRoot(), "saves");
return FS::PathCombine(gameRoot(), "saves");
}
QDir MinecraftInstance::librariesPath() const
@ -336,7 +336,7 @@ QMap<QString, QString> MinecraftInstance::getVariables() const
out.insert("INST_NAME", name());
out.insert("INST_ID", id());
out.insert("INST_DIR", QDir(instanceRoot()).absolutePath());
out.insert("INST_MC_DIR", QDir(minecraftRoot()).absolutePath());
out.insert("INST_MC_DIR", QDir(gameRoot()).absolutePath());
out.insert("INST_JAVA", settings()->get("JavaPath").toString());
out.insert("INST_JAVA_ARGS", javaArguments().join(' '));
return out;
@ -407,7 +407,7 @@ QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session) cons
token_mapping["version_type"] = profile->getMinecraftVersionType();
QString absRootDir = QDir(minecraftRoot()).absolutePath();
QString absRootDir = QDir(gameRoot()).absolutePath();
token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath();
auto assets = profile->getMinecraftAssets();
@ -716,7 +716,7 @@ IPathMatcher::Ptr MinecraftInstance::getLogFileMatcher()
QString MinecraftInstance::getLogFileRoot()
{
return minecraftRoot();
return gameRoot();
}
QString MinecraftInstance::prettifyTimeDuration(int64_t duration)
@ -780,11 +780,11 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
auto pptr = process.get();
ENV.icons()->saveIcon(iconKey(), FS::PathCombine(minecraftRoot(), "icon.png"), "PNG");
ENV.icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
// print a header
{
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC));
}
// check java
@ -806,7 +806,7 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
if(getPreLaunchCommand().size())
{
auto step = std::make_shared<PreLaunchCommand>(pptr);
step->setWorkingDirectory(minecraftRoot());
step->setWorkingDirectory(gameRoot());
process->appendStep(step);
}
@ -851,14 +851,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
if(method == "LauncherPart")
{
auto step = std::make_shared<LauncherPartLaunch>(pptr);
step->setWorkingDirectory(minecraftRoot());
step->setWorkingDirectory(gameRoot());
step->setAuthSession(session);
process->appendStep(step);
}
else if (method == "DirectJava")
{
auto step = std::make_shared<DirectJavaLaunch>(pptr);
step->setWorkingDirectory(minecraftRoot());
step->setWorkingDirectory(gameRoot());
step->setAuthSession(session);
process->appendStep(step);
}
@ -868,7 +868,7 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
if(getPostExitCommand().size())
{
auto step = std::make_shared<PostLaunchCommand>(pptr);
step->setWorkingDirectory(minecraftRoot());
step->setWorkingDirectory(gameRoot());
process->appendStep(step);
}
if (session)

View File

@ -49,10 +49,18 @@ public:
QDir librariesPath() const;
QDir versionsPath() const;
QString instanceConfigFolder() const override;
QString minecraftRoot() const; // Path to the instance's minecraft directory.
QString binRoot() const; // Path to the instance's minecraft bin directory.
QString getNativePath() const; // where to put the natives during/before launch
QString getLocalLibraryPath() const; // where the instance-local libraries should be
// Path to the instance's minecraft directory.
QString gameRoot() const override;
// Path to the instance's minecraft bin directory.
QString binRoot() const;
// where to put the natives during/before launch
QString getNativePath() const;
// where the instance-local libraries should be
QString getLocalLibraryPath() const;
////// Profile management //////

View File

@ -11,7 +11,7 @@ void CreateServerResourcePacksFolder::executeTask()
{
auto instance = m_parent->instance();
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->minecraftRoot(), "server-resource-packs")))
if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->gameRoot(), "server-resource-packs")))
{
emit logLine(tr("Couldn't create the 'server-resource-packs' folder"), MessageLevel::Error);
}

View File

@ -112,7 +112,7 @@ QList<Mod> LegacyInstance::getJarMods() const
return jarModList()->allMods();
}
QString LegacyInstance::minecraftRoot() const
QString LegacyInstance::gameRoot() const
{
QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft"));
QFileInfo dotMCDir(FS::PathCombine(instanceRoot(), ".minecraft"));
@ -125,7 +125,7 @@ QString LegacyInstance::minecraftRoot() const
QString LegacyInstance::binRoot() const
{
return FS::PathCombine(minecraftRoot(), "bin");
return FS::PathCombine(gameRoot(), "bin");
}
QString LegacyInstance::jarModsDir() const
@ -135,31 +135,31 @@ QString LegacyInstance::jarModsDir() const
QString LegacyInstance::libDir() const
{
return FS::PathCombine(minecraftRoot(), "lib");
return FS::PathCombine(gameRoot(), "lib");
}
QString LegacyInstance::savesDir() const
{
return FS::PathCombine(minecraftRoot(), "saves");
return FS::PathCombine(gameRoot(), "saves");
}
QString LegacyInstance::loaderModsDir() const
{
return FS::PathCombine(minecraftRoot(), "mods");
return FS::PathCombine(gameRoot(), "mods");
}
QString LegacyInstance::coreModsDir() const
{
return FS::PathCombine(minecraftRoot(), "coremods");
return FS::PathCombine(gameRoot(), "coremods");
}
QString LegacyInstance::resourceDir() const
{
return FS::PathCombine(minecraftRoot(), "resources");
return FS::PathCombine(gameRoot(), "resources");
}
QString LegacyInstance::texturePacksDir() const
{
return FS::PathCombine(minecraftRoot(), "texturepacks");
return FS::PathCombine(gameRoot(), "texturepacks");
}
QString LegacyInstance::runnableJar() const
@ -174,7 +174,7 @@ QString LegacyInstance::modListFile() const
QString LegacyInstance::instanceConfigFolder() const
{
return FS::PathCombine(minecraftRoot(), "config");
return FS::PathCombine(gameRoot(), "config");
}
bool LegacyInstance::shouldRebuild() const

View File

@ -52,7 +52,7 @@ public:
QString coreModsDir() const;
QString resourceDir() const;
virtual QString instanceConfigFolder() const override;
QString minecraftRoot() const; // Path to the instance's minecraft directory.
QString gameRoot() const; // Path to the instance's minecraft directory.
QString binRoot() const; // Path to the instance's minecraft bin directory.
/// Get the curent base jar of this instance. By default, it's the
@ -123,7 +123,7 @@ public:
}
QString getLogFileRoot() override
{
return minecraftRoot();
return gameRoot();
}
QString getStatusbarDescription() override;

View File

@ -126,7 +126,7 @@ void LegacyUpgradeTask::copyFinished()
QStringList rootRemovables = {"modlist", "version", "instMods"};
QStringList mcRemovables = {"bin", "MultiMCLauncher.jar", "icon.png"};
removeAll(inst.instanceRoot(), rootRemovables);
removeAll(inst.minecraftRoot(), mcRemovables);
removeAll(inst.gameRoot(), mcRemovables);
}
emitSucceeded();
}

View File

@ -11,7 +11,7 @@ FoldersTask::FoldersTask(MinecraftInstance * inst)
void FoldersTask::executeTask()
{
// Make directories
QDir mcDir(m_inst->minecraftRoot());
QDir mcDir(m_inst->gameRoot());
if (!mcDir.exists() && !mcDir.mkpath("."))
{
emitFailed(tr("Failed to create folder for minecraft binaries."));

View File

@ -51,7 +51,7 @@ public:
values.append(new NotesPage(onesix.get()));
values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds"));
values.append(new ServersPage(onesix.get()));
values.append(new ScreenshotsPage(FS::PathCombine(onesix->minecraftRoot(), "screenshots")));
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
values.append(new InstanceSettingsPage(onesix.get()));
}
std::shared_ptr<LegacyInstance> legacy = std::dynamic_pointer_cast<LegacyInstance>(inst);
@ -60,7 +60,7 @@ public:
values.append(new LegacyUpgradePage(legacy));
values.append(new NotesPage(legacy.get()));
values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds"));
values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots")));
values.append(new ScreenshotsPage(FS::PathCombine(legacy->gameRoot(), "screenshots")));
}
auto logMatcher = inst->getLogFileMatcher();
if(logMatcher)

View File

@ -187,6 +187,7 @@ public:
TranslatedAction actionEditInstance;
TranslatedAction actionWorlds;
TranslatedAction actionViewSelectedInstFolder;
TranslatedAction actionViewSelectedMCFolder;
TranslatedAction actionDeleteInstance;
TranslatedAction actionConfig_Folder;
TranslatedAction actionCAT;
@ -519,12 +520,12 @@ public:
instanceToolBar->addSeparator();
actionViewSelectedInstFolder = TranslatedAction(MainWindow);
actionViewSelectedInstFolder->setObjectName(QStringLiteral("actionViewSelectedInstFolder"));
actionViewSelectedInstFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Instance Folder"));
actionViewSelectedInstFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's root folder in a file browser."));
all_actions.append(&actionViewSelectedInstFolder);
instanceToolBar->addAction(actionViewSelectedInstFolder);
actionViewSelectedMCFolder = TranslatedAction(MainWindow);
actionViewSelectedMCFolder->setObjectName(QStringLiteral("actionViewSelectedMCFolder"));
actionViewSelectedMCFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Minecraft Folder"));
actionViewSelectedMCFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's minecraft folder in a file browser."));
all_actions.append(&actionViewSelectedMCFolder);
instanceToolBar->addAction(actionViewSelectedMCFolder);
actionConfig_Folder = TranslatedAction(MainWindow);
actionConfig_Folder->setObjectName(QStringLiteral("actionConfig_Folder"));
@ -533,6 +534,13 @@ public:
all_actions.append(&actionConfig_Folder);
instanceToolBar->addAction(actionConfig_Folder);
actionViewSelectedInstFolder = TranslatedAction(MainWindow);
actionViewSelectedInstFolder->setObjectName(QStringLiteral("actionViewSelectedInstFolder"));
actionViewSelectedInstFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Instance Folder"));
actionViewSelectedInstFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's root folder in a file browser."));
all_actions.append(&actionViewSelectedInstFolder);
instanceToolBar->addAction(actionViewSelectedInstFolder);
instanceToolBar->addSeparator();
actionExportInstance = TranslatedAction(MainWindow);
@ -1651,6 +1659,21 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered()
}
}
void MainWindow::on_actionViewSelectedMCFolder_triggered()
{
if (m_selectedInstance)
{
QString str = m_selectedInstance->gameRoot();
if (!FS::ensureFilePathExists(str))
{
// TODO: report error
return;
}
DesktopServices::openDirectory(QDir(str).absolutePath());
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{
// Save the window state and geometry.

View File

@ -87,6 +87,8 @@ private slots:
void on_actionViewSelectedInstFolder_triggered();
void on_actionViewSelectedMCFolder_triggered();
void refreshInstances();
void on_actionViewCentralModsFolder_triggered();

View File

@ -561,7 +561,7 @@ ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent)
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_inst = inst;
m_model = new ServersModel(inst->minecraftRoot(), this);
m_model = new ServersModel(inst->gameRoot(), this);
ui->serversView->setIconSize(QSize(64,64));
ui->serversView->setModel(m_model);
auto head = ui->serversView->header();