Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/RA_Integration.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>RC_CLIENT_SUPPORTS_HASH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir);$(RapidJSON_IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
Expand Down Expand Up @@ -83,7 +82,6 @@
<ClCompile Include="data\context\SessionTracker.cpp" />
<ClCompile Include="data\models\AchievementModel.cpp" />
<ClCompile Include="data\models\LeaderboardModel.cpp" />
<ClCompile Include="data\models\RichPresenceModel.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -217,7 +215,6 @@
<ClInclude Include="data\context\SessionTracker.hh" />
<ClInclude Include="data\models\AchievementModel.hh" />
<ClInclude Include="data\models\LeaderboardModel.hh" />
<ClInclude Include="data\models\RichPresenceModel.hh" />
<ClInclude Include="data\Types.hh" />
<ClInclude Include="Exports.hh" />
<ClInclude Include="pch.h" />
Expand Down
6 changes: 0 additions & 6 deletions src/RA_Integration.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@
<ClCompile Include="ui\win32\TriggerSummaryDialog.cpp">
<Filter>UI\Win32</Filter>
</ClCompile>
<ClCompile Include="data\models\RichPresenceModel.cpp">
<Filter>Data\Models</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RA_Resource.h">
Expand Down Expand Up @@ -980,9 +977,6 @@
<ClInclude Include="ui\win32\TriggerSummaryDialog.hh">
<Filter>UI\Win32</Filter>
</ClInclude>
<ClInclude Include="data\models\RichPresenceModel.hh">
<Filter>Data\Models</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="RA_Shared.rc">
Expand Down
1 change: 1 addition & 0 deletions src/base.props
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
<PreprocessorDefinitions>RC_CLIENT_SUPPORTS_HASH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ProgramDatabaseFile>$(OutDir)\$(TargetName).pdb</ProgramDatabaseFile>
Expand Down
9 changes: 0 additions & 9 deletions src/data/context/GameContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public:
/// </summary>
bool IsGameLoading() const noexcept { return m_nLoadCount != 0; }

/// <summary>
/// Gets the unique identifier of the currently loaded subset game.
/// </summary>
/// <remarks>
/// Will match <see cref="GameId"/> unless an exclusive or specialty subset is loaded.
/// </remarks>
unsigned int ActiveGameId() const noexcept { return m_nActiveGameId; }

/// <summary>
/// Gets the title of the currently loaded game.
/// </summary>
Expand Down Expand Up @@ -202,7 +194,6 @@ protected:
void BeginLoad();
void EndLoad();

unsigned int m_nActiveGameId = 0;
std::wstring m_sGameTitle;
std::string m_sGameHash;
Mode m_nMode{};
Expand Down
3 changes: 2 additions & 1 deletion src/devkit/RADevKit.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>RC_CLIENT_SUPPORTS_HASH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir);$(RapidJSON_IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<PreBuildEvent>
Expand All @@ -73,6 +72,7 @@
<ClCompile Include="data\models\MemoryNoteModel.cpp" />
<ClCompile Include="data\models\MemoryNotesModel.cpp" />
<ClCompile Include="data\models\MemoryRegionsModel.cpp" />
<ClCompile Include="data\models\RichPresenceModel.cpp" />
<ClCompile Include="data\models\TriggerValidation.cpp" />
<ClCompile Include="data\Value.cpp" />
<ClCompile Include="services\Http.cpp" />
Expand Down Expand Up @@ -104,6 +104,7 @@
<ClInclude Include="data\models\MemoryNoteModel.hh" />
<ClInclude Include="data\models\MemoryNotesModel.hh" />
<ClInclude Include="data\models\MemoryRegionsModel.hh" />
<ClInclude Include="data\models\RichPresenceModel.hh" />
<ClInclude Include="data\models\TriggerValidation.hh" />
<ClInclude Include="data\NotifyTargetSet.hh" />
<ClInclude Include="data\Value.hh" />
Expand Down
33 changes: 27 additions & 6 deletions src/devkit/RADevKit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<Filter Include="data\models">
<UniqueIdentifier>{0257fa92-4751-42dc-8c9b-2ea7110ed5b2}</UniqueIdentifier>
</Filter>
<Filter Include="ui">
<UniqueIdentifier>{3d6b142b-5f11-4326-a76e-1044b0d23859}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="services\ServiceLocator.hh">
Expand Down Expand Up @@ -177,10 +180,21 @@
<ClInclude Include="data\models\MemoryNotesModel.hh">
<Filter>data\models</Filter>
</ClInclude>
<ClInclude Include="ui\IImageRepository.hh" />
<ClInclude Include="ui\ImageReference.hh" />
<ClInclude Include="context\IGameContext.hh" />
<ClInclude Include="data\models\TriggerValidation.hh" />
<ClInclude Include="data\models\TriggerValidation.hh">
<Filter>data\models</Filter>
</ClInclude>
<ClInclude Include="ui\IImageRepository.hh">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="ui\ImageReference.hh">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="context\IGameContext.hh">
<Filter>context</Filter>
</ClInclude>
<ClInclude Include="data\models\RichPresenceModel.hh">
<Filter>data\models</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="util\GSL.cpp">
Expand Down Expand Up @@ -249,7 +263,14 @@
<ClCompile Include="data\models\MemoryNotesModel.cpp">
<Filter>data\models</Filter>
</ClCompile>
<ClCompile Include="ui\ImageReference.cpp" />
<ClCompile Include="data\models\TriggerValidation.cpp" />
<ClCompile Include="data\models\TriggerValidation.cpp">
<Filter>data\models</Filter>
</ClCompile>
<ClCompile Include="ui\ImageReference.cpp">
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="data\models\RichPresenceModel.cpp">
<Filter>data\models</Filter>
</ClCompile>
</ItemGroup>
</Project>
21 changes: 19 additions & 2 deletions src/devkit/context/IGameContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ public:
/// <summary>
/// Gets the unique identifier of the currently loaded game.
/// </summary>
unsigned int GameId() const noexcept { return m_nGameId; }
uint32_t GameId() const noexcept { return m_nGameId; }

/// <summary>
/// Gets the unique identifier of the base game for the currently loaded subset.
/// </summary>
/// <remarks>
/// Will match <see cref="GameId"/> unless an exclusive or specialty subset is loaded.
/// </remarks>
uint32_t ActiveGameId() const noexcept { return m_nActiveGameId; }

class NotifyTarget
{
Expand All @@ -53,11 +61,20 @@ public:
void AddNotifyTarget(NotifyTarget& pTarget) noexcept { m_vNotifyTargets.Add(pTarget); }
void RemoveNotifyTarget(NotifyTarget& pTarget) noexcept { m_vNotifyTargets.Remove(pTarget); }

/// <summary>
/// Gets the <see cref="MemoryNote"/>s for the currently loaded game.
/// </summary>
virtual ra::data::models::MemoryNotesModel& MemoryNotes() noexcept(false) = 0;

/// <summary>
/// Gets the <see cref="MemoryNote"/>s for the currently loaded game.
/// </summary>
virtual const ra::data::models::MemoryNotesModel& MemoryNotes() const noexcept(false) = 0;

protected:
unsigned int m_nGameId = 0;
uint32_t m_nGameId = 0;
uint32_t m_nActiveGameId = 0;

ra::data::NotifyTargetSet<NotifyTarget> m_vNotifyTargets;
};

Expand Down
8 changes: 8 additions & 0 deletions src/devkit/context/IRcClient.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public:
/// </summary>
static const std::wstring GetErrorMessage(int nResult, const rc_api_response_t& pResponse);

/// <summary>
/// Gets whether or not hardcore is enabled.
/// </summary>
bool IsHardcodeEnabled() const noexcept
{
return rc_client_get_hardcore_enabled(GetClient());
}

protected:
IRcClient() noexcept = default;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#include "RichPresenceModel.hh"

#include "context\IRcClient.hh"
#include "context/IGameContext.hh"
#include "context/IRcClient.hh"

#include "data\context\GameContext.hh"
#include "services/ILocalStorage.hh"
#include "services/ServiceLocator.hh"

#include "services\IConfiguration.hh"
#include "services\ILocalStorage.hh"
#include "services\ServiceLocator.hh"
#include "util/Strings.hh"

#include "util\Strings.hh"

#include <rcheevos\src\rcheevos\rc_internal.h>
#include <rcheevos\src\rc_client_internal.h>
#include <rcheevos/src/rcheevos/rc_internal.h>
#include <rcheevos/src/rc_client_internal.h>

namespace ra {
namespace data {
Expand Down Expand Up @@ -152,13 +150,11 @@ void RichPresenceModel::SetScript(const std::string& sScript)
sNormalizedScript.push_back('\n');

SetAssetDefinition(m_pScript, sNormalizedScript);

// TODO: parse and load into runtime
}

void RichPresenceModel::ReloadRichPresenceScript()
{
const auto& pGameContext = ra::services::ServiceLocator::Get<ra::data::context::GameContext>();
const auto& pGameContext = ra::services::ServiceLocator::Get<ra::context::IGameContext>();
auto& pLocalStorage = ra::services::ServiceLocator::GetMutable<ra::services::ILocalStorage>();
auto pRich = pLocalStorage.ReadText(ra::services::StorageItemType::RichPresence, std::to_wstring(pGameContext.ActiveGameId()));

Expand Down Expand Up @@ -200,7 +196,7 @@ void RichPresenceModel::ReloadRichPresenceScript()
}

if (GetChanges() != ra::data::models::AssetChanges::None && IsActive() &&
ra::services::ServiceLocator::Get<ra::services::IConfiguration>().IsFeatureEnabled(ra::services::Feature::Hardcore))
ra::services::ServiceLocator::Get<ra::context::IRcClient>().IsHardcodeEnabled())
{
// ignore modified rich presence in hardcore
Deactivate();
Expand All @@ -211,7 +207,7 @@ void RichPresenceModel::ReloadRichPresenceScript()

void RichPresenceModel::WriteRichPresenceScript()
{
const auto& pGameContext = ra::services::ServiceLocator::Get<ra::data::context::GameContext>();
const auto& pGameContext = ra::services::ServiceLocator::Get<ra::context::IGameContext>();
auto& pLocalStorage = ra::services::ServiceLocator::GetMutable<ra::services::ILocalStorage>();

auto pWriter = pLocalStorage.WriteText(ra::services::StorageItemType::RichPresence,
Expand All @@ -236,11 +232,14 @@ void RichPresenceModel::SyncScriptToRuntime()

void RichPresenceModel::DetachRuntimeLeaderboard(struct rc_client_game_info_t* pGame) noexcept
{
if (pGame)
pGame->runtime.richpresence = nullptr;

if (m_pRichPresenceInfo)
{
free(m_pRichPresenceInfo);

if (pGame)
pGame->runtime.richpresence = m_pRichPresenceInfo = nullptr;
m_pRichPresenceInfo = nullptr;
}

m_pDefinitionBuffer.reset();
}
Expand All @@ -260,7 +259,7 @@ void RichPresenceModel::ParseScript()

if (!pGame || sScript.empty())
{
// empty script - clear out previous one
// empty script or no game loaded - clear out previous one
DetachRuntimeLeaderboard(pGame);

rc_mutex_unlock(&pClient->state.mutex);
Expand Down Expand Up @@ -380,7 +379,7 @@ struct rc_richpresence_t* RichPresenceModel::GetMutableRuntimeDefinition()
return nullptr;
}

std::wstring RichPresenceModel::GetMessage() const
std::wstring RichPresenceModel::GetDisplayMessage() const
{
if (!m_sParseError.empty())
return m_sParseError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RA_DATA_RICHPRESENCE_MODEL_H
#define RA_DATA_RICHPRESENCE_MODEL_H
#ifndef RA_DATA_MODELS_RICHPRESENCE_MODEL_H
#define RA_DATA_MODELS_RICHPRESENCE_MODEL_H
#pragma once

#include "data/models/AssetModelBase.hh"
Expand Down Expand Up @@ -35,10 +35,18 @@ public:
/// <summary>
/// Gets the current evaluation of the rich presence script.
/// </summary>
std::wstring GetMessage() const;
std::wstring GetDisplayMessage() const;

/// <summary>
/// Initializes from a published script.
/// </summary>
/// <param name="pDefinition">Pre-parsed script already loaded in the runtime.</param>
/// <param name="sScript">Unparsed script. Ignored unless <paramref name="pDefinition"/> is <c>nullptr</c>.</param>
void InitializeFromPublishedScript(const rc_runtime_richpresence_t* pDefinition, const std::string& sScript);

/// <summary>
/// Revert to file state (if available) or server state if not.
/// </summary>
void ReloadRichPresenceScript();

void Activate() override;
Expand Down
1 change: 0 additions & 1 deletion src/rcheevos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>RC_CLIENT_SUPPORTS_HASH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)rcheevos\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/viewmodels/RichPresenceMonitorViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void RichPresenceMonitorViewModel::UpdateDisplayString()
break;

case ra::data::models::AssetState::Active:
SetDisplayString(pRichPresence->GetMessage());
SetDisplayString(pRichPresence->GetDisplayMessage());
break;

default:
Expand Down
4 changes: 1 addition & 3 deletions tests/RA_Integration.Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>RC_CLIENT_SUPPORTS_HASH;RA_UTEST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>RA_UTEST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir);$(RapidJSON_IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
Expand Down Expand Up @@ -84,7 +84,6 @@
<ClCompile Include="..\src\data\context\SessionTracker.cpp" />
<ClCompile Include="..\src\data\models\AchievementModel.cpp" />
<ClCompile Include="..\src\data\models\LeaderboardModel.cpp" />
<ClCompile Include="..\src\data\models\RichPresenceModel.cpp" />
<ClCompile Include="..\src\pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -158,7 +157,6 @@
<ClCompile Include="data\context\SessionTracker_Tests.cpp" />
<ClCompile Include="data\models\AchievementModel_Tests.cpp" />
<ClCompile Include="data\models\LeaderboardModel_Tests.cpp" />
<ClCompile Include="data\models\RichPresenceModel_Tests.cpp" />
<ClCompile Include="devkit\context\mocks\MockEmulatorMemoryContext.cpp" />
<ClCompile Include="devkit\context\mocks\MockRcClient.cpp" />
<ClCompile Include="Exports_Tests.cpp" />
Expand Down
6 changes: 0 additions & 6 deletions tests/RA_Integration.Tests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,6 @@
<ClCompile Include="..\src\ui\viewmodels\NewAssetViewModel.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="..\src\data\models\RichPresenceModel.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="data\models\RichPresenceModel_Tests.cpp">
<Filter>Tests\Data\Models</Filter>
</ClCompile>
<ClCompile Include="..\src\ui\viewmodels\EmulatorViewModel.cpp">
<Filter>Code</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions tests/devkit/RADevKit.Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<ClCompile Include="data\ModelProperty_Tests.cpp" />
<ClCompile Include="data\models\LocalBadgesModel_Tests.cpp" />
<ClCompile Include="data\models\MemoryNotesModel_Tests.cpp" />
<ClCompile Include="data\models\RichPresenceModel_Tests.cpp" />
<ClCompile Include="data\models\TriggerValidation_Tests.cpp" />
<ClCompile Include="util\Tokenizer_Tests.cpp" />
<ClInclude Include="context\mocks\MockConsoleContext.hh" />
Expand Down
Loading
Loading