Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into pre-lauch

This commit is contained in:
Trial97 2023-06-15 14:13:30 +03:00
commit 535fb2c4d6
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
8 changed files with 55 additions and 28 deletions

View File

@ -376,33 +376,33 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// init the logger // init the logger
{ {
static const QString logBase = BuildConfig.LAUNCHER_NAME + "-%0.log"; static const QString baseLogFile = BuildConfig.LAUNCHER_NAME + "-%0.log";
auto moveFile = [](const QString &oldName, const QString &newName) static const QString logBase = FS::PathCombine("logs", baseLogFile);
{ auto moveFile = [](const QString& oldName, const QString& newName) {
QFile::remove(newName); QFile::remove(newName);
QFile::copy(oldName, newName); QFile::copy(oldName, newName);
QFile::remove(oldName); QFile::remove(oldName);
}; };
if (FS::ensureFolderPathExists("logs")) { // if this did not fail
for (auto i = 0; i <= 4; i++)
if (auto oldName = baseLogFile.arg(i);
QFile::exists(oldName)) // do not pointlessly delete new files if the old ones are not there
moveFile(oldName, logBase.arg(i));
}
moveFile(logBase.arg(3), logBase.arg(4)); for (auto i = 4; i > 0; i--)
moveFile(logBase.arg(2), logBase.arg(3)); moveFile(logBase.arg(i - 1), logBase.arg(i));
moveFile(logBase.arg(1), logBase.arg(2));
moveFile(logBase.arg(0), logBase.arg(1));
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0))); logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
if(!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
{ showFatalErrorMessage("The launcher data folder is not writable!",
showFatalErrorMessage( QString("The launcher couldn't create a log file - the data folder is not writable.\n"
"The launcher data folder is not writable!",
QString(
"The launcher couldn't create a log file - the data folder is not writable.\n"
"\n" "\n"
"Make sure you have write permissions to the data folder.\n" "Make sure you have write permissions to the data folder.\n"
"(%1)\n" "(%1)\n"
"\n" "\n"
"The launcher cannot continue until you fix this problem." "The launcher cannot continue until you fix this problem.")
).arg(dataPath) .arg(dataPath));
);
return; return;
} }
qInstallMessageHandler(appDebugOutput); qInstallMessageHandler(appDebugOutput);
@ -1699,6 +1699,7 @@ bool Application::handleDataMigration(const QString& currentData,
matcher->add(std::make_shared<SimplePrefixMatcher>(configFile)); matcher->add(std::make_shared<SimplePrefixMatcher>(configFile));
matcher->add(std::make_shared<SimplePrefixMatcher>( matcher->add(std::make_shared<SimplePrefixMatcher>(
BuildConfig.LAUNCHER_CONFIGFILE)); // it's possible that we already used that directory before BuildConfig.LAUNCHER_CONFIGFILE)); // it's possible that we already used that directory before
matcher->add(std::make_shared<SimplePrefixMatcher>("logs/"));
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts.json")); matcher->add(std::make_shared<SimplePrefixMatcher>("accounts.json"));
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts/")); matcher->add(std::make_shared<SimplePrefixMatcher>("accounts/"));
matcher->add(std::make_shared<SimplePrefixMatcher>("assets/")); matcher->add(std::make_shared<SimplePrefixMatcher>("assets/"));

View File

@ -149,9 +149,10 @@ void MinecraftInstance::loadSpecificSettings()
// special! // special!
m_settings->registerPassthrough(global_settings->getSetting("JavaTimestamp"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaTimestamp"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaArchitecture"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaArchitecture"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaRealArchitecture"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaRealArchitecture"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaVendor"), javaOrLocation);
// Window Size // Window Size
auto windowSetting = m_settings->registerSetting("OverrideWindow", false); auto windowSetting = m_settings->registerSetting("OverrideWindow", false);

View File

@ -1234,6 +1234,12 @@ void MainWindow::on_actionViewInstanceFolder_triggered()
DesktopServices::openDirectory(str); DesktopServices::openDirectory(str);
} }
void MainWindow::on_actionViewLauncherRootFolder_triggered()
{
const QString dataPath = QDir::currentPath();
DesktopServices::openDirectory(dataPath);
}
void MainWindow::refreshInstances() void MainWindow::refreshInstances()
{ {
APPLICATION->instances()->loadList(); APPLICATION->instances()->loadList();

View File

@ -113,6 +113,8 @@ private slots:
void on_actionViewInstanceFolder_triggered(); void on_actionViewInstanceFolder_triggered();
void on_actionViewLauncherRootFolder_triggered();
void on_actionViewSelectedInstFolder_triggered(); void on_actionViewSelectedInstFolder_triggered();
void refreshInstances(); void refreshInstances();

View File

@ -187,6 +187,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<addaction name="actionViewInstanceFolder"/> <addaction name="actionViewInstanceFolder"/>
<addaction name="actionViewLauncherRootFolder"/>
<addaction name="actionViewCentralModsFolder"/> <addaction name="actionViewCentralModsFolder"/>
</widget> </widget>
<widget class="QMenu" name="accountsMenu"> <widget class="QMenu" name="accountsMenu">
@ -541,6 +542,18 @@
<string>Open the instance folder in a file browser.</string> <string>Open the instance folder in a file browser.</string>
</property> </property>
</action> </action>
<action name="actionViewLauncherRootFolder">
<property name="icon">
<iconset theme="viewfolder">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>&amp;View Launcher Root Folder</string>
</property>
<property name="toolTip">
<string>Open the launcher's root folder in a file browser.</string>
</property>
</action>
<action name="actionViewCentralModsFolder"> <action name="actionViewCentralModsFolder">
<property name="icon"> <property name="icon">
<iconset theme="centralmods"> <iconset theme="centralmods">

View File

@ -60,6 +60,10 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
m_settings = inst->settings(); m_settings = inst->settings();
ui->setupUi(this); ui->setupUi(this);
// As the signal will (probably) not be triggered once we click edit, let's update it manually instead.
updateRunningStatus(m_instance->isRunning());
connect(m_instance, &BaseInstance::runningStatusChanged, this, &InstanceSettingsPage::updateRunningStatus);
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
@ -70,11 +74,6 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
updateThresholds(); updateThresholds();
} }
bool InstanceSettingsPage::shouldDisplay() const
{
return !m_instance->isRunning();
}
InstanceSettingsPage::~InstanceSettingsPage() InstanceSettingsPage::~InstanceSettingsPage()
{ {
delete ui; delete ui;
@ -524,3 +523,8 @@ void InstanceSettingsPage::updateThresholds()
ui->labelMaxMemIcon->setPixmap(pix); ui->labelMaxMemIcon->setPixmap(pix);
} }
} }
void InstanceSettingsPage::updateRunningStatus(bool running)
{
setEnabled(!running);
}

View File

@ -75,12 +75,12 @@ public:
{ {
return "Instance-settings"; return "Instance-settings";
} }
virtual bool shouldDisplay() const override;
void retranslate() override; void retranslate() override;
void updateThresholds(); void updateThresholds();
private slots: private slots:
void updateRunningStatus(bool running);
void on_javaDetectBtn_clicked(); void on_javaDetectBtn_clicked();
void on_javaTestBtn_clicked(); void on_javaTestBtn_clicked();
void on_javaBrowseBtn_clicked(); void on_javaBrowseBtn_clicked();

View File

@ -37,7 +37,7 @@
nil nil
]; ];
inputsFrom = [self.packages.${system}.default]; inputsFrom = [self.packages.${system}.prismlauncher-unwrapped];
buildInputs = with pkgs; [ccache ninja]; buildInputs = with pkgs; [ccache ninja];
}; };