2023-06-15 11:40:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-27 21:31:15 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
2023-07-02 10:00:13 +00:00
|
|
|
#include "Common/File/Path.h"
|
2023-06-17 20:22:59 +00:00
|
|
|
#include "Common/UI/View.h"
|
2023-06-15 11:40:37 +00:00
|
|
|
#include "Common/UI/UIScreen.h"
|
|
|
|
#include "Common/UI/ViewGroup.h"
|
2023-07-02 10:00:13 +00:00
|
|
|
#include "Core/RetroAchievements.h"
|
2023-06-15 11:40:37 +00:00
|
|
|
#include "UI/MiscScreens.h"
|
2023-06-16 14:29:44 +00:00
|
|
|
#include "UI/TabbedDialogScreen.h"
|
2023-06-15 11:40:37 +00:00
|
|
|
|
2023-12-30 10:22:24 +00:00
|
|
|
#include "ext/rcheevos/include/rc_client.h"
|
|
|
|
|
2023-06-21 12:32:10 +00:00
|
|
|
// Lists the achievements and leaderboards for one game.
|
|
|
|
class RetroAchievementsListScreen : public TabbedUIDialogScreenWithGameBackground {
|
2023-06-15 11:40:37 +00:00
|
|
|
public:
|
2023-06-21 12:32:10 +00:00
|
|
|
RetroAchievementsListScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
|
2023-06-15 11:40:37 +00:00
|
|
|
const char *tag() const override { return "RetroAchievementsListScreen"; }
|
|
|
|
|
2023-06-21 12:32:10 +00:00
|
|
|
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-15 11:40:37 +00:00
|
|
|
};
|
2023-06-16 11:25:03 +00:00
|
|
|
|
2023-06-21 12:32:10 +00:00
|
|
|
// Lets you manage your account, and shows some achievement stats and stuff.
|
2023-06-16 14:29:44 +00:00
|
|
|
class RetroAchievementsSettingsScreen : public TabbedUIDialogScreenWithGameBackground {
|
2023-06-16 11:25:03 +00:00
|
|
|
public:
|
2023-06-16 14:29:44 +00:00
|
|
|
RetroAchievementsSettingsScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
|
2023-06-27 12:58:39 +00:00
|
|
|
~RetroAchievementsSettingsScreen();
|
2023-06-16 14:29:44 +00:00
|
|
|
const char *tag() const override { return "RetroAchievementsSettingsScreen"; }
|
2023-06-16 11:25:03 +00:00
|
|
|
|
2023-06-16 14:29:44 +00:00
|
|
|
void CreateTabs() override;
|
2023-09-30 09:21:22 +00:00
|
|
|
void sendMessage(UIMessage message, const char *value) override;
|
2023-06-16 14:29:44 +00:00
|
|
|
|
2023-06-21 10:17:44 +00:00
|
|
|
protected:
|
|
|
|
bool ShowSearchControls() const override { return false; }
|
|
|
|
|
2023-06-16 14:29:44 +00:00
|
|
|
private:
|
|
|
|
void CreateAccountTab(UI::ViewGroup *viewGroup);
|
2023-07-16 10:15:44 +00:00
|
|
|
void CreateCustomizeTab(UI::ViewGroup *viewGroup);
|
2023-07-11 08:30:50 +00:00
|
|
|
void CreateDeveloperToolsTab(UI::ViewGroup *viewGroup);
|
2023-06-21 13:45:07 +00:00
|
|
|
|
|
|
|
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:
|
2023-08-01 11:48:27 +00:00
|
|
|
void FetchEntries();
|
2023-06-27 09:12:25 +00:00
|
|
|
void Poll();
|
|
|
|
|
|
|
|
int leaderboardID_;
|
2023-08-01 11:48:27 +00:00
|
|
|
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,
|
2023-07-03 12:39:49 +00:00
|
|
|
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);
|
2023-07-16 20:07:26 +00:00
|
|
|
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
|
|
|
|
2023-06-21 10:17:44 +00:00
|
|
|
class AchievementView : public UI::ClickableItem {
|
2023-06-17 20:22:59 +00:00
|
|
|
public:
|
2023-06-27 12:58:39 +00:00
|
|
|
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
|
|
|
|
2023-06-21 10:17:44 +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
|
|
|
};
|
2023-06-19 21:47:23 +00:00
|
|
|
|
2023-07-02 15:12:46 +00:00
|
|
|
class GameAchievementSummaryView : public UI::Item {
|
|
|
|
public:
|
2023-06-27 12:58:39 +00:00
|
|
|
GameAchievementSummaryView(UI::LayoutParams *layoutParams = nullptr) : UI::Item(layoutParams) {
|
|
|
|
layoutParams_->height = UI::WRAP_CONTENT; // Override the standard Item fixed height.
|
|
|
|
}
|
2023-07-02 15:12:46 +00:00
|
|
|
|
|
|
|
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:
|
2023-06-27 12:58:39 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2023-07-02 15:12:46 +00:00
|
|
|
class LeaderboardEntryView : public UI::Item {
|
2023-06-19 21:47:23 +00:00
|
|
|
public:
|
2023-06-27 12:58:39 +00:00
|
|
|
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.
|
|
|
|
}
|
2023-06-19 21:47:23 +00:00
|
|
|
|
|
|
|
void Draw(UIContext &dc) override;
|
|
|
|
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
2023-07-02 15:12:46 +00:00
|
|
|
|
2023-06-19 21:47:23 +00:00
|
|
|
private:
|
2023-07-02 15:12:46 +00:00
|
|
|
const rc_client_leaderboard_entry_t *entry_;
|
|
|
|
bool isCurrentUser_;
|
2023-06-19 21:47:23 +00:00
|
|
|
};
|