mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
Merge branch 'master' into ps3-cli-args
This commit is contained in:
commit
f5aeb39c9c
23 changed files with 425 additions and 286 deletions
31
.github/workflows/rpcs3.yml
vendored
31
.github/workflows/rpcs3.yml
vendored
|
@ -1,5 +1,8 @@
|
|||
name: Build RPCS3
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
|
@ -33,6 +36,8 @@ jobs:
|
|||
docker_img: "rpcs3/rpcs3-ci-jammy:1.1"
|
||||
build_sh: "/rpcs3/.ci/build-linux.sh"
|
||||
compiler: clang
|
||||
UPLOAD_COMMIT_HASH: d812f1254a1157c80fd402f94446310560f54e5f
|
||||
UPLOAD_REPO_FULL_NAME: "rpcs3/rpcs3-binaries-linux"
|
||||
- os: ubuntu-24.04
|
||||
docker_img: "rpcs3/rpcs3-ci-jammy:1.1"
|
||||
build_sh: "/rpcs3/.ci/build-linux.sh"
|
||||
|
@ -92,8 +97,7 @@ jobs:
|
|||
github.event_name != 'pull_request' &&
|
||||
github.repository == 'RPCS3/rpcs3' &&
|
||||
github.ref == 'refs/heads/master' &&
|
||||
matrix.compiler == 'clang' &&
|
||||
runner.arch == 'ARM64'
|
||||
matrix.compiler == 'clang'
|
||||
env:
|
||||
RPCS3_TOKEN: ${{ secrets.RPCS3_TOKEN }}
|
||||
run: |
|
||||
|
@ -120,6 +124,8 @@ jobs:
|
|||
CCACHE_INODECACHE: 'true'
|
||||
CCACHE_SLOPPINESS: 'time_macros'
|
||||
DEPS_CACHE_DIR: ./dependency_cache
|
||||
UPLOAD_COMMIT_HASH: 7d09e3be30805911226241afbb14f8cdc2eb054e
|
||||
UPLOAD_REPO_FULL_NAME: "RPCS3/rpcs3-binaries-win"
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
|
@ -128,12 +134,12 @@ jobs:
|
|||
fetch-depth: 0
|
||||
|
||||
- name: Setup env
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "QTDIR=C:\Qt\${{ env.QT_VER }}\${{ env.QT_VER_MSVC }}_64" >> ${{ github.env }}
|
||||
echo "VULKAN_SDK=C:\VulkanSDK\${{ env.VULKAN_VER }}" >> ${{ github.env }}
|
||||
|
||||
- name: Get Cache Keys
|
||||
shell: bash
|
||||
run: .ci/get_keys-windows.sh
|
||||
|
||||
- name: Setup Build Ccache
|
||||
|
@ -151,11 +157,9 @@ jobs:
|
|||
restore-keys: ${{ runner.os }}-${{ env.COMPILER }}-
|
||||
|
||||
- name: Download and unpack dependencies
|
||||
shell: bash
|
||||
run: .ci/setup-windows.sh
|
||||
|
||||
- name: Export Variables
|
||||
shell: bash
|
||||
run: |
|
||||
while IFS='=' read -r key val; do
|
||||
# Skip lines that are empty or start with '#'
|
||||
|
@ -167,24 +171,27 @@ jobs:
|
|||
uses: microsoft/setup-msbuild@main
|
||||
|
||||
- name: Compile RPCS3
|
||||
shell: pwsh
|
||||
run: msbuild rpcs3.sln /p:Configuration=Release /p:Platform=x64 /p:CLToolPath=${{ env.CCACHE_BIN_DIR }} /p:UseMultiToolTask=true /p:CustomAfterMicrosoftCommonTargets="${{ github.workspace }}\buildfiles\msvc\ci_no_debug_info.targets"
|
||||
|
||||
- name: Pack up build artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}"
|
||||
.ci/deploy-windows.sh
|
||||
|
||||
- name: Upload artifacts (7z)
|
||||
#TODO: Upload artifact to release repository
|
||||
#condition for release
|
||||
#if: |
|
||||
# github.event_name != 'pull_request' &&
|
||||
# github.repository == 'RPCS3/rpcs3' &&
|
||||
# github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@main
|
||||
with:
|
||||
name: RPCS3 for Windows (MSVC)
|
||||
path: ${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}
|
||||
compression-level: 0
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Deploy master build to GitHub Releases
|
||||
if: |
|
||||
github.event_name != 'pull_request' &&
|
||||
github.repository == 'RPCS3/rpcs3' &&
|
||||
github.ref == 'refs/heads/master'
|
||||
env:
|
||||
RPCS3_TOKEN: ${{ secrets.RPCS3_TOKEN }}
|
||||
run: .ci/github-upload.sh
|
||||
|
|
|
@ -10,131 +10,131 @@ pr:
|
|||
include:
|
||||
- master
|
||||
jobs:
|
||||
- job: Linux_Build
|
||||
strategy:
|
||||
matrix:
|
||||
Clang:
|
||||
COMPILER: clang
|
||||
GCC:
|
||||
COMPILER: gcc
|
||||
variables:
|
||||
CCACHE_DIR: $(Pipeline.Workspace)/ccache
|
||||
CI_HAS_ARTIFACTS: true
|
||||
UPLOAD_COMMIT_HASH: d812f1254a1157c80fd402f94446310560f54e5f
|
||||
UPLOAD_REPO_FULL_NAME: "RPCS3/rpcs3-binaries-linux"
|
||||
DEPLOY_APPIMAGE: true
|
||||
APPDIR: "/rpcs3/build/appdir"
|
||||
ARTDIR: "/root/artifacts"
|
||||
RELEASE_MESSAGE: "/rpcs3/GitHubReleaseMessage.txt"
|
||||
# - job: Linux_Build
|
||||
# strategy:
|
||||
# matrix:
|
||||
# Clang:
|
||||
# COMPILER: clang
|
||||
# GCC:
|
||||
# COMPILER: gcc
|
||||
# variables:
|
||||
# CCACHE_DIR: $(Pipeline.Workspace)/ccache
|
||||
# CI_HAS_ARTIFACTS: true
|
||||
# UPLOAD_COMMIT_HASH: d812f1254a1157c80fd402f94446310560f54e5f
|
||||
# UPLOAD_REPO_FULL_NAME: "RPCS3/rpcs3-binaries-linux"
|
||||
# DEPLOY_APPIMAGE: true
|
||||
# APPDIR: "/rpcs3/build/appdir"
|
||||
# ARTDIR: "/root/artifacts"
|
||||
# RELEASE_MESSAGE: "/rpcs3/GitHubReleaseMessage.txt"
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
# pool:
|
||||
# vmImage: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: ccache | $(Agent.OS) | $(COMPILER) | $(Build.SourceVersion)
|
||||
restoreKeys: |
|
||||
ccache | $(Agent.OS) | $(COMPILER)
|
||||
path: $(CCACHE_DIR)
|
||||
displayName: ccache
|
||||
# steps:
|
||||
# - task: Cache@2
|
||||
# inputs:
|
||||
# key: ccache | $(Agent.OS) | $(COMPILER) | $(Build.SourceVersion)
|
||||
# restoreKeys: |
|
||||
# ccache | $(Agent.OS) | $(COMPILER)
|
||||
# path: $(CCACHE_DIR)
|
||||
# displayName: ccache
|
||||
|
||||
- bash: |
|
||||
docker pull --quiet rpcs3/rpcs3-ci-jammy:1.1
|
||||
docker run \
|
||||
-v $(pwd):/rpcs3 \
|
||||
--env-file .ci/docker.env \
|
||||
-v $CCACHE_DIR:/root/.ccache \
|
||||
-v $BUILD_ARTIFACTSTAGINGDIRECTORY:/root/artifacts \
|
||||
rpcs3/rpcs3-ci-jammy:1.1 \
|
||||
/rpcs3/.ci/build-linux.sh
|
||||
displayName: Docker setup and build
|
||||
# - bash: |
|
||||
# docker pull --quiet rpcs3/rpcs3-ci-jammy:1.1
|
||||
# docker run \
|
||||
# -v $(pwd):/rpcs3 \
|
||||
# --env-file .ci/docker.env \
|
||||
# -v $CCACHE_DIR:/root/.ccache \
|
||||
# -v $BUILD_ARTIFACTSTAGINGDIRECTORY:/root/artifacts \
|
||||
# rpcs3/rpcs3-ci-jammy:1.1 \
|
||||
# /rpcs3/.ci/build-linux.sh
|
||||
# displayName: Docker setup and build
|
||||
|
||||
- publish: $(Build.ArtifactStagingDirectory)
|
||||
condition: succeeded()
|
||||
artifact: RPCS3 for Linux ($(COMPILER))
|
||||
# - publish: $(Build.ArtifactStagingDirectory)
|
||||
# condition: succeeded()
|
||||
# artifact: RPCS3 for Linux ($(COMPILER))
|
||||
|
||||
- bash: |
|
||||
COMM_TAG=$(awk '/version{.*}/ { printf("%d.%d.%d", $5, $6, $7) }' ./rpcs3/rpcs3_version.cpp)
|
||||
COMM_COUNT=$(git rev-list --count HEAD)
|
||||
COMM_HASH=$(git rev-parse --short=8 HEAD)
|
||||
# - bash: |
|
||||
# COMM_TAG=$(awk '/version{.*}/ { printf("%d.%d.%d", $5, $6, $7) }' ./rpcs3/rpcs3_version.cpp)
|
||||
# COMM_COUNT=$(git rev-list --count HEAD)
|
||||
# COMM_HASH=$(git rev-parse --short=8 HEAD)
|
||||
|
||||
export AVVER="${COMM_TAG}-${COMM_COUNT}"
|
||||
# export AVVER="${COMM_TAG}-${COMM_COUNT}"
|
||||
|
||||
.ci/github-upload.sh
|
||||
condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.Repository.Name'], 'RPCS3/rpcs3'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['COMPILER'], 'clang'))
|
||||
displayName: Push build to GitHub
|
||||
env:
|
||||
RPCS3_TOKEN: $(RPCS3-Token)
|
||||
# .ci/github-upload.sh
|
||||
# condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.Repository.Name'], 'RPCS3/rpcs3'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['COMPILER'], 'clang'))
|
||||
# displayName: Push build to GitHub
|
||||
# env:
|
||||
# RPCS3_TOKEN: $(RPCS3-Token)
|
||||
|
||||
- job: Windows_Build
|
||||
variables:
|
||||
COMPILER: msvc
|
||||
QT_VER_MAIN: '6'
|
||||
QT_VER: '6.8.2'
|
||||
QT_VER_MSVC: 'msvc2022'
|
||||
QT_DATE: '202501260838'
|
||||
QTDIR: C:\Qt\$(QT_VER)\$(QT_VER_MSVC)_64
|
||||
VULKAN_VER: '1.3.268.0'
|
||||
VULKAN_SDK_SHA: '8459ef49bd06b697115ddd3d97c9aec729e849cd775f5be70897718a9b3b9db5'
|
||||
VULKAN_SDK: C:\VulkanSDK\$(VULKAN_VER)
|
||||
CCACHE_SHA: '6252f081876a9a9f700fae13a5aec5d0d486b28261d7f1f72ac11c7ad9df4da9'
|
||||
CCACHE_BIN_DIR: 'C:\ccache_bin'
|
||||
CCACHE_DIR: 'C:\ccache'
|
||||
CCACHE_INODECACHE: 'true'
|
||||
CCACHE_SLOPPINESS: 'time_macros'
|
||||
DEPS_CACHE_DIR: ./dependency_cache
|
||||
UPLOAD_COMMIT_HASH: 7d09e3be30805911226241afbb14f8cdc2eb054e
|
||||
UPLOAD_REPO_FULL_NAME: "RPCS3/rpcs3-binaries-win"
|
||||
# - job: Windows_Build
|
||||
# variables:
|
||||
# COMPILER: msvc
|
||||
# QT_VER_MAIN: '6'
|
||||
# QT_VER: '6.8.2'
|
||||
# QT_VER_MSVC: 'msvc2022'
|
||||
# QT_DATE: '202501260838'
|
||||
# QTDIR: C:\Qt\$(QT_VER)\$(QT_VER_MSVC)_64
|
||||
# VULKAN_VER: '1.3.268.0'
|
||||
# VULKAN_SDK_SHA: '8459ef49bd06b697115ddd3d97c9aec729e849cd775f5be70897718a9b3b9db5'
|
||||
# VULKAN_SDK: C:\VulkanSDK\$(VULKAN_VER)
|
||||
# CCACHE_SHA: '6252f081876a9a9f700fae13a5aec5d0d486b28261d7f1f72ac11c7ad9df4da9'
|
||||
# CCACHE_BIN_DIR: 'C:\ccache_bin'
|
||||
# CCACHE_DIR: 'C:\ccache'
|
||||
# CCACHE_INODECACHE: 'true'
|
||||
# CCACHE_SLOPPINESS: 'time_macros'
|
||||
# DEPS_CACHE_DIR: ./dependency_cache
|
||||
# UPLOAD_COMMIT_HASH: 7d09e3be30805911226241afbb14f8cdc2eb054e
|
||||
# UPLOAD_REPO_FULL_NAME: "RPCS3/rpcs3-binaries-win"
|
||||
|
||||
pool:
|
||||
vmImage: "windows-latest"
|
||||
# pool:
|
||||
# vmImage: "windows-latest"
|
||||
|
||||
steps:
|
||||
- bash: .ci/get_keys-windows.sh
|
||||
displayName: Get Cache Keys
|
||||
# steps:
|
||||
# - bash: .ci/get_keys-windows.sh
|
||||
# displayName: Get Cache Keys
|
||||
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: ccache | $(Agent.OS) | $(COMPILER) | "$(Build.SourceVersion)"
|
||||
path: $(CCACHE_DIR)
|
||||
restoreKeys:
|
||||
ccache | $(Agent.OS) | $(COMPILER)
|
||||
displayName: Build Ccache
|
||||
# - task: Cache@2
|
||||
# inputs:
|
||||
# key: ccache | $(Agent.OS) | $(COMPILER) | "$(Build.SourceVersion)"
|
||||
# path: $(CCACHE_DIR)
|
||||
# restoreKeys:
|
||||
# ccache | $(Agent.OS) | $(COMPILER)
|
||||
# displayName: Build Ccache
|
||||
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: $(Agent.OS) | $(COMPILER) | "$(QT_VER)" | $(VULKAN_SDK_SHA) | $(CCACHE_SHA) | llvm.lock | glslang.lock
|
||||
path: $(DEPS_CACHE_DIR)
|
||||
displayName: Dependencies Cache
|
||||
# - task: Cache@2
|
||||
# inputs:
|
||||
# key: $(Agent.OS) | $(COMPILER) | "$(QT_VER)" | $(VULKAN_SDK_SHA) | $(CCACHE_SHA) | llvm.lock | glslang.lock
|
||||
# path: $(DEPS_CACHE_DIR)
|
||||
# displayName: Dependencies Cache
|
||||
|
||||
- bash: .ci/setup-windows.sh
|
||||
displayName: Download and unpack dependencies
|
||||
# - bash: .ci/setup-windows.sh
|
||||
# displayName: Download and unpack dependencies
|
||||
|
||||
- bash: .ci/export-azure-vars.sh
|
||||
displayName: Export Variables
|
||||
# - bash: .ci/export-azure-vars.sh
|
||||
# displayName: Export Variables
|
||||
|
||||
- task: VSBuild@1
|
||||
inputs:
|
||||
solution: 'rpcs3.sln'
|
||||
maximumCpuCount: true
|
||||
platform: x64
|
||||
configuration: 'Release'
|
||||
msbuildArgs: /p:CLToolPath=$(CCACHE_BIN_DIR) /p:UseMultiToolTask=true /p:CustomAfterMicrosoftCommonTargets="$(Build.SourcesDirectory)\buildfiles\msvc\ci_no_debug_info.targets"
|
||||
displayName: Compile RPCS3
|
||||
# - task: VSBuild@1
|
||||
# inputs:
|
||||
# solution: 'rpcs3.sln'
|
||||
# maximumCpuCount: true
|
||||
# platform: x64
|
||||
# configuration: 'Release'
|
||||
# msbuildArgs: /p:CLToolPath=$(CCACHE_BIN_DIR) /p:UseMultiToolTask=true /p:CustomAfterMicrosoftCommonTargets="$(Build.SourcesDirectory)\buildfiles\msvc\ci_no_debug_info.targets"
|
||||
# displayName: Compile RPCS3
|
||||
|
||||
- bash: .ci/deploy-windows.sh
|
||||
displayName: Pack up build artifacts
|
||||
# - bash: .ci/deploy-windows.sh
|
||||
# displayName: Pack up build artifacts
|
||||
|
||||
- publish: $(Build.ArtifactStagingDirectory)
|
||||
condition: succeeded()
|
||||
artifact: RPCS3 for Windows
|
||||
# - publish: $(Build.ArtifactStagingDirectory)
|
||||
# condition: succeeded()
|
||||
# artifact: RPCS3 for Windows
|
||||
|
||||
- bash: .ci/github-upload.sh
|
||||
condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.Repository.Name'], 'RPCS3/rpcs3'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
displayName: Push build to GitHub
|
||||
env:
|
||||
RPCS3_TOKEN: $(RPCS3-Token)
|
||||
# - bash: .ci/github-upload.sh
|
||||
# condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.Repository.Name'], 'RPCS3/rpcs3'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
# displayName: Push build to GitHub
|
||||
# env:
|
||||
# RPCS3_TOKEN: $(RPCS3-Token)
|
||||
|
||||
- job: Mac_Build_x86_64
|
||||
timeoutInMinutes: 180
|
||||
|
|
|
@ -590,7 +590,7 @@ f32 microphone_device::calculate_energy_level()
|
|||
sum_squares += normalized_sample * normalized_sample;
|
||||
}
|
||||
|
||||
const f32 rms = num_samples > 0 ? std::sqrt(sum_squares / num_samples) : 0.0f;
|
||||
const f32 rms = num_samples > 0 ? static_cast<f32>(std::sqrt(sum_squares / num_samples)) : 0.0f;
|
||||
constexpr f32 decibels_max = 90.0f;
|
||||
const f32 decibels_relative = 20.0f * std::log10(std::max(rms, 0.00001f));
|
||||
const f32 decibels = decibels_max + (decibels_relative * 0.5f);
|
||||
|
|
|
@ -303,7 +303,7 @@ namespace gl
|
|||
}
|
||||
|
||||
// Create font file
|
||||
const std::vector<u8> glyph_data = font->get_glyph_data();
|
||||
const std::vector<u8>& glyph_data = font->get_glyph_data();
|
||||
|
||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex->copy_from(glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {});
|
||||
|
|
|
@ -121,6 +121,7 @@ namespace rsx
|
|||
m_list->set_pos(20, 85);
|
||||
|
||||
m_message_box = std::make_shared<home_menu_message_box>(20, 85, virtual_width - 2 * 20, 540);
|
||||
m_message_box->visible = false;
|
||||
|
||||
m_description = std::make_unique<label>();
|
||||
m_description->set_font("Arial", 20);
|
||||
|
@ -156,7 +157,7 @@ namespace rsx
|
|||
{
|
||||
if (fade_animation.active) return;
|
||||
|
||||
if (m_message_box && m_message_box->visible())
|
||||
if (m_message_box && m_message_box->visible)
|
||||
{
|
||||
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
||||
if (navigation != page_navigation::stay)
|
||||
|
@ -210,7 +211,7 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||
{
|
||||
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_REMOVE_USER_MSG, selected_username.c_str()), [this, selected_username]()
|
||||
{
|
||||
|
@ -247,7 +248,7 @@ namespace rsx
|
|||
user_index++;
|
||||
}
|
||||
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||
{
|
||||
if (user_index < m_friend_data.requests_received.size())
|
||||
{
|
||||
|
@ -291,7 +292,7 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||
{
|
||||
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_UNBLOCK_USER_MSG, selected_username.c_str()), []()
|
||||
{
|
||||
|
@ -392,7 +393,7 @@ namespace rsx
|
|||
m_last_page.store(m_current_page);
|
||||
}
|
||||
|
||||
if (m_message_box && m_message_box->visible())
|
||||
if (m_message_box && m_message_box->visible)
|
||||
{
|
||||
result.add(m_message_box->get_compiled());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace rsx
|
|||
is_current_page = true;
|
||||
|
||||
m_message_box = std::make_shared<home_menu_message_box>(x, y, width, height);
|
||||
m_message_box->visible = false;
|
||||
|
||||
m_config_changed = std::make_shared<bool>(g_backup_cfg.to_string() != g_cfg.to_string());
|
||||
|
||||
std::unique_ptr<overlay_element> resume = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_RESUME));
|
||||
|
|
|
@ -61,13 +61,13 @@ namespace rsx
|
|||
m_label.set_text(text);
|
||||
m_label.auto_resize();
|
||||
m_label.set_pos(x + (w - m_label.w) / 2, y + (h - m_label.h) / 2);
|
||||
m_visible = true;
|
||||
visible = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
void home_menu_message_box::hide()
|
||||
{
|
||||
m_visible = false;
|
||||
visible = false;
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ namespace rsx
|
|||
void show(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||
void hide();
|
||||
page_navigation handle_button_press(pad_button button_press);
|
||||
bool visible() const { return m_visible; }
|
||||
|
||||
private:
|
||||
bool m_visible = false;
|
||||
label m_label{};
|
||||
image_button m_accept_btn;
|
||||
image_button m_cancel_btn;
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace rsx
|
|||
|
||||
void home_menu_page::show_dialog(const std::string& text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||
{
|
||||
if (m_message_box && !m_message_box->visible())
|
||||
if (m_message_box && !m_message_box->visible)
|
||||
{
|
||||
rsx_log.notice("home_menu_page::show_dialog: page='%s', text='%s'", title, text);
|
||||
m_message_box->show(text, std::move(on_accept), std::move(on_cancel));
|
||||
|
@ -129,7 +129,7 @@ namespace rsx
|
|||
|
||||
page_navigation home_menu_page::handle_button_press(pad_button button_press, bool is_auto_repeat, u64 auto_repeat_interval_ms)
|
||||
{
|
||||
if (m_message_box && m_message_box->visible())
|
||||
if (m_message_box && m_message_box->visible)
|
||||
{
|
||||
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
||||
if (navigation != page_navigation::stay)
|
||||
|
@ -270,7 +270,7 @@ namespace rsx
|
|||
{
|
||||
compiled_resources = list_view::get_compiled();
|
||||
|
||||
if (m_message_box && m_message_box->visible())
|
||||
if (m_message_box && m_message_box->visible)
|
||||
{
|
||||
compiled_resources.add(m_message_box->get_compiled());
|
||||
}
|
||||
|
|
|
@ -9,7 +9,21 @@ namespace rsx
|
|||
{
|
||||
namespace overlays
|
||||
{
|
||||
trophy_list_dialog::trophy_list_entry::trophy_list_entry(const std::string& name, const std::string& description, const std::string& trophy_type, const std::string& icon_path, bool hidden, bool locked, bool platinum_relevant)
|
||||
static constexpr u16 trophy_list_y = 85;
|
||||
static constexpr u16 trophy_list_h = 540;
|
||||
|
||||
struct trophy_list_entry : horizontal_layout
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<image_info> icon_data;
|
||||
|
||||
public:
|
||||
trophy_list_entry(const SceNpTrophyDetails& details, const std::string& icon_path, bool locked, bool platinum_relevant);
|
||||
s32 trophy_id = 0;
|
||||
};
|
||||
|
||||
trophy_list_entry::trophy_list_entry(const SceNpTrophyDetails& details, const std::string& icon_path, bool locked, bool platinum_relevant)
|
||||
: trophy_id(details.trophyId)
|
||||
{
|
||||
std::unique_ptr<overlay_element> image = std::make_unique<image_view>();
|
||||
image->set_size(160, 110);
|
||||
|
@ -17,7 +31,7 @@ namespace rsx
|
|||
|
||||
if (fs::exists(icon_path))
|
||||
{
|
||||
icon_data = std::make_unique<image_info>(icon_path.c_str(), hidden || locked);
|
||||
icon_data = std::make_unique<image_info>(icon_path.c_str(), details.hidden || locked);
|
||||
static_cast<image_view*>(image.get())->set_raw_image(icon_data.get());
|
||||
}
|
||||
else
|
||||
|
@ -27,10 +41,20 @@ namespace rsx
|
|||
static_cast<image_view*>(image.get())->set_image_resource(resource_config::standard_image_resource::square);
|
||||
}
|
||||
|
||||
std::string trophy_type;
|
||||
switch (details.trophyGrade)
|
||||
{
|
||||
case SCE_NP_TROPHY_GRADE_BRONZE: trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_BRONZE); break;
|
||||
case SCE_NP_TROPHY_GRADE_SILVER: trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_SILVER); break;
|
||||
case SCE_NP_TROPHY_GRADE_GOLD: trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_GOLD); break;
|
||||
case SCE_NP_TROPHY_GRADE_PLATINUM: trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_PLATINUM); break;
|
||||
default: trophy_type = "?"; break;
|
||||
}
|
||||
|
||||
std::unique_ptr<overlay_element> text_stack = std::make_unique<vertical_layout>();
|
||||
std::unique_ptr<overlay_element> padding = std::make_unique<spacer>();
|
||||
std::unique_ptr<overlay_element> header_text = std::make_unique<label>(fmt::format("%s (%s%s)", (locked && !hidden) ? get_localized_string(localized_string_id::HOME_MENU_TROPHY_LOCKED_TITLE, name.c_str()) : name, trophy_type, platinum_relevant ? " - " + get_localized_string(localized_string_id::HOME_MENU_TROPHY_PLATINUM_RELEVANT) : ""));
|
||||
std::unique_ptr<overlay_element> subtext = std::make_unique<label>(description);
|
||||
std::unique_ptr<overlay_element> header_text = std::make_unique<label>(fmt::format("%s (%s%s)", (locked && !details.hidden) ? get_localized_string(localized_string_id::HOME_MENU_TROPHY_LOCKED_TITLE, details.name) : details.name, trophy_type, platinum_relevant ? " - " + get_localized_string(localized_string_id::HOME_MENU_TROPHY_PLATINUM_RELEVANT) : ""));
|
||||
std::unique_ptr<overlay_element> subtext = std::make_unique<label>(details.description);
|
||||
|
||||
padding->set_size(1, 1);
|
||||
header_text->set_size(800, 40);
|
||||
|
@ -70,10 +94,6 @@ namespace rsx
|
|||
m_dim_background->set_size(virtual_width, virtual_height);
|
||||
m_dim_background->back_color.a = 0.9f;
|
||||
|
||||
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, 540);
|
||||
m_list->set_pos(20, 85);
|
||||
m_list->set_cancel_only(true);
|
||||
|
||||
m_description = std::make_unique<label>();
|
||||
m_description->set_font("Arial", 20);
|
||||
m_description->set_pos(20, 37);
|
||||
|
@ -81,6 +101,13 @@ namespace rsx
|
|||
m_description->auto_resize();
|
||||
m_description->back_color.a = 0.f;
|
||||
|
||||
m_show_hidden_trophies_button = std::make_unique<image_button>();
|
||||
m_show_hidden_trophies_button->set_text(m_show_hidden_trophies ? localized_string_id::HOME_MENU_TROPHY_HIDE_HIDDEN_TROPHIES : localized_string_id::HOME_MENU_TROPHY_SHOW_HIDDEN_TROPHIES);
|
||||
m_show_hidden_trophies_button->set_image_resource(resource_config::standard_image_resource::square);
|
||||
m_show_hidden_trophies_button->set_size(120, 30);
|
||||
m_show_hidden_trophies_button->set_pos(180, trophy_list_y + trophy_list_h + 20);
|
||||
m_show_hidden_trophies_button->set_font("Arial", 16);
|
||||
|
||||
fade_animation.duration_sec = 0.15f;
|
||||
|
||||
return_code = selection_code::canceled;
|
||||
|
@ -106,6 +133,10 @@ namespace rsx
|
|||
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav");
|
||||
close_dialog = true;
|
||||
break;
|
||||
case pad_button::square:
|
||||
m_show_hidden_trophies = !m_show_hidden_trophies;
|
||||
m_list_dirty = true;
|
||||
break;
|
||||
case pad_button::dpad_up:
|
||||
case pad_button::ls_up:
|
||||
m_list->select_previous();
|
||||
|
@ -150,10 +181,24 @@ namespace rsx
|
|||
return {};
|
||||
}
|
||||
|
||||
if (m_show_hidden_trophies_last != m_show_hidden_trophies)
|
||||
{
|
||||
m_show_hidden_trophies_button->set_text(m_show_hidden_trophies ? localized_string_id::HOME_MENU_TROPHY_HIDE_HIDDEN_TROPHIES : localized_string_id::HOME_MENU_TROPHY_SHOW_HIDDEN_TROPHIES);
|
||||
m_show_hidden_trophies_last = m_show_hidden_trophies;
|
||||
}
|
||||
|
||||
compiled_resource result;
|
||||
result.add(m_dim_background->get_compiled());
|
||||
result.add(m_list->get_compiled());
|
||||
if (m_list_dirty.exchange(false))
|
||||
{
|
||||
reload();
|
||||
}
|
||||
if (m_list)
|
||||
{
|
||||
result.add(m_list->get_compiled());
|
||||
}
|
||||
result.add(m_description->get_compiled());
|
||||
result.add(m_show_hidden_trophies_button->get_compiled());
|
||||
|
||||
fade_animation.apply(result);
|
||||
|
||||
|
@ -163,103 +208,9 @@ namespace rsx
|
|||
void trophy_list_dialog::show(const std::string& trop_name)
|
||||
{
|
||||
visible = false;
|
||||
|
||||
std::unique_ptr<trophy_data> data = load_trophies(trop_name);
|
||||
ensure(data && data->trop_usr);
|
||||
|
||||
rsx_log.trace("Populating Trophy List Overlay with %s %s", data->game_name, data->path);
|
||||
|
||||
std::vector<std::unique_ptr<overlay_element>> entries;
|
||||
|
||||
const int all_trophies = data->trop_usr->GetTrophiesCount();
|
||||
const int unlocked_trophies = data->trop_usr->GetUnlockedTrophiesCount();
|
||||
const int percentage = (all_trophies > 0) ? (100 * unlocked_trophies / all_trophies) : 0;
|
||||
|
||||
std::shared_ptr<rXmlNode> trophy_base = data->trop_config.GetRoot();
|
||||
if (!trophy_base)
|
||||
{
|
||||
rsx_log.error("Populating Trophy List Overlay failed (root is null): %s %s", data->game_name, data->path);
|
||||
}
|
||||
|
||||
const std::string hidden_title = get_localized_string(localized_string_id::HOME_MENU_TROPHY_HIDDEN_TITLE);
|
||||
const std::string hidden_description = get_localized_string(localized_string_id::HOME_MENU_TROPHY_HIDDEN_DESCRIPTION);
|
||||
|
||||
for (std::shared_ptr<rXmlNode> n = trophy_base ? trophy_base->GetChildren() : nullptr; n; n = n->GetNext())
|
||||
{
|
||||
// Only show trophies.
|
||||
if (n->GetName() != "trophy")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get data (stolen graciously from sceNpTrophy.cpp)
|
||||
SceNpTrophyDetails details{};
|
||||
|
||||
// Get trophy id
|
||||
const s32 trophy_id = atoi(n->GetAttribute("id").c_str());
|
||||
details.trophyId = trophy_id;
|
||||
|
||||
// Get platinum link id (we assume there only exists one platinum trophy per game for now)
|
||||
const s32 platinum_link_id = atoi(n->GetAttribute("pid").c_str());
|
||||
const bool platinum_relevant = platinum_link_id >= 0;
|
||||
|
||||
// Get trophy type
|
||||
std::string trophy_type;
|
||||
|
||||
switch (n->GetAttribute("ttype")[0])
|
||||
{
|
||||
case 'B': details.trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_BRONZE); break;
|
||||
case 'S': details.trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_SILVER); break;
|
||||
case 'G': details.trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_GOLD); break;
|
||||
case 'P': details.trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; trophy_type = get_localized_string(localized_string_id::HOME_MENU_TROPHY_GRADE_PLATINUM); break;
|
||||
default: rsx_log.warning("Unknown trophy grade %s", n->GetAttribute("ttype")); break;
|
||||
}
|
||||
|
||||
// Get hidden state
|
||||
const bool hidden = n->GetAttribute("hidden")[0] == 'y';
|
||||
details.hidden = hidden;
|
||||
|
||||
// Get name and detail
|
||||
if (hidden)
|
||||
{
|
||||
strcpy_trunc(details.name, hidden_title);
|
||||
strcpy_trunc(details.description, hidden_description);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::shared_ptr<rXmlNode> n2 = n->GetChildren(); n2; n2 = n2->GetNext())
|
||||
{
|
||||
const std::string name = n2->GetName();
|
||||
if (name == "name")
|
||||
{
|
||||
strcpy_trunc(details.name, n2->GetNodeContent());
|
||||
}
|
||||
else if (name == "detail")
|
||||
{
|
||||
strcpy_trunc(details.description, n2->GetNodeContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bool unlocked = data->trop_usr->GetTrophyUnlockState(trophy_id);
|
||||
const auto icon_path_it = data->trophy_image_paths.find(trophy_id);
|
||||
|
||||
std::unique_ptr<overlay_element> entry = std::make_unique<trophy_list_entry>(details.name, details.description, trophy_type, icon_path_it != data->trophy_image_paths.cend() ? icon_path_it->second : "", hidden, !unlocked, platinum_relevant);
|
||||
entries.emplace_back(std::move(entry));
|
||||
}
|
||||
|
||||
for (auto& entry : entries)
|
||||
{
|
||||
m_list->add_entry(entry);
|
||||
}
|
||||
|
||||
if (!m_list->m_items.empty())
|
||||
{
|
||||
m_list->select_entry(0);
|
||||
}
|
||||
|
||||
m_description->set_text(get_localized_string(localized_string_id::HOME_MENU_TROPHY_LIST_TITLE, fmt::format("%d%% (%d/%d)", percentage, unlocked_trophies, all_trophies).c_str()));
|
||||
m_description->auto_resize();
|
||||
|
||||
m_trophy_data = load_trophies(trop_name);
|
||||
ensure(m_trophy_data && m_trophy_data->trop_usr);
|
||||
|
||||
fade_animation.current = color4f(0.f);
|
||||
fade_animation.end = color4f(1.f);
|
||||
|
@ -351,5 +302,125 @@ namespace rsx
|
|||
|
||||
return game_trophy_data;
|
||||
}
|
||||
|
||||
void trophy_list_dialog::reload()
|
||||
{
|
||||
ensure(m_trophy_data);
|
||||
|
||||
rsx_log.trace("Reloading Trophy List Overlay with %s %s", m_trophy_data->game_name, m_trophy_data->path);
|
||||
|
||||
std::string selected_trophy;
|
||||
s32 selected_index = 0;
|
||||
const overlay_element* old_trophy = m_list ? m_list->get_selected_entry() : nullptr;
|
||||
const s32 old_trophy_id = old_trophy ? static_cast<const trophy_list_entry*>(old_trophy)->trophy_id : 0;
|
||||
|
||||
std::vector<std::unique_ptr<overlay_element>> entries;
|
||||
|
||||
const int all_trophies = m_trophy_data->trop_usr->GetTrophiesCount();
|
||||
const int unlocked_trophies = m_trophy_data->trop_usr->GetUnlockedTrophiesCount();
|
||||
const int percentage = (all_trophies > 0) ? (100 * unlocked_trophies / all_trophies) : 0;
|
||||
|
||||
std::shared_ptr<rXmlNode> trophy_base = m_trophy_data->trop_config.GetRoot();
|
||||
if (!trophy_base)
|
||||
{
|
||||
rsx_log.error("Populating Trophy List Overlay failed (root is null): %s %s", m_trophy_data->game_name, m_trophy_data->path);
|
||||
}
|
||||
|
||||
const std::string hidden_title = get_localized_string(localized_string_id::HOME_MENU_TROPHY_HIDDEN_TITLE);
|
||||
const std::string hidden_description = get_localized_string(localized_string_id::HOME_MENU_TROPHY_HIDDEN_DESCRIPTION);
|
||||
|
||||
for (std::shared_ptr<rXmlNode> n = trophy_base ? trophy_base->GetChildren() : nullptr; n; n = n->GetNext())
|
||||
{
|
||||
// Only show trophies.
|
||||
if (n->GetName() != "trophy")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get data (stolen graciously from sceNpTrophy.cpp)
|
||||
SceNpTrophyDetails details{};
|
||||
details.trophyId = atoi(n->GetAttribute("id").c_str());
|
||||
details.hidden = n->GetAttribute("hidden")[0] == 'y';
|
||||
|
||||
const bool hide_trophy = details.hidden && !m_show_hidden_trophies;
|
||||
|
||||
if (details.trophyId == old_trophy_id)
|
||||
{
|
||||
// Select this entry if the trophy is visible. Use the previous index otherwise.
|
||||
const s32 index = static_cast<s32>(entries.size());
|
||||
selected_index = hide_trophy ? std::max(0, index - 1) : index;
|
||||
}
|
||||
|
||||
if (hide_trophy)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get platinum link id (we assume there only exists one platinum trophy per game for now)
|
||||
const s32 platinum_link_id = atoi(n->GetAttribute("pid").c_str());
|
||||
const bool platinum_relevant = platinum_link_id >= 0;
|
||||
|
||||
// Get trophy type
|
||||
switch (n->GetAttribute("ttype")[0])
|
||||
{
|
||||
case 'B': details.trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break;
|
||||
case 'S': details.trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break;
|
||||
case 'G': details.trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; break;
|
||||
case 'P': details.trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break;
|
||||
default: rsx_log.warning("Unknown trophy grade %s", n->GetAttribute("ttype")); break;
|
||||
}
|
||||
|
||||
// Get name and detail
|
||||
if (details.hidden)
|
||||
{
|
||||
strcpy_trunc(details.name, hidden_title);
|
||||
strcpy_trunc(details.description, hidden_description);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::shared_ptr<rXmlNode> n2 = n->GetChildren(); n2; n2 = n2->GetNext())
|
||||
{
|
||||
const std::string name = n2->GetName();
|
||||
if (name == "name")
|
||||
{
|
||||
strcpy_trunc(details.name, n2->GetNodeContent());
|
||||
}
|
||||
else if (name == "detail")
|
||||
{
|
||||
strcpy_trunc(details.description, n2->GetNodeContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bool unlocked = m_trophy_data->trop_usr->GetTrophyUnlockState(details.trophyId);
|
||||
const auto icon_path_it = m_trophy_data->trophy_image_paths.find(details.trophyId);
|
||||
|
||||
std::unique_ptr<overlay_element> entry = std::make_unique<trophy_list_entry>(details, icon_path_it != m_trophy_data->trophy_image_paths.cend() ? icon_path_it->second : "", !unlocked, platinum_relevant);
|
||||
entries.emplace_back(std::move(entry));
|
||||
}
|
||||
|
||||
// Recreate list
|
||||
if (m_list)
|
||||
{
|
||||
status_flags |= status_bits::invalidate_image_cache;
|
||||
}
|
||||
|
||||
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, trophy_list_h);
|
||||
m_list->set_pos(20, trophy_list_y);
|
||||
m_list->set_cancel_only(true);
|
||||
|
||||
for (auto& entry : entries)
|
||||
{
|
||||
m_list->add_entry(entry);
|
||||
}
|
||||
|
||||
if (!m_list->m_items.empty())
|
||||
{
|
||||
m_list->select_entry(selected_index);
|
||||
}
|
||||
|
||||
m_description->set_text(get_localized_string(localized_string_id::HOME_MENU_TROPHY_LIST_TITLE, fmt::format("%d%% (%d/%d)", percentage, unlocked_trophies, all_trophies).c_str()));
|
||||
m_description->auto_resize();
|
||||
}
|
||||
} // namespace overlays
|
||||
} // namespace RSX
|
||||
|
|
|
@ -23,23 +23,21 @@ namespace rsx
|
|||
struct trophy_list_dialog : public user_interface
|
||||
{
|
||||
private:
|
||||
struct trophy_list_entry : horizontal_layout
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<image_info> icon_data;
|
||||
|
||||
public:
|
||||
trophy_list_entry(const std::string& name, const std::string& description, const std::string& trophy_type, const std::string& icon_path, bool hidden, bool locked, bool platinum_relevant);
|
||||
};
|
||||
|
||||
std::unique_ptr<trophy_data> load_trophies(const std::string& trop_name) const;
|
||||
void reload();
|
||||
|
||||
std::unique_ptr<overlay_element> m_dim_background;
|
||||
std::unique_ptr<list_view> m_list;
|
||||
std::unique_ptr<label> m_description;
|
||||
std::unique_ptr<image_button> m_show_hidden_trophies_button;
|
||||
|
||||
animation_color_interpolate fade_animation;
|
||||
|
||||
std::unique_ptr<trophy_data> m_trophy_data;
|
||||
atomic_t<bool> m_list_dirty { true };
|
||||
bool m_show_hidden_trophies = false;
|
||||
bool m_show_hidden_trophies_last = false;
|
||||
|
||||
public:
|
||||
trophy_list_dialog();
|
||||
|
||||
|
|
|
@ -596,7 +596,7 @@ namespace rsx
|
|||
cmd_text.verts = render_text(text.c_str(), static_cast<f32>(x), static_cast<f32>(y));
|
||||
|
||||
if (!cmd_text.verts.empty())
|
||||
compiled_resources.add(std::move(compiled_resources_temp), margin_left, margin_top);
|
||||
compiled_resources.add(std::move(compiled_resources_temp), margin_left - horizontal_scroll_offset, margin_top - vertical_scroll_offset);
|
||||
}
|
||||
|
||||
is_compiled = true;
|
||||
|
@ -735,14 +735,20 @@ namespace rsx
|
|||
{
|
||||
if (!item)
|
||||
{
|
||||
rsx_log.error("Found null item in overlay_controls");
|
||||
rsx_log.error("Found null item in overlay_controls::vertical_layout");
|
||||
continue;
|
||||
}
|
||||
|
||||
const s32 item_y_limit = s32{item->y} + item->h - scroll_offset_value - y;
|
||||
const s32 item_y_base = s32{item->y} - scroll_offset_value - y;
|
||||
|
||||
if (item_y_limit < 0 || item_y_base > h)
|
||||
if (item_y_base > h)
|
||||
{
|
||||
// Out of bounds. The following items will be too.
|
||||
break;
|
||||
}
|
||||
|
||||
if (item_y_limit < 0)
|
||||
{
|
||||
// Out of bounds
|
||||
continue;
|
||||
|
@ -809,15 +815,28 @@ namespace rsx
|
|||
|
||||
for (auto &item : m_items)
|
||||
{
|
||||
if (!item)
|
||||
{
|
||||
rsx_log.error("Found null item in overlay_controls::horizontal_layout");
|
||||
continue;
|
||||
}
|
||||
|
||||
const s32 item_x_limit = s32{item->x} + item->w - scroll_offset_value - w;
|
||||
const s32 item_x_base = s32{item->x} - scroll_offset_value - w;
|
||||
|
||||
if (item_x_limit < 0 || item_x_base > h)
|
||||
if (item_x_base > w)
|
||||
{
|
||||
// Out of bounds. The following items will be too.
|
||||
break;
|
||||
}
|
||||
|
||||
if (item_x_limit < 0)
|
||||
{
|
||||
// Out of bounds
|
||||
continue;
|
||||
}
|
||||
else if (item_x_limit > h || item_x_base < 0)
|
||||
|
||||
if (item_x_limit > w || item_x_base < 0)
|
||||
{
|
||||
// Partial render
|
||||
areaf clip_rect = static_cast<areaf>(areai{x, y, (x + w), (y + h)});
|
||||
|
|
|
@ -167,6 +167,8 @@ namespace rsx
|
|||
compiled_resource compiled_resources;
|
||||
bool is_compiled = false;
|
||||
|
||||
bool visible = true;
|
||||
|
||||
u16 padding_left = 0;
|
||||
u16 padding_right = 0;
|
||||
u16 padding_top = 0;
|
||||
|
@ -175,6 +177,9 @@ namespace rsx
|
|||
u16 margin_left = 0;
|
||||
u16 margin_top = 0;
|
||||
|
||||
f32 horizontal_scroll_offset = 0.0f;
|
||||
f32 vertical_scroll_offset = 0.0f;
|
||||
|
||||
overlay_element() = default;
|
||||
overlay_element(u16 _w, u16 _h) : w(_w), h(_h) {}
|
||||
virtual ~overlay_element() = default;
|
||||
|
|
|
@ -5,24 +5,24 @@ namespace rsx
|
|||
{
|
||||
namespace overlays
|
||||
{
|
||||
static usz get_line_start(const std::u32string& text, usz pos)
|
||||
static usz get_line_start(std::u32string_view text, usz pos)
|
||||
{
|
||||
if (pos == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const usz line_start = text.rfind('\n', pos - 1);
|
||||
if (line_start == std::string::npos)
|
||||
if (line_start == umax)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return line_start + 1;
|
||||
}
|
||||
|
||||
static usz get_line_end(const std::u32string& text, usz pos)
|
||||
static usz get_line_end(std::u32string_view text, usz pos)
|
||||
{
|
||||
const usz line_end = text.find('\n', pos);
|
||||
if (line_end == std::string::npos)
|
||||
if (line_end == umax)
|
||||
{
|
||||
return text.length();
|
||||
}
|
||||
|
@ -198,13 +198,11 @@ namespace rsx
|
|||
{
|
||||
if (!is_compiled)
|
||||
{
|
||||
auto& compiled = label::get_compiled();
|
||||
auto renderer = get_font();
|
||||
const auto [caret_x, caret_y] = renderer->get_char_offset(text.c_str(), caret_position, clip_text ? w : -1, wrap_text);
|
||||
|
||||
overlay_element caret;
|
||||
auto renderer = get_font();
|
||||
const auto caret_loc = renderer->get_char_offset(text.c_str(), caret_position, clip_text ? w : -1, wrap_text);
|
||||
|
||||
caret.set_pos(static_cast<u16>(caret_loc.first) + padding_left + x, static_cast<u16>(caret_loc.second) + padding_top + y);
|
||||
caret.set_pos(static_cast<u16>(caret_x) + padding_left + x, static_cast<u16>(caret_y) + padding_top + y);
|
||||
caret.set_size(1, static_cast<u16>(renderer->get_size_px() + 2));
|
||||
caret.fore_color = fore_color;
|
||||
caret.back_color = fore_color;
|
||||
|
@ -217,11 +215,39 @@ namespace rsx
|
|||
m_reset_caret_pulse = false;
|
||||
}
|
||||
|
||||
compiled.add(caret.get_compiled());
|
||||
// Check if we have to scroll horizontally
|
||||
// TODO: Vertical scrolling
|
||||
const s32 available_width = w - padding_left - padding_right;
|
||||
const f32 offset_right = caret_x + caret.w - available_width;
|
||||
|
||||
if (text.empty())
|
||||
{
|
||||
// Scroll to the beginning
|
||||
horizontal_scroll_offset = 0.0f;
|
||||
}
|
||||
else if (horizontal_scroll_offset >= caret_x)
|
||||
{
|
||||
// Scroll to the left so that the entire caret is visible
|
||||
horizontal_scroll_offset = caret_x;
|
||||
}
|
||||
else if (horizontal_scroll_offset <= offset_right && offset_right > 0.0f)
|
||||
{
|
||||
// Scroll to the right so that the entire caret is visible
|
||||
horizontal_scroll_offset = offset_right;
|
||||
}
|
||||
else if (horizontal_scroll_offset > 0.0f && offset_right > 0.0f && caret_position >= text.size())
|
||||
{
|
||||
// Scroll to the left so that the entire caret is visible and reveal preceding text
|
||||
horizontal_scroll_offset = offset_right;
|
||||
}
|
||||
|
||||
horizontal_scroll_offset = std::max(0.0f, horizontal_scroll_offset);
|
||||
|
||||
auto& compiled = label::get_compiled();
|
||||
compiled.add(caret.get_compiled(), -horizontal_scroll_offset, -vertical_scroll_offset);
|
||||
|
||||
for (auto& cmd : compiled.draw_commands)
|
||||
{
|
||||
// TODO: Scrolling by using scroll offset
|
||||
cmd.config.clip_region = true;
|
||||
cmd.config.clip_rect = {static_cast<f32>(x), static_cast<f32>(y), static_cast<f32>(x + w), static_cast<f32>(y + h)};
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace rsx
|
|||
};
|
||||
|
||||
usz caret_position = 0;
|
||||
u16 vertical_scroll_offset = 0;
|
||||
|
||||
bool m_reset_caret_pulse = false;
|
||||
bool password_mode = false;
|
||||
|
|
|
@ -417,13 +417,14 @@ namespace rsx
|
|||
return {loc_x, loc_y};
|
||||
}
|
||||
|
||||
std::vector<u8> font::get_glyph_data() const
|
||||
const std::vector<u8>& font::get_glyph_data() const
|
||||
{
|
||||
std::vector<u8> bytes;
|
||||
const u32 page_size = codepage::bitmap_width * codepage::bitmap_height;
|
||||
constexpr u32 page_size = codepage::bitmap_width * codepage::bitmap_height;
|
||||
const auto size = page_size * m_glyph_map.size();
|
||||
|
||||
static thread_local std::vector<u8> bytes;
|
||||
bytes.resize(size);
|
||||
|
||||
u8* data = bytes.data();
|
||||
|
||||
for (const auto& e : m_glyph_map)
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace rsx
|
|||
|
||||
std::pair<f32, f32> get_char_offset(const char32_t* text, usz max_length, u16 max_width = -1, bool wrap = false);
|
||||
|
||||
bool matches(const char* name, int size) const { return font_name == name && static_cast<int>(size_pt) == size; }
|
||||
bool matches(const char* name, int size) const { return static_cast<int>(size_pt) == size && font_name == name; }
|
||||
std::string_view get_name() const { return font_name; }
|
||||
f32 get_size_pt() const { return size_pt; }
|
||||
f32 get_size_px() const { return size_px; }
|
||||
|
@ -87,7 +87,7 @@ namespace rsx
|
|||
|
||||
// Renderer info
|
||||
size3u get_glyph_data_dimensions() const { return { codepage::bitmap_width, codepage::bitmap_height, ::size32(m_glyph_map) }; }
|
||||
std::vector<u8> get_glyph_data() const;
|
||||
const std::vector<u8>& get_glyph_data() const;
|
||||
};
|
||||
|
||||
// TODO: Singletons are cancer
|
||||
|
@ -99,7 +99,7 @@ namespace rsx
|
|||
|
||||
font* find(const char* name, int size)
|
||||
{
|
||||
for (auto& f : fonts)
|
||||
for (const auto& f : fonts)
|
||||
{
|
||||
if (f->matches(name, size))
|
||||
return f.get();
|
||||
|
|
|
@ -71,25 +71,34 @@ namespace rsx
|
|||
m_scroll_indicator_bottom->fore_color.a = 0.f;
|
||||
}
|
||||
|
||||
void list_view::update_selection()
|
||||
const overlay_element* list_view::get_selected_entry() const
|
||||
{
|
||||
if (m_selected_entry < 0)
|
||||
{
|
||||
return; // Ideally unreachable but it should still be possible to recover by user interaction.
|
||||
return nullptr; // Ideally unreachable but it should still be possible to recover by user interaction.
|
||||
}
|
||||
|
||||
const usz current_index = static_cast<usz>(m_selected_entry) * (m_use_separators ? 2 : 1);
|
||||
|
||||
if (m_items.size() <= current_index)
|
||||
if (current_index >= m_items.size())
|
||||
{
|
||||
return nullptr; // Ideally unreachable but it should still be possible to recover by user interaction.
|
||||
}
|
||||
|
||||
return m_items[current_index].get();
|
||||
}
|
||||
|
||||
void list_view::update_selection()
|
||||
{
|
||||
const overlay_element* current_element = get_selected_entry();
|
||||
if (!current_element)
|
||||
{
|
||||
return; // Ideally unreachable but it should still be possible to recover by user interaction.
|
||||
}
|
||||
|
||||
auto current_element = m_items[current_index].get();
|
||||
|
||||
// Calculate bounds
|
||||
auto min_y = current_element->y - y;
|
||||
auto max_y = current_element->y + current_element->h + pack_padding + 2 - y;
|
||||
const auto min_y = current_element->y - y;
|
||||
const auto max_y = current_element->y + current_element->h + pack_padding + 2 - y;
|
||||
|
||||
if (min_y < scroll_offset_value)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace rsx
|
|||
|
||||
int get_selected_index() const;
|
||||
bool get_cancel_only() const;
|
||||
const overlay_element* get_selected_entry() const;
|
||||
|
||||
void set_cancel_only(bool cancel_only);
|
||||
void translate(s16 _x, s16 _y) override;
|
||||
|
|
|
@ -435,7 +435,7 @@ namespace rsx
|
|||
|
||||
m_preview.set_pos(input_x, input_y + title_height);
|
||||
m_preview.set_size(input_w, preview_height);
|
||||
m_preview.set_padding(get_scaled(15), 0, get_scaled(10), 0);
|
||||
m_preview.set_padding(get_scaled(15), get_scaled(15), get_scaled(10), 0);
|
||||
|
||||
const s16 button_y = panel_y + panel_h + button_margin;
|
||||
|
||||
|
|
|
@ -508,16 +508,14 @@ namespace vk
|
|||
{
|
||||
return found->second.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto gc = vk::get_resource_manager();
|
||||
gc->dispose(font_cache[key]);
|
||||
gc->dispose(view_cache[key]);
|
||||
}
|
||||
|
||||
auto gc = vk::get_resource_manager();
|
||||
gc->dispose(font_cache[key]);
|
||||
gc->dispose(view_cache[key]);
|
||||
}
|
||||
|
||||
// Create font resource
|
||||
const std::vector<u8> bytes = font->get_glyph_data();
|
||||
const std::vector<u8>& bytes = font->get_glyph_data();
|
||||
|
||||
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, image_size.width, image_size.height, image_size.depth,
|
||||
true, false, bytes.data(), -1);
|
||||
|
|
|
@ -276,6 +276,8 @@ enum class localized_string_id
|
|||
HOME_MENU_TROPHY_LOCKED_TITLE,
|
||||
HOME_MENU_TROPHY_HIDDEN_TITLE,
|
||||
HOME_MENU_TROPHY_HIDDEN_DESCRIPTION,
|
||||
HOME_MENU_TROPHY_SHOW_HIDDEN_TROPHIES,
|
||||
HOME_MENU_TROPHY_HIDE_HIDDEN_TROPHIES,
|
||||
HOME_MENU_TROPHY_PLATINUM_RELEVANT,
|
||||
HOME_MENU_TROPHY_GRADE_BRONZE,
|
||||
HOME_MENU_TROPHY_GRADE_SILVER,
|
||||
|
|
|
@ -297,6 +297,8 @@ private:
|
|||
case localized_string_id::HOME_MENU_TROPHY_LOCKED_TITLE: return tr("Locked trophy: %0").arg(std::forward<Args>(args)...);
|
||||
case localized_string_id::HOME_MENU_TROPHY_HIDDEN_TITLE: return tr("Hidden trophy");
|
||||
case localized_string_id::HOME_MENU_TROPHY_HIDDEN_DESCRIPTION: return tr("This trophy is hidden");
|
||||
case localized_string_id::HOME_MENU_TROPHY_SHOW_HIDDEN_TROPHIES: return tr("Show hidden trophies");
|
||||
case localized_string_id::HOME_MENU_TROPHY_HIDE_HIDDEN_TROPHIES: return tr("Hide hidden trophies");
|
||||
case localized_string_id::HOME_MENU_TROPHY_PLATINUM_RELEVANT: return tr("Platinum relevant");
|
||||
case localized_string_id::HOME_MENU_TROPHY_GRADE_BRONZE: return tr("Bronze", "Trophy type");
|
||||
case localized_string_id::HOME_MENU_TROPHY_GRADE_SILVER: return tr("Silver", "Trophy type");
|
||||
|
|
Loading…
Add table
Reference in a new issue