mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
add setting for quickplay singleplayer
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -82,7 +82,7 @@ class WorldListProxyModel : public QSortFilterProxyModel {
|
||||
}
|
||||
};
|
||||
|
||||
WorldListPage::WorldListPage(BaseInstance* inst, std::shared_ptr<WorldList> worlds, QWidget* parent)
|
||||
WorldListPage::WorldListPage(InstancePtr inst, std::shared_ptr<WorldList> worlds, QWidget* parent)
|
||||
: QMainWindow(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -120,6 +120,8 @@ void WorldListPage::openedImpl()
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
auto mInst = std::dynamic_pointer_cast<MinecraftInstance>(m_inst);
|
||||
ui->toolBar->setActionVisible(ui->actionJoin, mInst && mInst->traits().contains("feature:is_quick_play_singleplayer"));
|
||||
}
|
||||
|
||||
void WorldListPage::closedImpl()
|
||||
@ -339,6 +341,9 @@ void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex& current, [[
|
||||
ui->actionDatapacks->setEnabled(enable);
|
||||
bool hasIcon = !index.data(WorldList::IconFileRole).isNull();
|
||||
ui->actionReset_Icon->setEnabled(enable && hasIcon);
|
||||
auto mInst = std::dynamic_pointer_cast<MinecraftInstance>(m_inst);
|
||||
ui->actionJoin->setEnabled(enable);
|
||||
ui->toolBar->setActionVisible(ui->actionJoin, mInst && mInst->traits().contains("feature:is_quick_play_singleplayer"));
|
||||
}
|
||||
|
||||
void WorldListPage::on_actionAdd_triggered()
|
||||
@ -418,4 +423,15 @@ void WorldListPage::on_actionRefresh_triggered()
|
||||
m_worlds->update();
|
||||
}
|
||||
|
||||
void WorldListPage::on_actionJoin_triggered()
|
||||
{
|
||||
QModelIndex index = getSelectedWorld();
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
|
||||
auto world = (World*)worldVariant.value<void*>();
|
||||
APPLICATION->launch(m_inst, true, false, std::make_shared<MinecraftTarget>(MinecraftTarget::parse(world->folderName(), true)));
|
||||
}
|
||||
|
||||
#include "WorldListPage.moc"
|
||||
|
Reference in New Issue
Block a user