Skip to content
Merged
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
4 changes: 0 additions & 4 deletions src/RA_Integration.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
<ClCompile Include="data\context\EmulatorContext.cpp" />
<ClCompile Include="data\context\GameContext.cpp" />
<ClCompile Include="data\context\SessionTracker.cpp" />
<ClCompile Include="data\models\AchievementModel.cpp" />
<ClCompile Include="data\models\LeaderboardModel.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -213,8 +211,6 @@
<ClInclude Include="data\context\GameAssets.hh" />
<ClInclude Include="data\context\GameContext.hh" />
<ClInclude Include="data\context\SessionTracker.hh" />
<ClInclude Include="data\models\AchievementModel.hh" />
<ClInclude Include="data\models\LeaderboardModel.hh" />
<ClInclude Include="data\Types.hh" />
<ClInclude Include="Exports.hh" />
<ClInclude Include="pch.h" />
Expand Down
15 changes: 0 additions & 15 deletions src/RA_Integration.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<Filter Include="Data\Context">
<UniqueIdentifier>{d29ae560-83b6-496b-b1ba-bc0b0c5978af}</UniqueIdentifier>
</Filter>
<Filter Include="Data\Models">
<UniqueIdentifier>{c9c038f9-c4bb-436c-8416-12f91df44904}</UniqueIdentifier>
</Filter>
<Filter Include="Services\Search">
<UniqueIdentifier>{e978c08c-fedb-4ead-af63-0420b26291bb}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -315,9 +312,6 @@
<ClCompile Include="data\context\SessionTracker.cpp">
<Filter>Data\Context</Filter>
</ClCompile>
<ClCompile Include="data\models\AchievementModel.cpp">
<Filter>Data\Models</Filter>
</ClCompile>
<ClCompile Include="data\context\GameAssets.cpp">
<Filter>Data\Context</Filter>
</ClCompile>
Expand All @@ -333,9 +327,6 @@
<ClCompile Include="ui\viewmodels\ChallengeIndicatorViewModel.cpp">
<Filter>UI\ViewModels</Filter>
</ClCompile>
<ClCompile Include="data\models\LeaderboardModel.cpp">
<Filter>Data\Models</Filter>
</ClCompile>
<ClCompile Include="ui\viewmodels\IntegrationMenuViewModel.cpp">
<Filter>UI\ViewModels</Filter>
</ClCompile>
Expand Down Expand Up @@ -806,9 +797,6 @@
<ClInclude Include="data\context\SessionTracker.hh">
<Filter>Data\Context</Filter>
</ClInclude>
<ClInclude Include="data\models\AchievementModel.hh">
<Filter>Data\Models</Filter>
</ClInclude>
<ClInclude Include="data\context\GameAssets.hh">
<Filter>Data\Context</Filter>
</ClInclude>
Expand All @@ -830,9 +818,6 @@
<ClInclude Include="ui\viewmodels\ChallengeIndicatorViewModel.hh">
<Filter>UI\ViewModels</Filter>
</ClInclude>
<ClInclude Include="data\models\LeaderboardModel.hh">
<Filter>Data\Models</Filter>
</ClInclude>
<ClInclude Include="ui\viewmodels\IntegrationMenuViewModel.hh">
<Filter>UI\ViewModels</Filter>
</ClInclude>
Expand Down
14 changes: 14 additions & 0 deletions src/data/context/GameContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "context/IGameContext.hh"

#include "data/models/LocalBadgesModel.hh"

#include "services/ServiceLocator.hh"

#include "GameAssets.hh"
Expand Down Expand Up @@ -178,6 +180,17 @@ public:
return pNotes ? *pNotes : m_oDefaultNotes;
}

ra::data::models::LocalBadgesModel& LocalBadges() override
{
auto* pLocalBadges = dynamic_cast<ra::data::models::LocalBadgesModel*>(m_vAssets.FindAsset(ra::data::models::AssetType::LocalBadges, 0));
return pLocalBadges ? *pLocalBadges : m_oDefaultLocalBadges;
}
const ra::data::models::LocalBadgesModel& LocalBadges() const override
{
auto* pLocalBadges = dynamic_cast<const ra::data::models::LocalBadgesModel*>(m_vAssets.FindAsset(ra::data::models::AssetType::LocalBadges, 0));
return pLocalBadges ? *pLocalBadges : m_oDefaultLocalBadges;
}

