mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 06:38:46 +00:00
parent
55f4e39506
commit
d2a7c78316
3 changed files with 1205 additions and 28 deletions
|
@ -6,38 +6,38 @@
|
||||||
#include "src/qt_gui/discord_rpc_handler.h"
|
#include "src/qt_gui/discord_rpc_handler.h"
|
||||||
|
|
||||||
namespace DiscordRPCHandler {
|
namespace DiscordRPCHandler {
|
||||||
|
|
||||||
|
void RPC::init() {
|
||||||
|
DiscordEventHandlers handlers{};
|
||||||
|
std::string discordAppId = "1290207945476280360";
|
||||||
|
Discord_Initialize(discordAppId.c_str(), &handlers, 1, nullptr);
|
||||||
|
startTimestamp = time(nullptr);
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
void RPC::init() {
|
void RPC::setStatusIdling() {
|
||||||
DiscordEventHandlers handlers{};
|
DiscordRichPresence rpc{};
|
||||||
std::string discordAppId = "1290207945476280360";
|
rpc.largeImageKey = "https://github.com/shadps4-emu/shadPS4/raw/main/.github/shadps4.png";
|
||||||
Discord_Initialize(discordAppId.c_str(), &handlers, 1, nullptr);
|
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
||||||
startTimestamp = time(nullptr);
|
rpc.startTimestamp = startTimestamp;
|
||||||
enabled = true;
|
rpc.details = "Idle";
|
||||||
}
|
|
||||||
|
|
||||||
void RPC::setStatusIdling() {
|
Discord_UpdatePresence(&rpc);
|
||||||
DiscordRichPresence rpc{};
|
}
|
||||||
rpc.largeImageKey = "https://github.com/shadps4-emu/shadPS4/raw/main/.github/shadps4.png";
|
|
||||||
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
|
||||||
rpc.startTimestamp = startTimestamp;
|
|
||||||
rpc.details = "Idle";
|
|
||||||
|
|
||||||
Discord_UpdatePresence(&rpc);
|
void RPC::setStatusPlaying(const std::string& game_name, const std::string& game_id) {
|
||||||
}
|
DiscordRichPresence rpc{};
|
||||||
|
|
||||||
void RPC::setStatusPlaying(const std::string& game_name, const std::string& game_id) {
|
rpc.details = "Playing";
|
||||||
DiscordRichPresence rpc{};
|
rpc.state = game_name.c_str();
|
||||||
|
std::string largeImageUrl =
|
||||||
|
"https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/US/en/999/" +
|
||||||
|
game_id + "_00/image";
|
||||||
|
rpc.largeImageKey = largeImageUrl.c_str();
|
||||||
|
rpc.largeImageText = game_name.c_str();
|
||||||
|
rpc.startTimestamp = startTimestamp;
|
||||||
|
|
||||||
rpc.details = "Playing";
|
Discord_UpdatePresence(&rpc);
|
||||||
rpc.state = game_name.c_str();
|
}
|
||||||
std::string largeImageUrl =
|
|
||||||
"https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/US/en/999/" +
|
|
||||||
game_id + "_00/image";
|
|
||||||
rpc.largeImageKey = largeImageUrl.c_str();
|
|
||||||
rpc.largeImageText = game_name.c_str();
|
|
||||||
rpc.startTimestamp = startTimestamp;
|
|
||||||
|
|
||||||
Discord_UpdatePresence(&rpc);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace DiscordRPCHandler
|
} // namespace DiscordRPCHandler
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,124 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QActionGroup>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include "background_music_player.h"
|
||||||
|
#include "common/config.h"
|
||||||
|
#include "common/path_util.h"
|
||||||
|
#include "core/file_format/psf.h"
|
||||||
|
#include "core/file_sys/fs.h"
|
||||||
|
#include "qt_gui/discord_rpc_handler.h"
|
||||||
|
#include "elf_viewer.h"
|
||||||
|
#include "emulator.h"
|
||||||
|
#include "game_grid_frame.h"
|
||||||
|
#include "game_info.h"
|
||||||
|
#include "game_list_frame.h"
|
||||||
|
#include "game_list_utils.h"
|
||||||
|
#include "main_window_themes.h"
|
||||||
|
#include "main_window_ui.h"
|
||||||
|
#include "pkg_viewer.h"
|
||||||
|
|
||||||
|
class GameListFrame;
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
signals:
|
||||||
|
void WindowResized(QResizeEvent* event);
|
||||||
|
void ExtractionFinished();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget* parent = nullptr);
|
||||||
|
~MainWindow();
|
||||||
|
bool Init();
|
||||||
|
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
|
||||||
|
void InstallDirectory();
|
||||||
|
void StartGame();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void ConfigureGuiFromSettings();
|
||||||
|
void SaveWindowState() const;
|
||||||
|
void SearchGameTable(const QString& text);
|
||||||
|
void ShowGameList();
|
||||||
|
void RefreshGameTable();
|
||||||
|
void HandleResize(QResizeEvent* event);
|
||||||
|
void OnLanguageChanged(const std::string& locale);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui_MainWindow* ui;
|
||||||
|
void AddUiWidgets();
|
||||||
|
void CreateActions();
|
||||||
|
void CreateRecentGameActions();
|
||||||
|
void CreateDockWindows();
|
||||||
|
void GetPhysicalDevices();
|
||||||
|
void LoadGameLists();
|
||||||
|
void CheckUpdateMain(bool checkSave);
|
||||||
|
void CreateConnects();
|
||||||
|
void SetLastUsedTheme();
|
||||||
|
void SetLastIconSizeBullet();
|
||||||
|
void SetUiIcons(bool isWhite);
|
||||||
|
void InstallPkg();
|
||||||
|
void BootGame();
|
||||||
|
void AddRecentFiles(QString filePath);
|
||||||
|
void LoadTranslation();
|
||||||
|
void PlayBackgroundMusic();
|
||||||
|
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
|
||||||
|
bool isIconBlack = false;
|
||||||
|
bool isTableList = true;
|
||||||
|
bool isGameRunning = false;
|
||||||
|
QActionGroup* m_icon_size_act_group = nullptr;
|
||||||
|
QActionGroup* m_list_mode_act_group = nullptr;
|
||||||
|
QActionGroup* m_theme_act_group = nullptr;
|
||||||
|
QActionGroup* m_recent_files_group = nullptr;
|
||||||
|
PKG pkg;
|
||||||
|
// Dockable widget frames
|
||||||
|
WindowThemes m_window_themes;
|
||||||
|
GameListUtils m_game_list_utils;
|
||||||
|
QScopedPointer<QDockWidget> m_dock_widget;
|
||||||
|
// Game Lists
|
||||||
|
QScopedPointer<GameListFrame> m_game_list_frame;
|
||||||
|
QScopedPointer<GameGridFrame> m_game_grid_frame;
|
||||||
|
QScopedPointer<ElfViewer> m_elf_viewer;
|
||||||
|
// Status Bar.
|
||||||
|
QScopedPointer<QStatusBar> statusBar;
|
||||||
|
// Available GPU devices
|
||||||
|
std::vector<QString> m_physical_devices;
|
||||||
|
|
||||||
|
PSF psf;
|
||||||
|
|
||||||
|
std::shared_ptr<GameInfoClass> m_game_info = std::make_shared<GameInfoClass>();
|
||||||
|
|
||||||
|
QTranslator* translator;
|
||||||
|
|
||||||
|
DiscordRPCHandler::RPC discordRPC;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
|
|
||||||
|
void dragEnterEvent(QDragEnterEvent* event1) override {
|
||||||
|
if (event1->mimeData()->hasUrls()) {
|
||||||
|
event1->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dropEvent(QDropEvent* event1) override {
|
||||||
|
const QMimeData* mimeData = event1->mimeData();
|
||||||
|
if (mimeData->hasUrls()) {
|
||||||
|
QList<QUrl> urlList = mimeData->urls();
|
||||||
|
int pkgNum = 0;
|
||||||
|
int nPkg = urlList.size();
|
||||||
|
for (const QUrl& url : urlList) {
|
||||||
|
pkgNum++;
|
||||||
|
std::filesystem::path path = Common::FS::PathFromQString(url.toLocalFile());
|
||||||
|
InstallDragDropPkg(path, pkgNum, nPkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue