mirror of
https://github.com/redstrate/Astra.git
synced 2025-06-07 14:37:45 +00:00
Add game logo image to the login page
This loads the A Realm Reborn logo (for now) from the game and displays in on the login page.
This commit is contained in:
parent
f97204a422
commit
001e20b1b8
4 changed files with 56 additions and 1 deletions
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
|
@ -13,7 +13,7 @@ find_package(Corrosion REQUIRED)
|
|||
|
||||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libphysis/Cargo.toml
|
||||
NO_DEFAULT_FEATURES
|
||||
FEATURES game_install)
|
||||
FEATURES game_install visual_data) # FIXME: split visual_data? we only need texture decompression
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libphysis/logger EXCLUDE_FROM_ALL)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
|
|
@ -67,6 +67,7 @@ class LauncherCore : public QObject
|
|||
Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged)
|
||||
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
|
||||
Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged)
|
||||
Q_PROPERTY(QString cachedLogoImage READ cachedLogoImage NOTIFY cachedLogoImageChanged)
|
||||
|
||||
public:
|
||||
LauncherCore();
|
||||
|
@ -89,6 +90,7 @@ public:
|
|||
|
||||
Q_INVOKABLE void clearAvatarCache();
|
||||
Q_INVOKABLE void refreshNews();
|
||||
Q_INVOKABLE void refreshLogoImage();
|
||||
|
||||
[[nodiscard]] Profile *currentProfile() const;
|
||||
void setCurrentProfile(Profile *profile);
|
||||
|
@ -111,6 +113,7 @@ public:
|
|||
[[nodiscard]] ProfileManager *profileManager();
|
||||
[[nodiscard]] AccountManager *accountManager();
|
||||
[[nodiscard]] Headline *headline() const;
|
||||
[[nodiscard]] QString cachedLogoImage() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void loadingFinished();
|
||||
|
@ -124,6 +127,7 @@ Q_SIGNALS:
|
|||
void newsChanged();
|
||||
void currentProfileChanged();
|
||||
void autoLoginProfileChanged();
|
||||
void cachedLogoImageChanged();
|
||||
|
||||
protected:
|
||||
friend class Patcher;
|
||||
|
@ -149,6 +153,7 @@ private:
|
|||
Headline *m_headline = nullptr;
|
||||
LauncherSettings *m_settings = nullptr;
|
||||
GameRunner *m_runner = nullptr;
|
||||
QString m_cachedLogoImage;
|
||||
|
||||
int m_currentProfileIndex = 0;
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
#include <QDir>
|
||||
#include <QImage>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QStandardPaths>
|
||||
#include <algorithm>
|
||||
|
@ -122,6 +123,34 @@ void LauncherCore::refreshNews()
|
|||
fetchNews();
|
||||
}
|
||||
|
||||
void LauncherCore::refreshLogoImage()
|
||||
{
|
||||
const QDir cacheDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::CacheLocation).last();
|
||||
|
||||
QFileInfo logoImageFile(cacheDir.absoluteFilePath(QStringLiteral("logo.png")));
|
||||
if (logoImageFile.exists()) {
|
||||
m_cachedLogoImage = logoImageFile.absoluteFilePath();
|
||||
Q_EMIT cachedLogoImageChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_profileManager->numProfiles(); i++) {
|
||||
auto profile = m_profileManager->getProfile(i);
|
||||
if (profile->isGameInstalled() && profile->gameData()) {
|
||||
auto file = physis_gamedata_extract_file(profile->gameData(), "ui/uld/Title_Logo.tex");
|
||||
auto tex = physis_texture_parse(file);
|
||||
|
||||
QImage image(tex.rgba, tex.width, tex.height, QImage::Format_RGBA8888);
|
||||
image.save(logoImageFile.absoluteFilePath());
|
||||
|
||||
m_cachedLogoImage = logoImageFile.absoluteFilePath();
|
||||
Q_EMIT cachedLogoImageChanged();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Profile *LauncherCore::currentProfile() const
|
||||
{
|
||||
return m_profileManager->getProfile(m_currentProfileIndex);
|
||||
|
@ -246,6 +275,11 @@ Headline *LauncherCore::headline() const
|
|||
return m_headline;
|
||||
}
|
||||
|
||||
QString LauncherCore::cachedLogoImage() const
|
||||
{
|
||||
return m_cachedLogoImage;
|
||||
}
|
||||
|
||||
QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
|
||||
{
|
||||
info.profile->account()->updateConfig();
|
||||
|
|
|
@ -75,6 +75,7 @@ QQC2.Control {
|
|||
|
||||
function onCurrentProfileChanged() {
|
||||
page.updateFields();
|
||||
LauncherCore.refreshLogoImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,11 +104,25 @@ QQC2.Control {
|
|||
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
Image {
|
||||
readonly property real aspectRatio: sourceSize.height / sourceSize.width
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "file://" + LauncherCore.cachedLogoImage
|
||||
verticalAlignment: Image.AlignTop
|
||||
sourceClipRect: Qt.rect(0, sourceSize.height / 2, sourceSize.width, sourceSize.height / 2)
|
||||
|
||||
Component.onCompleted: LauncherCore.refreshLogoImage()
|
||||
Layout.preferredWidth: parent.width
|
||||
Layout.preferredHeight: width * aspectRatio
|
||||
}
|
||||
|
||||
FormCard.FormCard {
|
||||
maximumWidth: Kirigami.Units.gridUnit * 25
|
||||
visible: LauncherCore.profileManager.numProfiles > 1
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: currentProfileDelegate
|
||||
|
@ -263,6 +278,7 @@ QQC2.Control {
|
|||
FormCard.FormDelegateSeparator {
|
||||
above: loginButton
|
||||
below: forgotPasswordButton
|
||||
visible: !LauncherCore.currentProfile.account.isSapphire
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
|
|
Loading…
Add table
Reference in a new issue