mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 10:35:46 -04:00
Cheevos: Move to core
This commit is contained in:
@ -108,15 +108,6 @@ if(ENABLE_DISCORD_PRESENCE)
|
||||
target_link_libraries(frontend-common PRIVATE discord-rpc)
|
||||
endif()
|
||||
|
||||
if(ENABLE_CHEEVOS)
|
||||
target_sources(frontend-common PRIVATE
|
||||
cheevos.cpp
|
||||
cheevos.h
|
||||
)
|
||||
target_compile_definitions(frontend-common PUBLIC -DWITH_CHEEVOS=1)
|
||||
target_link_libraries(frontend-common PRIVATE rcheevos rapidjson)
|
||||
endif()
|
||||
|
||||
# Copy the provided data directory to the output directory.
|
||||
add_custom_command(TARGET frontend-common POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,123 +0,0 @@
|
||||
#pragma once
|
||||
#include "common/string.h"
|
||||
#include "core/types.h"
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class CDImage;
|
||||
|
||||
namespace Cheevos {
|
||||
|
||||
enum class AchievementCategory : u32
|
||||
{
|
||||
Local = 0,
|
||||
Core = 3,
|
||||
Unofficial = 5
|
||||
};
|
||||
|
||||
struct Achievement
|
||||
{
|
||||
u32 id;
|
||||
std::string title;
|
||||
std::string description;
|
||||
std::string memaddr;
|
||||
std::string locked_badge_path;
|
||||
std::string unlocked_badge_path;
|
||||
u32 points;
|
||||
AchievementCategory category;
|
||||
bool locked;
|
||||
bool active;
|
||||
};
|
||||
|
||||
struct Leaderboard
|
||||
{
|
||||
u32 id;
|
||||
std::string title;
|
||||
std::string description;
|
||||
int format;
|
||||
};
|
||||
|
||||
struct LeaderboardEntry
|
||||
{
|
||||
std::string user;
|
||||
std::string formatted_score;
|
||||
u32 rank;
|
||||
bool is_self;
|
||||
};
|
||||
|
||||
extern bool g_active;
|
||||
extern bool g_challenge_mode;
|
||||
extern u32 g_game_id;
|
||||
|
||||
ALWAYS_INLINE bool IsActive()
|
||||
{
|
||||
return g_active;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool IsChallengeModeEnabled()
|
||||
{
|
||||
return g_challenge_mode;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool IsChallengeModeActive()
|
||||
{
|
||||
return g_active && g_challenge_mode;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool HasActiveGame()
|
||||
{
|
||||
return g_game_id != 0;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u32 GetGameID()
|
||||
{
|
||||
return g_game_id;
|
||||
}
|
||||
|
||||
bool Initialize(bool test_mode, bool use_first_disc_from_playlist, bool enable_rich_presence, bool challenge_mode,
|
||||
bool include_unofficial);
|
||||
void Reset();
|
||||
void Shutdown();
|
||||
void Update();
|
||||
|
||||
bool IsLoggedIn();
|
||||
bool IsTestModeActive();
|
||||
bool IsUnofficialTestModeActive();
|
||||
bool IsUsingFirstDiscFromPlaylist();
|
||||
bool IsRichPresenceEnabled();
|
||||
const std::string& GetUsername();
|
||||
const std::string& GetRichPresenceString();
|
||||
|
||||
bool LoginAsync(const char* username, const char* password);
|
||||
bool Login(const char* username, const char* password);
|
||||
void Logout();
|
||||
|
||||
bool HasActiveGame();
|
||||
void GameChanged(const std::string& path, CDImage* image);
|
||||
|
||||
const std::string& GetGameTitle();
|
||||
const std::string& GetGameDeveloper();
|
||||
const std::string& GetGamePublisher();
|
||||
const std::string& GetGameReleaseDate();
|
||||
const std::string& GetGameIcon();
|
||||
|
||||
bool EnumerateAchievements(std::function<bool(const Achievement&)> callback);
|
||||
u32 GetUnlockedAchiementCount();
|
||||
u32 GetAchievementCount();
|
||||
u32 GetMaximumPointsForGame();
|
||||
u32 GetCurrentPointsForGame();
|
||||
|
||||
bool EnumerateLeaderboards(std::function<bool(const Leaderboard&)> callback);
|
||||
std::optional<bool> TryEnumerateLeaderboardEntries(u32 id, std::function<bool(const LeaderboardEntry&)> callback);
|
||||
const Leaderboard* GetLeaderboardByID(u32 id);
|
||||
u32 GetLeaderboardCount();
|
||||
bool IsLeaderboardTimeType(const Leaderboard& leaderboard);
|
||||
|
||||
std::pair<u32, u32> GetAchievementProgress(const Achievement& achievement);
|
||||
TinyString GetAchievementProgressText(const Achievement& achievement);
|
||||
|
||||
void UnlockAchievement(u32 achievement_id, bool add_notification = true);
|
||||
void SubmitLeaderboard(u32 leaderboard_id, int value);
|
||||
|
||||
} // namespace Cheevos
|
@ -52,7 +52,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CHEEVOS
|
||||
#include "cheevos.h"
|
||||
#include "core/cheevos.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -500,9 +500,7 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[],
|
||||
|
||||
void CommonHostInterface::OnAchievementsRefreshed()
|
||||
{
|
||||
#ifdef WITH_CHEEVOS
|
||||
// noop
|
||||
#endif
|
||||
}
|
||||
|
||||
void CommonHostInterface::PollAndUpdate()
|
||||
@ -3543,6 +3541,16 @@ std::vector<std::string> CommonHostInterface::GetSettingStringList(const char* s
|
||||
return m_settings_interface->GetStringList(section, key);
|
||||
}
|
||||
|
||||
SettingsInterface* CommonHostInterface::GetSettingsInterface()
|
||||
{
|
||||
return m_settings_interface.get();
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> CommonHostInterface::GetSettingsLock()
|
||||
{
|
||||
return std::lock_guard<std::recursive_mutex>(m_settings_mutex);
|
||||
}
|
||||
|
||||
void CommonHostInterface::SetTimerResolutionIncreased(bool enabled)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(_UWP)
|
||||
|
@ -134,11 +134,8 @@ public:
|
||||
virtual void DestroySystem() override;
|
||||
|
||||
/// Returns the settings interface.
|
||||
ALWAYS_INLINE SettingsInterface* GetSettingsInterface() const { return m_settings_interface.get(); }
|
||||
ALWAYS_INLINE std::lock_guard<std::recursive_mutex> GetSettingsLock()
|
||||
{
|
||||
return std::lock_guard<std::recursive_mutex>(m_settings_mutex);
|
||||
}
|
||||
SettingsInterface* GetSettingsInterface() override;
|
||||
std::lock_guard<std::recursive_mutex> GetSettingsLock() override;
|
||||
|
||||
/// Returns the game list.
|
||||
ALWAYS_INLINE GameList* GetGameList() const { return m_game_list.get(); }
|
||||
@ -312,7 +309,7 @@ public:
|
||||
virtual void* GetTopLevelWindowHandle() const;
|
||||
|
||||
/// Called when achievements data is loaded.
|
||||
virtual void OnAchievementsRefreshed();
|
||||
virtual void OnAchievementsRefreshed() override;
|
||||
|
||||
/// Opens a file in the DuckStation "package".
|
||||
/// This is the APK for Android builds, or the program directory for standalone builds.
|
||||
|
@ -4,11 +4,10 @@
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WITH_CHEEVOS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)dep\rcheevos\include;$(SolutionDir)dep\rapidjson\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(RootBuildDir)rcheevos\rcheevos.lib;$(RootBuildDir)simpleini\simpleini.lib;$(RootBuildDir)tinyxml2\tinyxml2.lib;$(RootBuildDir)core\core.lib;$(RootBuildDir)scmversion\scmversion.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(RootBuildDir)simpleini\simpleini.lib;$(RootBuildDir)tinyxml2\tinyxml2.lib;$(RootBuildDir)core\core.lib;$(RootBuildDir)scmversion\scmversion.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
<ClCompile Include="postprocessing_chain.cpp" />
|
||||
<ClCompile Include="postprocessing_shader.cpp" />
|
||||
<ClCompile Include="postprocessing_shadergen.cpp" />
|
||||
<ClCompile Include="cheevos.cpp" />
|
||||
<ClCompile Include="save_state_selector_ui.cpp" />
|
||||
<ClCompile Include="sdl_audio_stream.cpp">
|
||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
@ -72,7 +71,6 @@
|
||||
<ClInclude Include="postprocessing_chain.h" />
|
||||
<ClInclude Include="postprocessing_shader.h" />
|
||||
<ClInclude Include="postprocessing_shadergen.h" />
|
||||
<ClInclude Include="cheevos.h" />
|
||||
<ClInclude Include="save_state_selector_ui.h" />
|
||||
<ClInclude Include="sdl_audio_stream.h">
|
||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
|
@ -25,7 +25,6 @@
|
||||
<ClCompile Include="dinput_controller_interface.cpp" />
|
||||
<ClCompile Include="fullscreen_ui.cpp" />
|
||||
<ClCompile Include="fullscreen_ui_progress_callback.cpp" />
|
||||
<ClCompile Include="cheevos.cpp" />
|
||||
<ClCompile Include="input_overlay_ui.cpp" />
|
||||
<ClCompile Include="game_database.cpp" />
|
||||
<ClCompile Include="inhibit_screensaver.cpp" />
|
||||
@ -58,7 +57,6 @@
|
||||
<ClInclude Include="dinput_controller_interface.h" />
|
||||
<ClInclude Include="fullscreen_ui.h" />
|
||||
<ClInclude Include="fullscreen_ui_progress_callback.h" />
|
||||
<ClInclude Include="cheevos.h" />
|
||||
<ClInclude Include="input_overlay_ui.h" />
|
||||
<ClInclude Include="game_database.h" />
|
||||
<ClInclude Include="inhibit_screensaver.h" />
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
#include "fullscreen_ui.h"
|
||||
#include "IconsFontAwesome5.h"
|
||||
#include "cheevos.h"
|
||||
#include "common/byte_stream.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include "common/lru_cache.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/string.h"
|
||||
#include "common/string_util.h"
|
||||
@ -33,6 +31,10 @@
|
||||
#include <thread>
|
||||
Log_SetChannel(FullscreenUI);
|
||||
|
||||
#ifdef WITH_CHEEVOS
|
||||
#include "core/cheevos.h"
|
||||
#endif
|
||||
|
||||
static constexpr float LAYOUT_MAIN_MENU_BAR_SIZE = 20.0f; // Should be DPI scaled, not layout scaled!
|
||||
|
||||
using ImGuiFullscreen::g_large_font;
|
||||
@ -64,6 +66,7 @@ using ImGuiFullscreen::EndMenuButtons;
|
||||
using ImGuiFullscreen::EndNavBar;
|
||||
using ImGuiFullscreen::EnumChoiceButton;
|
||||
using ImGuiFullscreen::FloatingButton;
|
||||
using ImGuiFullscreen::GetCachedTexture;
|
||||
using ImGuiFullscreen::LayoutScale;
|
||||
using ImGuiFullscreen::MenuButton;
|
||||
using ImGuiFullscreen::MenuButtonFrame;
|
||||
@ -123,8 +126,7 @@ static std::optional<u32> s_open_leaderboard_id;
|
||||
static bool LoadResources();
|
||||
static void DestroyResources();
|
||||
|
||||
static HostDisplayTexture* GetCachedTexture(const std::string& name);
|
||||
static ImTextureID ResolveTextureHandle(const std::string& name);
|
||||
static std::unique_ptr<HostDisplayTexture> LoadTextureCallback(const char* path);
|
||||
|
||||
static std::unique_ptr<HostDisplayTexture> s_app_icon_texture;
|
||||
static std::unique_ptr<HostDisplayTexture> s_placeholder_texture;
|
||||
@ -135,7 +137,6 @@ static std::unique_ptr<HostDisplayTexture> s_fallback_disc_texture;
|
||||
static std::unique_ptr<HostDisplayTexture> s_fallback_exe_texture;
|
||||
static std::unique_ptr<HostDisplayTexture> s_fallback_psf_texture;
|
||||
static std::unique_ptr<HostDisplayTexture> s_fallback_playlist_texture;
|
||||
static LRUCache<std::string, std::unique_ptr<HostDisplayTexture>> s_texture_cache;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Settings
|
||||
@ -215,9 +216,11 @@ static std::thread s_game_list_load_thread;
|
||||
bool Initialize(CommonHostInterface* host_interface)
|
||||
{
|
||||
s_host_interface = host_interface;
|
||||
s_texture_cache.SetMaxCapacity(128);
|
||||
if (!LoadResources())
|
||||
if (!ImGuiFullscreen::Initialize() || !LoadResources())
|
||||
{
|
||||
ImGuiFullscreen::Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
s_settings_copy.Load(*s_host_interface->GetSettingsInterface());
|
||||
LoadSettings();
|
||||
@ -225,7 +228,7 @@ bool Initialize(CommonHostInterface* host_interface)
|
||||
|
||||
ImGuiFullscreen::UpdateLayoutScale();
|
||||
ImGuiFullscreen::UpdateFonts();
|
||||
ImGuiFullscreen::SetResolveTextureFunction(ResolveTextureHandle);
|
||||
ImGuiFullscreen::SetLoadTextureFunction(LoadTextureCallback);
|
||||
|
||||
if (System::IsValid())
|
||||
SystemCreated();
|
||||
@ -337,6 +340,7 @@ void Shutdown()
|
||||
s_cover_image_map.clear();
|
||||
s_nav_input_values = {};
|
||||
DestroyResources();
|
||||
ImGuiFullscreen::Shutdown();
|
||||
|
||||
s_host_interface = nullptr;
|
||||
}
|
||||
@ -460,7 +464,6 @@ bool LoadResources()
|
||||
|
||||
void DestroyResources()
|
||||
{
|
||||
s_texture_cache.Clear();
|
||||
s_app_icon_texture.reset();
|
||||
s_placeholder_texture.reset();
|
||||
s_fallback_playlist_texture.reset();
|
||||
@ -506,6 +509,11 @@ static std::unique_ptr<HostDisplayTexture> LoadTexture(const char* path, bool fr
|
||||
return texture;
|
||||
}
|
||||
|
||||
std::unique_ptr<HostDisplayTexture> LoadTextureCallback(const char* path)
|
||||
{
|
||||
return LoadTexture(path, false);
|
||||
}
|
||||
|
||||
std::unique_ptr<HostDisplayTexture> LoadTextureResource(const char* name, bool allow_fallback /*= true*/)
|
||||
{
|
||||
const std::string path(StringUtil::StdStringFromFormat("resources" FS_OSPATH_SEPARATOR_STR "%s", name));
|
||||
@ -527,29 +535,6 @@ std::unique_ptr<HostDisplayTexture> LoadTextureResource(const char* name, bool a
|
||||
return texture;
|
||||
}
|
||||
|
||||
HostDisplayTexture* GetCachedTexture(const std::string& name)
|
||||
{
|
||||
std::unique_ptr<HostDisplayTexture>* tex_ptr = s_texture_cache.Lookup(name);
|
||||
if (!tex_ptr)
|
||||
{
|
||||
std::unique_ptr<HostDisplayTexture> tex = LoadTexture(name.c_str(), false);
|
||||
tex_ptr = s_texture_cache.Insert(name, std::move(tex));
|
||||
}
|
||||
|
||||
return tex_ptr->get();
|
||||
}
|
||||
|
||||
ImTextureID ResolveTextureHandle(const std::string& name)
|
||||
{
|
||||
HostDisplayTexture* tex = GetCachedTexture(name);
|
||||
return tex ? tex->GetHandle() : nullptr;
|
||||
}
|
||||
|
||||
bool InvalidateCachedTexture(const std::string& path)
|
||||
{
|
||||
return s_texture_cache.Remove(path);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -63,7 +63,6 @@ bool IsBindingInput();
|
||||
bool HandleKeyboardBinding(const char* keyName, bool pressed);
|
||||
|
||||
std::unique_ptr<HostDisplayTexture> LoadTextureResource(const char* name, bool allow_fallback = true);
|
||||
bool InvalidateCachedTexture(const std::string& path);
|
||||
|
||||
// Returns true if the message has been dismissed.
|
||||
bool DrawErrorWindow(const char* message);
|
||||
|
Reference in New Issue
Block a user