mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-20 23:09:06 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cda02e91e | |||
| f8facda35f | |||
| 39be450fa3 | |||
| 68aaea6085 | |||
| ba608d2b57 | |||
| c22f57bc4e |
@@ -158,7 +158,7 @@ ENUM(GpuUnswizzleChunk, VeryLow, Low, Normal, Medium, High)
|
||||
ENUM(TemperatureUnits, Celsius, Fahrenheit)
|
||||
ENUM(ExtendedDynamicState, Disabled, EDS1, EDS2, EDS3);
|
||||
ENUM(GpuLogLevel, Off, Errors, Standard, Verbose, All)
|
||||
ENUM(GameListMode, TreeView, GridView);
|
||||
ENUM(GameListMode, TreeView, GridView, CarouselView);
|
||||
ENUM(SpeedMode, Standard, Turbo, Slow);
|
||||
|
||||
template <typename Type>
|
||||
|
||||
@@ -207,7 +207,7 @@ struct Values {
|
||||
|
||||
// Game List
|
||||
Setting<bool> show_add_ons{linkage, true, "show_add_ons", Category::UiGameList};
|
||||
Setting<u32, true> game_icon_size{linkage, 64, 8, 512, "game_icon_size", Category::UiGameList};
|
||||
Setting<u32, true> game_icon_size{linkage, 64, 0, 512, "game_icon_size", Category::UiGameList};
|
||||
Setting<u32, true> folder_icon_size{linkage, 48, 8, 512, "folder_icon_size", Category::UiGameList};
|
||||
Setting<u8> row_1_text_id{linkage, 3, "row_1_text_id", Category::UiGameList};
|
||||
Setting<u8> row_2_text_id{linkage, 2, "row_2_text_id", Category::UiGameList};
|
||||
|
||||
@@ -165,6 +165,7 @@ public:
|
||||
return QStringLiteral("%1\n %2").arg(row1, row2);
|
||||
}
|
||||
case Settings::GameListMode::GridView:
|
||||
case Settings::GameListMode::CarouselView:
|
||||
return row1;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1619,36 +1619,33 @@ void BufferCache<P>::TouchBuffer(Buffer& buffer, BufferId buffer_id) noexcept {
|
||||
template <class P>
|
||||
bool BufferCache<P>::SynchronizeBuffer(Buffer& buffer, DAddr device_addr, u32 size) {
|
||||
upload_copies.clear();
|
||||
u64 staging_offset = 0;
|
||||
u64 total_size_bytes = 0;
|
||||
u64 largest_copy = 0;
|
||||
DAddr buffer_start = buffer.CpuAddr();
|
||||
auto push = [&](u64 start, u64 end) {
|
||||
if (start >= end) {
|
||||
return;
|
||||
}
|
||||
u64 sz = end - start;
|
||||
upload_copies.push_back({
|
||||
.src_offset = staging_offset,
|
||||
.dst_offset = start - buffer_start,
|
||||
.size = sz
|
||||
const DAddr buffer_start = buffer.cpu_addr_cached;
|
||||
memory_tracker.ForEachUploadRange(device_addr, size, [&](u64 device_addr_out, u64 range_size) {
|
||||
upload_copies.push_back(BufferCopy{
|
||||
.src_offset = total_size_bytes,
|
||||
.dst_offset = device_addr_out - buffer_start,
|
||||
.size = range_size,
|
||||
});
|
||||
staging_offset += sz;
|
||||
largest_copy = (std::max)(largest_copy, sz);
|
||||
};
|
||||
memory_tracker.ForEachUploadRange(device_addr, size, [&](u64 addr, u64 range_size) {
|
||||
u64 start = addr;
|
||||
u64 end = addr + range_size;
|
||||
gpu_modified_ranges.ForEachInRange(start, range_size, [&](u64 gstart, u64 gsize) {
|
||||
u64 gend = gstart + gsize;
|
||||
push(start, gstart);
|
||||
start = (std::max)(start, gend);
|
||||
});
|
||||
push(start, end);
|
||||
total_size_bytes += range_size;
|
||||
largest_copy = (std::max)(largest_copy, range_size);
|
||||
});
|
||||
if (upload_copies.empty()) {
|
||||
if (total_size_bytes == 0) {
|
||||
return true;
|
||||
}
|
||||
UploadMemory(buffer, staging_offset, largest_copy, std::span(upload_copies));
|
||||
u64 min_offset = (std::numeric_limits<u64>::max)();
|
||||
u64 max_offset = 0;
|
||||
for (const auto& copy : upload_copies) {
|
||||
min_offset = (std::min)(min_offset, copy.dst_offset);
|
||||
max_offset = (std::max)(max_offset, copy.dst_offset + copy.size);
|
||||
}
|
||||
const DAddr sync_addr = buffer.CpuAddr() + min_offset;
|
||||
const u64 sync_size = max_offset - min_offset;
|
||||
DownloadBufferMemory(buffer, sync_addr, sync_size);
|
||||
const std::span<BufferCopy> copies_span(upload_copies.data(), upload_copies.size());
|
||||
UploadMemory(buffer, total_size_bytes, largest_copy, copies_span);
|
||||
any_buffer_uploaded = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1699,7 +1696,6 @@ void BufferCache<P>::MappedUploadMemory([[maybe_unused]] Buffer& buffer,
|
||||
u8* const src_pointer = staging_pointer.data() + copy.src_offset;
|
||||
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
|
||||
device_memory.ReadBlockUnsafe(device_addr, src_pointer, copy.size);
|
||||
|
||||
// Apply the staging offset
|
||||
copy.src_offset += upload_staging.offset;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
|
||||
extended_dynamic_state_2_logic_op.Assign(features.has_extended_dynamic_state_2_logic_op ? 1 : 0);
|
||||
extended_dynamic_state_3_blend.Assign(features.has_extended_dynamic_state_3_blend ? 1 : 0);
|
||||
extended_dynamic_state_3_enables.Assign(features.has_extended_dynamic_state_3_enables ? 1 : 0);
|
||||
dynamic_state3_depth_clamp_enable.Assign(features.has_dynamic_state3_depth_clamp_enable ? 1 : 0);
|
||||
dynamic_state3_logic_op_enable.Assign(features.has_dynamic_state3_logic_op_enable ? 1 : 0);
|
||||
dynamic_state3_line_stipple_enable.Assign(features.has_dynamic_state3_line_stipple_enable ? 1 : 0);
|
||||
dynamic_vertex_input.Assign(features.has_dynamic_vertex_input ? 1 : 0);
|
||||
xfb_enabled.Assign(regs.transform_feedback_enabled != 0);
|
||||
ndc_minus_one_to_one.Assign(regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1 : 0);
|
||||
|
||||
@@ -208,6 +208,9 @@ struct FixedPipelineState {
|
||||
BitField<12, 2, u32> tessellation_spacing;
|
||||
BitField<14, 1, u32> tessellation_clockwise;
|
||||
BitField<15, 5, u32> patch_control_points_minus_one;
|
||||
BitField<20, 1, u32> dynamic_state3_depth_clamp_enable;
|
||||
BitField<21, 1, u32> dynamic_state3_logic_op_enable;
|
||||
BitField<22, 1, u32> dynamic_state3_line_stipple_enable;
|
||||
|
||||
BitField<24, 4, Maxwell::PrimitiveTopology> topology;
|
||||
BitField<28, 4, Tegra::Texture::MsaaMode> msaa_mode;
|
||||
|
||||
@@ -907,10 +907,10 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
||||
|
||||
// EDS3 - Enables (composite: per-feature)
|
||||
if (key.state.extended_dynamic_state_3_enables) {
|
||||
if (device.SupportsDynamicState3DepthClampEnable()) {
|
||||
if (key.state.dynamic_state3_depth_clamp_enable) {
|
||||
dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT);
|
||||
}
|
||||
if (device.SupportsDynamicState3LogicOpEnable()) {
|
||||
if (key.state.dynamic_state3_logic_op_enable) {
|
||||
dynamic_states.push_back(VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT);
|
||||
}
|
||||
if (device.SupportsDynamicState3LineRasterizationMode()) {
|
||||
@@ -919,7 +919,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
||||
if (device.SupportsDynamicState3ConservativeRasterizationMode()) {
|
||||
dynamic_states.push_back(VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT);
|
||||
}
|
||||
if (device.SupportsDynamicState3LineStippleEnable()) {
|
||||
if (key.state.dynamic_state3_line_stipple_enable) {
|
||||
dynamic_states.push_back(VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT);
|
||||
}
|
||||
if (device.SupportsDynamicState3AlphaToCoverageEnable()) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
constexpr u64 MAX_PENDING_FLUSHES = 5;
|
||||
|
||||
void Scheduler::CommandChunk::ExecuteAll(vk::CommandBuffer cmdbuf,
|
||||
vk::CommandBuffer upload_cmdbuf) {
|
||||
@@ -115,7 +116,18 @@ Scheduler::Scheduler(const Device& device_, StateTracker& state_tracker_)
|
||||
Scheduler::~Scheduler() = default;
|
||||
|
||||
u64 Scheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) {
|
||||
// When flushing, we only send data to the worker thread; no waiting is necessary.
|
||||
// Prevent the CPU from getting too far ahead of the GPU by limiting pending flushes.
|
||||
const bool should_throttle = Settings::IsGPULevelHigh();
|
||||
if (should_throttle) {
|
||||
const u64 current_tick = master_semaphore->CurrentTick();
|
||||
const u64 gap = current_tick > last_submitted_tick ? current_tick - last_submitted_tick : 0;
|
||||
const u64 step = (std::min)(MAX_PENDING_FLUSHES, gap);
|
||||
const u64 new_tick = last_submitted_tick + step;
|
||||
if (new_tick < current_tick) {
|
||||
last_submitted_tick = new_tick;
|
||||
master_semaphore->Wait(last_submitted_tick);
|
||||
}
|
||||
}
|
||||
const u64 signal_value = SubmitExecution(signal_semaphore, wait_semaphore);
|
||||
AllocateNewContext();
|
||||
return signal_value;
|
||||
|
||||
@@ -296,6 +296,8 @@ private:
|
||||
double last_target_fps{};
|
||||
u64 max_frame_count{};
|
||||
u64 frame_counter{};
|
||||
|
||||
u64 last_submitted_tick = 0;
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
||||
@@ -27,8 +27,17 @@ using namespace Common::Literals;
|
||||
|
||||
// Maximum potential alignment of a Vulkan buffer
|
||||
constexpr VkDeviceSize MAX_ALIGNMENT = 256;
|
||||
|
||||
// Stream buffer size in bytes
|
||||
// *NIX drivers are more sensitive to increased buffers for streaming.
|
||||
// Windows ones however, can intake bigger buffers and generally do not OOM.
|
||||
// - GTX 960 on Windows will not OOM with 256mib
|
||||
// - GT 1030 on ^NIX will OOM with 256mib
|
||||
#ifdef _WIN32
|
||||
constexpr VkDeviceSize MAX_STREAM_BUFFER_SIZE = 256_MiB;
|
||||
#else
|
||||
constexpr VkDeviceSize MAX_STREAM_BUFFER_SIZE = 128_MiB;
|
||||
#endif
|
||||
|
||||
size_t GetStreamBufferSize(const Device& device) {
|
||||
if (!device.HasDebuggingToolAttached()) {
|
||||
@@ -46,13 +55,13 @@ size_t GetStreamBufferSize(const Device& device) {
|
||||
// If rebar is not supported, cut the max heap size to 40%. This will allow 2 captures to be
|
||||
// loaded at the same time in RenderDoc. If rebar is supported, this shouldn't be an issue
|
||||
// as the heap will be much larger.
|
||||
if (size <= 256_MiB) {
|
||||
if (size <= MAX_STREAM_BUFFER_SIZE) {
|
||||
size = size * 40 / 100;
|
||||
}
|
||||
} else {
|
||||
size = MAX_STREAM_BUFFER_SIZE;
|
||||
}
|
||||
return (std::min)(Common::AlignUp(size, MAX_ALIGNMENT), MAX_STREAM_BUFFER_SIZE);
|
||||
return Common::AlignUp(size, MAX_ALIGNMENT);
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
|
||||
@@ -240,7 +240,9 @@ add_executable(yuzu
|
||||
|
||||
render/performance_overlay.h render/performance_overlay.cpp render/performance_overlay.ui
|
||||
updater/update_dialog.h updater/update_dialog.cpp updater/update_dialog.ui
|
||||
game/common.h)
|
||||
game/common.h
|
||||
game/carousel.h game/carousel.cpp
|
||||
)
|
||||
|
||||
set_target_properties(yuzu PROPERTIES OUTPUT_NAME "eden")
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "qt_common/config/uisettings.h"
|
||||
#include "qt_common/game_list/model.h"
|
||||
#include "yuzu/game/common.h"
|
||||
#include "yuzu/game/game_card.h"
|
||||
#include "yuzu/game/carousel.h"
|
||||
|
||||
GameCarousel::GameCarousel(QWidget* parent) : QListView{parent} {
|
||||
m_gameCard = new GameCard(this);
|
||||
setItemDelegate(m_gameCard);
|
||||
|
||||
setViewMode(QListView::IconMode);
|
||||
setMovement(QListView::Static);
|
||||
setUniformItemSizes(true);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
setSpacing(10);
|
||||
setWordWrap(true);
|
||||
setTextElideMode(Qt::ElideRight);
|
||||
setFlow(QListView::LeftToRight);
|
||||
setWrapping(false);
|
||||
}
|
||||
|
||||
void GameCarousel::SetModel(GameListModel* model) {
|
||||
QListView::setModel(model);
|
||||
UpdateIconSize();
|
||||
}
|
||||
|
||||
void GameCarousel::ApplyFilter(const QString& edit_filter_text, GameListModel* model) {
|
||||
int row_count = model->rowCount();
|
||||
|
||||
for (int i = 0; i < row_count; ++i) {
|
||||
QStandardItem* item = model->item(i, 0);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
if (Yuzu::FilterMatches(edit_filter_text, item)) {
|
||||
setRowHidden(i, false);
|
||||
} else {
|
||||
setRowHidden(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameCarousel::UpdateIconSize() {
|
||||
const u32 icon_size = UISettings::values.game_icon_size.GetValue();
|
||||
|
||||
int heightMargin = 0;
|
||||
int widthMargin = 80;
|
||||
|
||||
// TODO(crueter): get rid of this nonsense
|
||||
if (UISettings::values.show_game_name) {
|
||||
switch (icon_size) {
|
||||
case 128:
|
||||
heightMargin = 65;
|
||||
break;
|
||||
case 0:
|
||||
widthMargin = 120;
|
||||
heightMargin = 120;
|
||||
break;
|
||||
case 64:
|
||||
heightMargin = 77;
|
||||
break;
|
||||
case 32:
|
||||
case 256:
|
||||
heightMargin = 81;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
widthMargin = 24;
|
||||
heightMargin = 24;
|
||||
}
|
||||
|
||||
const int min_item_width = icon_size + widthMargin;
|
||||
const int min_item_height = icon_size + heightMargin;
|
||||
const int grid_height = std::max(min_item_height, viewport()->height());
|
||||
|
||||
QSize content_size(min_item_width, min_item_height);
|
||||
QSize grid_size(min_item_width, grid_height);
|
||||
if (gridSize() != grid_size) {
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
setGridSize(grid_size);
|
||||
m_gameCard->setSize(grid_size, content_size, 0, 0);
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex GameCarousel::indexAt(const QPoint& point) const {
|
||||
QModelIndex index = QListView::indexAt(point);
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
if (m_gameCard && !m_gameCard->hitTest(point, index, this, visualRect(index)))
|
||||
return {};
|
||||
return index;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QListView>
|
||||
#include <QString>
|
||||
|
||||
class GameCard;
|
||||
class GameListModel;
|
||||
class QResizeEvent;
|
||||
|
||||
class GameCarousel : public QListView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameCarousel(QWidget* parent = nullptr);
|
||||
|
||||
void SetModel(GameListModel* model);
|
||||
void ApplyFilter(const QString& edit_filter_text, GameListModel* model);
|
||||
void UpdateIconSize();
|
||||
|
||||
QModelIndex indexAt(const QPoint& point) const override;
|
||||
|
||||
private:
|
||||
GameCard* m_gameCard = nullptr;
|
||||
};
|
||||
+54
-15
@@ -18,27 +18,16 @@ void GameCard::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
constexpr int cardMargin = 8;
|
||||
constexpr int cardCornerRadius = 10;
|
||||
|
||||
const int column = index.row() % m_columns;
|
||||
const int cell_width = option.rect.width();
|
||||
const int card_width = cell_width - m_padding;
|
||||
|
||||
const int row_width = m_columns * cell_width;
|
||||
const int total_gap = row_width - cardMargin * 2 - m_columns * card_width;
|
||||
const int gap = (m_columns > 1) ? (total_gap / (m_columns - 1)) : 0;
|
||||
|
||||
const int card_left = option.rect.left() - column * cell_width + cardMargin + column * (card_width + gap) + 4;
|
||||
const QRect cardRect(card_left, option.rect.top() + 4, card_width - 8,
|
||||
option.rect.height() - cardMargin);
|
||||
const QRect cardRect = getCardRect(option, index);
|
||||
|
||||
QPalette palette = option.palette;
|
||||
QColor backgroundColor = palette.window().color();
|
||||
QColor borderColor = palette.dark().color();
|
||||
QColor textColor = palette.text().color();
|
||||
|
||||
// highlight blue on select
|
||||
// highlight on select or hover
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
backgroundColor = palette.highlight().color();
|
||||
borderColor = palette.highlight().color().lighter(150);
|
||||
@@ -60,7 +49,7 @@ void GameCard::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
scaled.scale(icon_size, icon_size, Qt::KeepAspectRatio);
|
||||
|
||||
iconRect = {cardRect.left() + (cardRect.width() - scaled.width()) / 2,
|
||||
cardRect.top() + cardMargin, scaled.width(), scaled.height()};
|
||||
cardRect.top() + cardMargin - 1, scaled.width(), scaled.height()};
|
||||
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
||||
@@ -94,12 +83,62 @@ void GameCard::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QRect GameCard::getCardRect(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
||||
const int cell_width = option.rect.width();
|
||||
|
||||
const int card_width = cell_width - m_padding;
|
||||
|
||||
int card_left, card_top, card_height;
|
||||
|
||||
if (m_columns >= 1) {
|
||||
// grid mode
|
||||
|
||||
// center everything in-line, such that the leftmost and rightmost cards
|
||||
// have ~ equal padding to the edge of the viewport
|
||||
// spacing between each card is larger, but equal to each other
|
||||
const int column = index.row() % m_columns;
|
||||
|
||||
const int row_width = m_columns * cell_width;
|
||||
const int total_gap = row_width - cardMargin * 2 - m_columns * card_width;
|
||||
const int gap = (m_columns > 1) ? (total_gap / (m_columns - 1)) : 0;
|
||||
card_left =
|
||||
option.rect.left() - column * cell_width + cardMargin + column * (card_width + gap) + 4;
|
||||
|
||||
// fill cell vertically
|
||||
card_top = option.rect.top() + cardMargin;
|
||||
card_height = option.rect.height() - cardMargin - 1;
|
||||
} else {
|
||||
// carousel mode
|
||||
card_left = option.rect.left() + cardMargin + 4;
|
||||
|
||||
// the delegate itself takes up the full height, but the card itself
|
||||
// gets centered
|
||||
const int content_height = m_contentSize.height() - cardMargin;
|
||||
const int cell_height = option.rect.height();
|
||||
|
||||
card_height = std::min(content_height, cell_height - cardMargin * 2) - 1;
|
||||
card_top = option.rect.top() + (cell_height - card_height) / 2;
|
||||
}
|
||||
|
||||
return QRect(card_left, card_top, card_width - cardMargin, card_height);
|
||||
}
|
||||
|
||||
bool GameCard::hitTest(const QPoint& point, const QModelIndex& index, const QWidget* widget,
|
||||
const QRect& cellRect) const {
|
||||
QStyleOptionViewItem option;
|
||||
option.initFrom(widget);
|
||||
option.rect = cellRect;
|
||||
return getCardRect(option, index).contains(point);
|
||||
}
|
||||
|
||||
QSize GameCard::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void GameCard::setSize(const QSize& newSize, const int padding, const int columns) {
|
||||
void GameCard::setSize(const QSize& newSize, const QSize& contentSize, const int padding,
|
||||
const int columns) {
|
||||
m_size = newSize;
|
||||
m_contentSize = contentSize;
|
||||
m_padding = padding;
|
||||
m_columns = columns;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,19 @@ public:
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const override;
|
||||
|
||||
QRect getCardRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
bool hitTest(const QPoint& point, const QModelIndex& index,
|
||||
const QWidget* widget, const QRect& cellRect) const;
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
void setSize(const QSize& newSize, const int padding, const int columns);
|
||||
void setSize(const QSize& newSize, const QSize& contentSize, const int padding, const int columns);
|
||||
|
||||
private:
|
||||
static constexpr int cardMargin = 8;
|
||||
|
||||
QSize m_size;
|
||||
QSize m_contentSize;
|
||||
int m_padding;
|
||||
int m_columns;
|
||||
};
|
||||
|
||||
@@ -25,8 +25,6 @@ GameGrid::GameGrid(QWidget* parent) : QListView{parent} {
|
||||
|
||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setGridSize(QSize(140, 160));
|
||||
m_gameCard->setSize(gridSize(), 0, 4);
|
||||
|
||||
setSpacing(10);
|
||||
setWordWrap(true);
|
||||
@@ -97,8 +95,17 @@ void GameGrid::UpdateIconSize() {
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
setGridSize(grid_size);
|
||||
m_gameCard->setSize(grid_size, stretched_width - min_item_width, columns);
|
||||
m_gameCard->setSize(grid_size, grid_size, stretched_width - min_item_width, columns);
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex GameGrid::indexAt(const QPoint& point) const {
|
||||
QModelIndex index = QListView::indexAt(point);
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
if (m_gameCard && !m_gameCard->hitTest(point, index, this, visualRect(index)))
|
||||
return {};
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <QListView>
|
||||
#include <QString>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
class GameCard;
|
||||
class GameListModel;
|
||||
|
||||
@@ -21,6 +19,8 @@ public:
|
||||
void ApplyFilter(const QString& edit_filter_text, GameListModel* model);
|
||||
void UpdateIconSize();
|
||||
|
||||
QModelIndex indexAt(const QPoint& point) const override;
|
||||
|
||||
private:
|
||||
GameCard* m_gameCard = nullptr;
|
||||
};
|
||||
|
||||
+58
-13
@@ -20,6 +20,7 @@
|
||||
#include <QScrollerProperties>
|
||||
#include <QToolButton>
|
||||
#include <QVariantAnimation>
|
||||
#include <qlayoutitem.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "qt_common/qt_common.h"
|
||||
#include "qt_common/util/game.h"
|
||||
#include "yuzu/compatibility_list.h"
|
||||
#include "yuzu/game/carousel.h"
|
||||
#include "yuzu/game/game_grid.h"
|
||||
#include "yuzu/game/game_list.h"
|
||||
#include "yuzu/game/game_tree.h"
|
||||
@@ -67,6 +69,9 @@ GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvid
|
||||
connect(grid_view, &QListView::activated, this, &GameList::ValidateEntry);
|
||||
connect(grid_view, &QListView::customContextMenuRequested, this, &GameList::PopupContextMenu);
|
||||
|
||||
connect(carousel_view, &QListView::activated, this, &GameList::ValidateEntry);
|
||||
connect(carousel_view, &QListView::customContextMenuRequested, this, &GameList::PopupContextMenu);
|
||||
|
||||
connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, this,
|
||||
[this](Qt::Key key) {
|
||||
if (system.IsPoweredOn()) {
|
||||
@@ -86,6 +91,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvid
|
||||
connect(item_model, &GameListModel::SaveConfig, this, &GameList::SaveConfig);
|
||||
connect(item_model, &GameListModel::PopulatingStarted, this, &GameList::OnPopulate);
|
||||
|
||||
// TODO: impl on grid/carousel
|
||||
connect(tree_view, &GameTree::FilterResultReady, search_field,
|
||||
[this](int visible, int total) { search_field->setFilterResult(visible, total); });
|
||||
|
||||
@@ -101,12 +107,11 @@ GameList::~GameList() {
|
||||
void GameList::SetupViews() {
|
||||
tree_view = new GameTree(this);
|
||||
grid_view = new GameGrid(this);
|
||||
carousel_view = new GameCarousel(this);
|
||||
|
||||
tree_view->SetModel(item_model);
|
||||
grid_view->SetModel(item_model);
|
||||
|
||||
layout->addWidget(tree_view);
|
||||
layout->addWidget(grid_view);
|
||||
carousel_view->SetModel(item_model);
|
||||
}
|
||||
|
||||
QString GameList::GetLastFilterResultItem() const {
|
||||
@@ -138,10 +143,16 @@ void GameList::LoadCompatibilityList() {
|
||||
void GameList::OnPopulate() {
|
||||
m_currentView->setEnabled(false);
|
||||
|
||||
if (m_isTreeMode) {
|
||||
grid_view->UpdateIconSize();
|
||||
} else {
|
||||
switch (game_list_mode) {
|
||||
case Settings::GameListMode::TreeView:
|
||||
tree_view->UpdateColumnVisibility(item_model);
|
||||
break;
|
||||
case Settings::GameListMode::GridView:
|
||||
grid_view->UpdateIconSize();
|
||||
break;
|
||||
case Settings::GameListMode::CarouselView:
|
||||
carousel_view->UpdateIconSize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,26 +177,46 @@ void GameList::UnloadController() {
|
||||
}
|
||||
|
||||
void GameList::ResetViewMode() {
|
||||
auto& setting = UISettings::values.game_list_mode;
|
||||
const auto mode = UISettings::values.game_list_mode.GetValue();
|
||||
game_list_mode = mode;
|
||||
|
||||
if (m_currentView)
|
||||
layout->removeWidget(m_currentView);
|
||||
|
||||
bool newTreeMode = false;
|
||||
|
||||
switch (setting.GetValue()) {
|
||||
switch (mode) {
|
||||
case Settings::GameListMode::TreeView:
|
||||
m_currentView = tree_view;
|
||||
newTreeMode = true;
|
||||
tree_view->setVisible(true);
|
||||
grid_view->setVisible(false);
|
||||
|
||||
break;
|
||||
case Settings::GameListMode::GridView:
|
||||
m_currentView = grid_view;
|
||||
newTreeMode = false;
|
||||
grid_view->setVisible(true);
|
||||
tree_view->setVisible(false);
|
||||
|
||||
break;
|
||||
case Settings::GameListMode::CarouselView:
|
||||
m_currentView = carousel_view;
|
||||
newTreeMode = false;
|
||||
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
tree_view->setVisible(false);
|
||||
grid_view->setVisible(false);
|
||||
carousel_view->setVisible(false);
|
||||
|
||||
tree_view->setEnabled(false);
|
||||
grid_view->setEnabled(false);
|
||||
carousel_view->setEnabled(false);
|
||||
|
||||
m_currentView->setVisible(true);
|
||||
m_currentView->setEnabled(true);
|
||||
layout->insertWidget(0, m_currentView);
|
||||
|
||||
auto view = m_currentView->viewport();
|
||||
view->installEventFilter(this);
|
||||
|
||||
@@ -297,11 +328,13 @@ void GameList::OnPopulatingCompleted(const QStringList& watch_list) {
|
||||
for (int i = 1; i < item_model->rowCount() - 1; ++i) {
|
||||
children_total += item_model->item(i, 0)->rowCount();
|
||||
}
|
||||
|
||||
search_field->setFilterResult(children_total, children_total);
|
||||
if (children_total > 0) {
|
||||
search_field->setFocus();
|
||||
}
|
||||
|
||||
// TODO: carousel/grid impl.
|
||||
item_model->sort(tree_view->header()->sortIndicatorSection(),
|
||||
tree_view->header()->sortIndicatorOrder());
|
||||
|
||||
@@ -317,8 +350,15 @@ void GameList::RefreshExternalContent() {
|
||||
}
|
||||
|
||||
void GameList::UpdateIconSizes() {
|
||||
if (!m_isTreeMode) {
|
||||
switch (game_list_mode) {
|
||||
case Settings::GameListMode::GridView:
|
||||
grid_view->UpdateIconSize();
|
||||
break;
|
||||
case Settings::GameListMode::CarouselView:
|
||||
carousel_view->UpdateIconSize();
|
||||
break;
|
||||
case Settings::GameListMode::TreeView:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,6 +752,11 @@ bool GameList::eventFilter(QObject* obj, QEvent* event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == carousel_view->viewport() && event->type() == QEvent::Resize) {
|
||||
carousel_view->UpdateIconSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QVector>
|
||||
#include <QWidget>
|
||||
#include <qabstractitemview.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
#include "frontend_common/play_time_manager.h"
|
||||
#include "qt_common/config/uisettings.h"
|
||||
#include "qt_common/game_list/model.h"
|
||||
#include "qt_common/util/game.h"
|
||||
#include "yuzu/compatibility_list.h"
|
||||
|
||||
@@ -38,6 +38,9 @@ class MainWindow;
|
||||
enum class AmLaunchType;
|
||||
enum class StartGameType;
|
||||
|
||||
class GameCarousel;
|
||||
|
||||
class QAbstractItemView;
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
@@ -151,7 +154,9 @@ private:
|
||||
|
||||
GameTree* tree_view = nullptr;
|
||||
GameGrid* grid_view = nullptr;
|
||||
GameCarousel* carousel_view = nullptr;
|
||||
GameListModel* item_model = nullptr;
|
||||
Settings::GameListMode game_list_mode;
|
||||
|
||||
ControllerNavigation* controller_navigation = nullptr;
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QString>
|
||||
#include <QTreeView>
|
||||
|
||||
class GameListModel;
|
||||
|
||||
+10
-1
@@ -45,7 +45,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1280</width>
|
||||
<height>22</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -111,6 +111,7 @@
|
||||
</property>
|
||||
<addaction name="action_Tree_View"/>
|
||||
<addaction name="action_Grid_View"/>
|
||||
<addaction name="action_Carousel_View"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuGame_Icon_Size">
|
||||
<property name="title">
|
||||
@@ -620,6 +621,14 @@
|
||||
<string>Show &Performance Overlay</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Carousel_View">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Carousel View</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="yuzu.qrc"/>
|
||||
|
||||
@@ -1529,6 +1529,7 @@ void MainWindow::ConnectMenuEvents() {
|
||||
|
||||
connect_menu(ui->action_Grid_View, &MainWindow::SetGridView);
|
||||
connect_menu(ui->action_Tree_View, &MainWindow::SetTreeView);
|
||||
connect_menu(ui->action_Carousel_View, &MainWindow::SetCarouselView);
|
||||
|
||||
game_size_actions = new QActionGroup(this);
|
||||
game_size_actions->setExclusive(true);
|
||||
@@ -3317,9 +3318,10 @@ void MainWindow::ResetWindowSize1080() {
|
||||
void MainWindow::SetGameListMode(Settings::GameListMode mode) {
|
||||
ui->action_Grid_View->setChecked(mode == Settings::GameListMode::GridView);
|
||||
ui->action_Tree_View->setChecked(mode == Settings::GameListMode::TreeView);
|
||||
ui->action_Carousel_View->setChecked(mode == Settings::GameListMode::CarouselView);
|
||||
|
||||
UISettings::values.game_list_mode = mode;
|
||||
ui->action_Show_Game_Name->setEnabled(mode == Settings::GameListMode::GridView);
|
||||
ui->action_Show_Game_Name->setEnabled(mode != Settings::GameListMode::TreeView);
|
||||
|
||||
CheckIconSize();
|
||||
game_list->ResetViewMode();
|
||||
@@ -3333,11 +3335,15 @@ void MainWindow::SetTreeView() {
|
||||
SetGameListMode(Settings::GameListMode::TreeView);
|
||||
}
|
||||
|
||||
void MainWindow::SetCarouselView() {
|
||||
SetGameListMode(Settings::GameListMode::CarouselView);
|
||||
}
|
||||
|
||||
void MainWindow::CheckIconSize() {
|
||||
// When in grid view mode, with text off
|
||||
// there is no point in having icons turned off..
|
||||
// When in grid/carousel view mode, with text off
|
||||
// there is no point in having icons turned off
|
||||
auto actions = game_size_actions->actions();
|
||||
if (UISettings::values.game_list_mode.GetValue() == Settings::GameListMode::GridView &&
|
||||
if (UISettings::values.game_list_mode.GetValue() != Settings::GameListMode::TreeView &&
|
||||
!UISettings::values.show_game_name.GetValue()) {
|
||||
u32 newSize = UISettings::values.game_icon_size.GetValue();
|
||||
if (newSize == 0) {
|
||||
|
||||
@@ -410,6 +410,7 @@ private slots:
|
||||
void SetGameListMode(Settings::GameListMode mode);
|
||||
void SetGridView();
|
||||
void SetTreeView();
|
||||
void SetCarouselView();
|
||||
|
||||
void CheckIconSize();
|
||||
void ToggleShowGameName();
|
||||
|
||||
Reference in New Issue
Block a user