ppsspp/UI/RetroAchievementScreens.h

145 lines
4.8 KiB
C
Raw Normal View History

#pragma once
2023-06-27 21:31:15 +00:00
#include <cstdint>
#include "Common/File/Path.h"
2023-06-17 20:22:59 +00:00
#include "Common/UI/View.h"
#include "Common/UI/UIScreen.h"
#include "Common/UI/ViewGroup.h"
#include "Core/RetroAchievements.h"
#include "UI/MiscScreens.h"
#include "UI/TabbedDialogScreen.h"
2023-12-30 10:22:24 +00:00
#include "ext/rcheevos/include/rc_client.h"
// Lists the achievements and leaderboards for one game.
class RetroAchievementsListScreen : public TabbedUIDialogScreenWithGameBackground {
public:
RetroAchievementsListScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
const char *tag() const override { return "RetroAchievementsListScreen"; }
void CreateTabs() override;
protected:
bool ShowSearchControls() const override { return false; }
2023-06-27 09:12:25 +00:00
private:
void CreateAchievementsTab(UI::ViewGroup *viewGroup);
void CreateLeaderboardsTab(UI::ViewGroup *viewGroup);
void CreateStatisticsTab(UI::ViewGroup *viewGroup);
};
2023-06-16 11:25:03 +00:00
// Lets you manage your account, and shows some achievement stats and stuff.
class RetroAchievementsSettingsScreen : public TabbedUIDialogScreenWithGameBackground {
2023-06-16 11:25:03 +00:00
public:
RetroAchievementsSettingsScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
~RetroAchievementsSettingsScreen();
const char *tag() const override { return "RetroAchievementsSettingsScreen"; }
2023-06-16 11:25:03 +00:00
void CreateTabs() override;
void sendMessage(UIMessage message, const char *value) override;
protected:
bool ShowSearchControls() const override { return false; }
private:
void CreateAccountTab(UI::ViewGroup *viewGroup);
void CreateCustomizeTab(UI::ViewGroup *viewGroup);
void CreateDeveloperToolsTab(UI::ViewGroup *viewGroup);
std::string username_;
std::string password_;
2023-06-16 11:25:03 +00:00
};
2023-06-17 20:22:59 +00:00
2023-06-27 09:12:25 +00:00
class RetroAchievementsLeaderboardScreen : public TabbedUIDialogScreenWithGameBackground {
public:
2023-06-27 21:31:15 +00:00
RetroAchievementsLeaderboardScreen(const Path &gamePath, int leaderboardID);
~RetroAchievementsLeaderboardScreen();
2023-06-27 09:12:25 +00:00
const char *tag() const override { return "RetroAchievementsLeaderboardScreen"; }
void CreateTabs() override;
void update() override;
2023-06-27 21:31:15 +00:00
2023-06-27 09:12:25 +00:00
protected:
bool ShowSearchControls() const override { return false; }
2023-06-27 21:31:15 +00:00
2023-06-27 09:12:25 +00:00
private:
void FetchEntries();
2023-06-27 09:12:25 +00:00
void Poll();
int leaderboardID_;
bool nearMe_ = false;
2023-06-27 21:31:15 +00:00
// Keep the fetched list alive and destroy in destructor.
rc_client_leaderboard_entry_list_t *entryList_ = nullptr;
rc_client_leaderboard_entry_list_t *pendingEntryList_ = nullptr;
rc_client_async_handle_t *pendingAsyncCall_ = nullptr;
2023-06-27 09:12:25 +00:00
};
2023-06-17 20:22:59 +00:00
class UIContext;
enum class AchievementRenderStyle {
LISTED,
UNLOCKED,
2023-06-27 21:31:15 +00:00
PROGRESS_INDICATOR,
CHALLENGE_INDICATOR,
2023-06-17 20:22:59 +00:00
};
2023-06-27 21:31:15 +00:00
void MeasureAchievement(const UIContext &dc, const rc_client_achievement_t *achievement, AchievementRenderStyle style, float *w, float *h);
void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement, AchievementRenderStyle style, const Bounds &bounds, float alpha, float startTime, float time_s, bool hasFocus);
2023-06-27 21:31:15 +00:00
class AchievementView : public UI::ClickableItem {
2023-06-17 20:22:59 +00:00
public:
AchievementView(const rc_client_achievement_t *achievement, UI::LayoutParams *layoutParams = nullptr) : UI::ClickableItem(layoutParams), achievement_(achievement) {
layoutParams_->height = UI::WRAP_CONTENT; // Override the standard Item fixed height.
}
2023-06-17 20:22:59 +00:00
void Click() override;
2023-06-17 20:22:59 +00:00
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
private:
2023-06-27 21:31:15 +00:00
const rc_client_achievement_t *achievement_;
2023-06-17 20:22:59 +00:00
};
class GameAchievementSummaryView : public UI::Item {
public:
GameAchievementSummaryView(UI::LayoutParams *layoutParams = nullptr) : UI::Item(layoutParams) {
layoutParams_->height = UI::WRAP_CONTENT; // Override the standard Item fixed height.
}
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
};
2023-06-27 09:12:25 +00:00
class LeaderboardSummaryView : public UI::ClickableItem {
public:
LeaderboardSummaryView(const rc_client_leaderboard_t *leaderboard, UI::LayoutParams *layoutParams = nullptr) : UI::ClickableItem(layoutParams), leaderboard_(leaderboard) {
layoutParams_->height = UI::WRAP_CONTENT; // Override the standard Item fixed height.
}
2023-06-27 09:12:25 +00:00
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
private:
2023-06-27 21:31:15 +00:00
const rc_client_leaderboard_t *leaderboard_;
2023-06-27 09:12:25 +00:00
};
class LeaderboardEntryView : public UI::Item {
public:
LeaderboardEntryView(const rc_client_leaderboard_entry_t *entry, bool isCurrentUser, UI::LayoutParams *layoutParams = nullptr)
: UI::Item(layoutParams), entry_(entry), isCurrentUser_(isCurrentUser) {
layoutParams_->height = UI::WRAP_CONTENT; // Override the standard Item fixed height.
}
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
private:
const rc_client_leaderboard_entry_t *entry_;
bool isCurrentUser_;
};