private:
void FinishLoadGame(int nResult, const char* sErrorMessage, bool bWasPaused);
void MigrateSubsetUserFiles();
Expand Down Expand Up @@ -211,6 +224,7 @@ private:
// use the mock helper to register as both GameContext and IGameContext
ra::services::ServiceLocator::ServiceOverride<ra::context::IGameContext> m_IGameContextOverride;
ra::data::models::MemoryNotesModel m_oDefaultNotes;
ra::data::models::LocalBadgesModel m_oDefaultLocalBadges;
};

} // namespace context
Expand Down
4 changes: 4 additions & 0 deletions src/devkit/RADevKit.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
<ClCompile Include="data\ModelCollectionBase.cpp" />
<ClCompile Include="data\ModelProperty.cpp" />
<ClCompile Include="data\ModelPropertyContainer.cpp" />
<ClCompile Include="data\models\AchievementModel.cpp" />
<ClCompile Include="data\models\AssetModelBase.cpp" />
<ClCompile Include="data\models\LeaderboardModel.cpp" />
<ClCompile Include="data\models\LocalBadgesModel.cpp" />
<ClCompile Include="data\models\MemoryNoteModel.cpp" />
<ClCompile Include="data\models\MemoryNotesModel.cpp" />
Expand Down Expand Up @@ -99,7 +101,9 @@
<ClInclude Include="data\ModelCollectionBase.hh" />
<ClInclude Include="data\ModelProperty.hh" />
<ClInclude Include="data\ModelPropertyContainer.hh" />
<ClInclude Include="data\models\AchievementModel.hh" />
<ClInclude Include="data\models\AssetModelBase.hh" />
<ClInclude Include="data\models\LeaderboardModel.hh" />
<ClInclude Include="data\models\LocalBadgesModel.hh" />
<ClInclude Include="data\models\MemoryNoteModel.hh" />
<ClInclude Include="data\models\MemoryNotesModel.hh" />
Expand Down
12 changes: 12 additions & 0 deletions src/devkit/RADevKit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@
<ClInclude Include="data\models\RichPresenceModel.hh">
<Filter>data\models</Filter>
</ClInclude>
<ClInclude Include="data\models\AchievementModel.hh">
<Filter>data\models</Filter>
</ClInclude>
<ClInclude Include="data\models\LeaderboardModel.hh">
<Filter>data\models</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="util\GSL.cpp">
Expand Down Expand Up @@ -272,5 +278,11 @@
<ClCompile Include="data\models\RichPresenceModel.cpp">
<Filter>data\models</Filter>
</ClCompile>
<ClCompile Include="data\models\AchievementModel.cpp">
<Filter>data\models</Filter>
</ClCompile>
<ClCompile Include="data\models\LeaderboardModel.cpp">
<Filter>data\models</Filter>
</ClCompile>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions src/devkit/context/IGameContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace ra {
namespace data {
namespace models {
class MemoryNotesModel;
class LocalBadgesModel;
} // namespace models
} // namespace data

Expand Down Expand Up @@ -71,6 +72,16 @@ public:
/// </summary>
virtual const ra::data::models::MemoryNotesModel& MemoryNotes() const noexcept(false) = 0;

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

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

protected:
uint32_t m_nGameId = 0;
uint32_t m_nActiveGameId = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#include "AchievementModel.hh"

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

#include "util\Log.hh"
#include "data/context/GameAssets.hh" // TODO: this is a reference outside of the devkit code for FirstLocalID

#include "data\context\GameContext.hh"
#include "util/Log.hh"

#include "data\models\LocalBadgesModel.hh"
#include "data\models\TriggerValidation.hh"
#include "data/models/LocalBadgesModel.hh"
#include "data/models/TriggerValidation.hh"

#include "services\ServiceLocator.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 @@ -109,24 +110,16 @@ void AchievementModel::OnValueChanged(const StringModelProperty::ChangeArgs& arg
{
if (ra::util::String::StartsWith(args.tOldValue, L"local\\"))
{
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::data::context::GameContext>();
auto* pLocalBadges = dynamic_cast<LocalBadgesModel*>(pGameContext.Assets().FindAsset(ra::data::models::AssetType::LocalBadges, 0));
if (pLocalBadges)
{
const bool bCommitted = (GetLocalValue(BadgeProperty) == args.tOldValue);
pLocalBadges->RemoveReference(args.tOldValue, bCommitted);
}
const bool bCommitted = (GetLocalValue(BadgeProperty) == args.tOldValue);
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::context::IGameContext>();
pGameContext.LocalBadges().RemoveReference(args.tOldValue, bCommitted);
}

if (ra::util::String::StartsWith(args.tNewValue, L"local\\"))
{
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::data::context::GameContext>();
auto* pLocalBadges = dynamic_cast<LocalBadgesModel*>(pGameContext.Assets().FindAsset(ra::data::models::AssetType::LocalBadges, 0));
if (pLocalBadges)
{
const bool bCommitted = (GetLocalValue(BadgeProperty) == args.tNewValue);
pLocalBadges->AddReference(args.tNewValue, bCommitted);
}
const bool bCommitted = (GetLocalValue(BadgeProperty) == args.tNewValue);
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::context::IGameContext>();
pGameContext.LocalBadges().AddReference(args.tNewValue, bCommitted);
}

if (m_pAchievementInfo)
Expand All @@ -143,10 +136,8 @@ void AchievementModel::CommitTransaction()
const auto& pBadgeName = GetBadge();
if (*pPreviousBadgeName != pBadgeName)
{
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::data::context::GameContext>();
auto* pLocalBadges = dynamic_cast<LocalBadgesModel*>(pGameContext.Assets().FindAsset(ra::data::models::AssetType::LocalBadges, 0));
if (pLocalBadges)
pLocalBadges->Commit(*pPreviousBadgeName, pBadgeName);
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::context::IGameContext>();
pGameContext.LocalBadges().Commit(*pPreviousBadgeName, pBadgeName);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RA_DATA_ACHIEVEMENT_MODEL_H
#define RA_DATA_ACHIEVEMENT_MODEL_H
#ifndef RA_DATA_MODELS_ACHIEVEMENTMODEL_H
#define RA_DATA_MODELS_ACHIEVEMENTMODEL_H
#pragma once

#include "data/models/AssetModelBase.hh"
Expand Down Expand Up @@ -237,4 +237,4 @@ private:
} // namespace data
} // namespace ra

#endif RA_DATA_ACHIEVEMENT_MODEL_H
#endif RA_DATA_MODELS_ACHIEVEMENTMODEL_H
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "LeaderboardModel.hh"

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

#include "data\models\TriggerValidation.hh"
#include "data/models/TriggerValidation.hh"

#include "services\ServiceLocator.hh"
#include "services/ServiceLocator.hh"

#include "util\Strings.hh"
#include "util/Strings.hh"

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

namespace ra {
namespace data {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RA_DATA_LEADERBOARD_MODEL_H
#define RA_DATA_LEADERBOARD_MODEL_H
#ifndef RA_DATA_MODELS_LEADERBOARDMODEL_H
#define RA_DATA_MODELS_LEADERBOARDMODEL_H
#pragma once

#include "data/models/AssetModelBase.hh"
Expand Down Expand Up @@ -260,4 +260,4 @@ private:
} // namespace data
} // namespace ra

#endif RA_DATA_LEADERBOARD_MODEL_H
#endif RA_DATA_MODELS_LEADERBOARDMODEL_H
7 changes: 5 additions & 2 deletions src/ui/win32/bindings/ImageBinding.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public:

~ImageBinding() noexcept
{
GSL_SUPPRESS_F6 auto& pImageRepository = ra::services::ServiceLocator::GetMutable<ra::ui::IImageRepository>();
pImageRepository.RemoveNotifyTarget(*this);
if (ra::services::ServiceLocator::Exists<ra::ui::IImageRepository>())
{
GSL_SUPPRESS_F6 auto& pImageRepository = ra::services::ServiceLocator::GetMutable<ra::ui::IImageRepository>();
pImageRepository.RemoveNotifyTarget(*this);
}
}

ImageBinding(const ImageBinding&) noexcept = delete;
Expand Down
5 changes: 0 additions & 5 deletions tests/RA_Integration.Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
<ClCompile Include="..\src\data\context\EmulatorContext.cpp" />
<ClCompile Include="..\src\data\context\GameContext.cpp" />
<ClCompile Include="..\src\data\context\SessionTracker.cpp" />
<ClCompile Include="..\src\data\models\AchievementModel.cpp" />
<ClCompile Include="..\src\data\models\LeaderboardModel.cpp" />
<ClCompile Include="..\src\pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -144,7 +142,6 @@
<ClCompile Include="..\src\ui\viewmodels\TriggerViewModel.cpp" />
<ClCompile Include="..\src\ui\viewmodels\UnknownGameViewModel.cpp" />
<ClCompile Include="api\ConnectedServer_Tests.cpp" />
<ClInclude Include="..\src\data\models\LeaderboardModel.hh" />
<ClInclude Include="..\src\RA_Defs.h" />
<ClCompile Include="..\src\ui\ViewModelBase.cpp" />
<ClCompile Include="..\src\ui\viewmodels\GameChecksumViewModel.cpp" />
Expand All @@ -155,8 +152,6 @@
<ClCompile Include="data\context\GameAssets_Tests.cpp" />
<ClCompile Include="data\context\GameContext_Tests.cpp" />
<ClCompile Include="data\context\SessionTracker_Tests.cpp" />
<ClCompile Include="data\models\AchievementModel_Tests.cpp" />
<ClCompile Include="data\models\LeaderboardModel_Tests.cpp" />
<ClCompile Include="devkit\context\mocks\MockEmulatorMemoryContext.cpp" />
<ClCompile Include="devkit\context\mocks\MockRcClient.cpp" />
<ClCompile Include="Exports_Tests.cpp" />
Expand Down
18 changes: 0 additions & 18 deletions tests/RA_Integration.Tests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<Filter Include="Tests\Data\Context">
<UniqueIdentifier>{da241f86-5f80-4b36-b3d8-f8a0ecc1a4ee}</UniqueIdentifier>
</Filter>
<Filter Include="Tests\Data\Models">
<UniqueIdentifier>{a0f14c97-e5dd-4827-9864-ca54f0c9177e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\RA_Defs.cpp">
Expand Down Expand Up @@ -309,12 +306,6 @@
<ClCompile Include="data\context\GameContext_Tests.cpp">
<Filter>Tests\Data\Context</Filter>
</ClCompile>
<ClCompile Include="..\src\data\models\AchievementModel.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="data\models\AchievementModel_Tests.cpp">
<Filter>Tests\Data\Models</Filter>
</ClCompile>
<ClCompile Include="ui\viewmodels\AssetListViewModel_Tests.cpp">
<Filter>Tests\UI\ViewModels</Filter>
</ClCompile>
Expand All @@ -339,12 +330,6 @@
<ClCompile Include="..\src\ui\viewmodels\ChallengeIndicatorViewModel.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="..\src\data\models\LeaderboardModel.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="data\models\LeaderboardModel_Tests.cpp">
<Filter>Tests\Data\Models</Filter>
</ClCompile>
<ClCompile Include="..\src\ui\viewmodels\IntegrationMenuViewModel.cpp">
<Filter>Code</Filter>
</ClCompile>
Expand Down Expand Up @@ -512,9 +497,6 @@
<ClInclude Include="ui\viewmodels\TriggerConditionAsserts.hh">
<Filter>Tests\UI\ViewModels</Filter>
</ClInclude>
<ClInclude Include="..\src\data\models\LeaderboardModel.hh">
<Filter>Code</Filter>
</ClInclude>
<ClInclude Include="..\src\ui\viewmodels\PointerFinderViewModel.hh">
<Filter>Code</Filter>
</ClInclude>
Expand Down
Loading
Loading