forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RetroAchievementScreens.h
144 lines (109 loc) · 4.77 KB
/
RetroAchievementScreens.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#pragma once
#include <cstdint>
#include "Common/File/Path.h"
#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"
#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; }
private:
void CreateAchievementsTab(UI::ViewGroup *viewGroup);
void CreateLeaderboardsTab(UI::ViewGroup *viewGroup);
void CreateStatisticsTab(UI::ViewGroup *viewGroup);
};
// Lets you manage your account, and shows some achievement stats and stuff.
class RetroAchievementsSettingsScreen : public TabbedUIDialogScreenWithGameBackground {
public:
RetroAchievementsSettingsScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
~RetroAchievementsSettingsScreen();
const char *tag() const override { return "RetroAchievementsSettingsScreen"; }
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_;
};
class RetroAchievementsLeaderboardScreen : public TabbedUIDialogScreenWithGameBackground {
public:
RetroAchievementsLeaderboardScreen(const Path &gamePath, int leaderboardID);
~RetroAchievementsLeaderboardScreen();
const char *tag() const override { return "RetroAchievementsLeaderboardScreen"; }
void CreateTabs() override;
void update() override;
protected:
bool ShowSearchControls() const override { return false; }
private:
void FetchEntries();
void Poll();
int leaderboardID_;
bool nearMe_ = false;
// 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;
};
class UIContext;
enum class AchievementRenderStyle {
LISTED,
UNLOCKED,
PROGRESS_INDICATOR,
CHALLENGE_INDICATOR,
};
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);
class AchievementView : public UI::ClickableItem {
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.
}
void Click() override;
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
private:
const rc_client_achievement_t *achievement_;
};
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;
};
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.
}
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
private:
const rc_client_leaderboard_t *leaderboard_;
};
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_;
};