Skip to content

Commit

Permalink
export menu for rc_client_raintegration (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Jan 13, 2024
1 parent 43bbbd0 commit a2ad077
Show file tree
Hide file tree
Showing 39 changed files with 1,528 additions and 758 deletions.
2 changes: 1 addition & 1 deletion rcheevos
Submodule rcheevos updated 65 files
+28 −30 include/rc_api_editor.h
+14 −18 include/rc_api_info.h
+6 −10 include/rc_api_request.h
+38 −27 include/rc_api_runtime.h
+18 −18 include/rc_api_user.h
+86 −76 include/rc_client.h
+61 −11 include/rc_client_raintegration.h
+8 −10 include/rc_consoles.h
+5 −7 include/rc_error.h
+100 −0 include/rc_export.h
+23 −27 include/rc_hash.h
+27 −31 include/rc_runtime.h
+34 −31 include/rc_runtime_types.h
+17 −19 include/rc_url.h
+4 −6 include/rc_util.h
+48 −2 src/rapi/rc_api_common.c
+6 −7 src/rapi/rc_api_common.h
+11 −0 src/rapi/rc_api_editor.c
+52 −5 src/rapi/rc_api_runtime.c
+9 −2 src/rapi/rc_api_user.c
+100 −9 src/rc_client.c
+33 −36 src/rc_client_external.h
+11 −15 src/rc_client_internal.h
+138 −18 src/rc_client_raintegration.c
+29 −21 src/rc_client_raintegration_internal.h
+4 −6 src/rc_compat.h
+39 −39 src/rc_libretro.c
+23 −25 src/rc_libretro.h
+11 −0 src/rc_version.c
+9 −6 src/rc_version.h
+1 −1 src/rcheevos/alloc.c
+1 −1 src/rcheevos/condset.c
+4 −1 src/rcheevos/consoleinfo.c
+74 −0 src/rcheevos/format.c
+1 −1 src/rcheevos/lboard.c
+4 −9 src/rcheevos/operand.c
+3 −7 src/rcheevos/rc_internal.h
+1 −2 src/rcheevos/rc_validate.c
+2 −6 src/rcheevos/rc_validate.h
+4 −0 src/rcheevos/richpresence.c
+1 −1 src/rcheevos/runtime_progress.c
+1 −1 src/rcheevos/value.c
+39 −6 src/rhash/hash.c
+7 −1 test/Makefile
+74 −0 test/rapi/test_rc_api_common.c
+41 −2 test/rapi/test_rc_api_editor.c
+175 −0 test/rapi/test_rc_api_runtime.c
+41 −0 test/rapi/test_rc_api_user.c
+3 −2 test/rcheevos-test.vcxproj
+3 −2 test/rcheevos-test.vcxproj.filters
+133 −0 test/rcheevos/test_condset.c
+3 −2 test/rcheevos/test_consoleinfo.c
+40 −0 test/rcheevos/test_format.c
+2 −2 test/rcheevos/test_rc_validate.c
+43 −0 test/rcheevos/test_richpresence.c
+47 −0 test/rcheevos/test_trigger.c
+4 −6 test/rhash/data.h
+2 −2 test/rhash/mock_filereader.c
+4 −6 test/rhash/mock_filereader.h
+5 −5 test/rhash/test_hash.c
+478 −40 test/test_rc_client.c
+29 −0 test/test_rc_client_external.c
+121 −1 test/test_rc_client_raintegration.c
+78 −1 test/test_rc_libretro.c
+3 −3 validator/validator.c
8 changes: 6 additions & 2 deletions src/Exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "data\context\UserContext.hh"

#include "services\AchievementRuntime.hh"
#include "services\AchievementRuntimeExports.hh"
#include "services\FrameEventQueue.hh"
#include "services\GameIdentifier.hh"
#include "services\Http.hh"
Expand Down Expand Up @@ -79,8 +80,11 @@ API void CCONV _RA_UpdateHWnd(HWND hMainHWND)
{
pDesktop.SetMainHWnd(hMainHWND);

auto& pOverlayWindow = ra::services::ServiceLocator::GetMutable<ra::ui::win32::OverlayWindow>();
pOverlayWindow.CreateOverlayWindow(hMainHWND);
if (!IsExternalRcheevosClient())
{
auto& pOverlayWindow = ra::services::ServiceLocator::GetMutable<ra::ui::win32::OverlayWindow>();
pOverlayWindow.CreateOverlayWindow(hMainHWND);
}
}
}
#endif
Expand Down
16 changes: 15 additions & 1 deletion src/RA_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void __gsl_contract_handler(const char* const file, unsigned int line, const cha
}
#endif

API int CCONV _RA_Shutdown()
static int DoShutdown()
{
// if the services haven't been registered, there's nothing to shut down
if (!ra::services::Initialization::IsInitialized())
Expand Down Expand Up @@ -155,6 +155,20 @@ API int CCONV _RA_Shutdown()
return 0;
}

API int CCONV _RA_Shutdown()
{
try
{
return DoShutdown();
}
catch (std::runtime_error&)
{

}

return 0;
}

API int CCONV _RA_ConfirmLoadNewRom(int bQuittingApp)
{
// Returns true if we can go ahead and load the new rom.
Expand Down
2 changes: 2 additions & 0 deletions src/RA_Integration.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<ClCompile Include="RA_md5factory.cpp" />
<ClCompile Include="RA_StringUtils.cpp" />
<ClCompile Include="services\AchievementRuntime.cpp" />
<ClCompile Include="services\AchievementRuntimeExports.cpp" />
<ClCompile Include="services\FrameEventQueue.cpp" />
<ClCompile Include="services\GameIdentifier.cpp" />
<ClCompile Include="services\Http.cpp" />
Expand Down Expand Up @@ -231,6 +232,7 @@
<ClInclude Include="RA_Resource.h" />
<ClInclude Include="RA_StringUtils.h" />
<ClInclude Include="services\AchievementRuntime.hh" />
<ClInclude Include="services\AchievementRuntimeExports.hh" />
<ClInclude Include="services\FrameEventQueue.hh" />
<ClInclude Include="services\GameIdentifier.hh" />
<ClInclude Include="services\Http.hh" />
Expand Down
6 changes: 6 additions & 0 deletions src/RA_Integration.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@
<ClCompile Include="ui\viewmodels\ProgressTrackerViewModel.cpp">
<Filter>UI\ViewModels</Filter>
</ClCompile>
<ClCompile Include="services\AchievementRuntimeExports.cpp">
<Filter>Services</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RA_Resource.h">
Expand Down Expand Up @@ -968,6 +971,9 @@
<ClInclude Include="ui\viewmodels\ProgressTrackerViewModel.hh">
<Filter>UI\ViewModels</Filter>
</ClInclude>
<ClInclude Include="services\AchievementRuntimeExports.hh">
<Filter>Services</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="RA_Shared.rc">
Expand Down
23 changes: 15 additions & 8 deletions src/data/context/EmulatorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Exports.hh"
#include "RA_BuildVer.h"
#include "RA_Log.h"
#include "RA_Resource.h"
#include "RA_StringUtils.h"

#include "api\LatestClient.hh"
Expand All @@ -11,6 +12,7 @@
#include "data\context\UserContext.hh"

#include "services\AchievementRuntime.hh"
#include "services\AchievementRuntimeExports.hh"
#include "services\IClock.hh"
#include "services\IConfiguration.hh"
#include "services\IFileSystem.hh"
Expand Down Expand Up @@ -456,10 +458,9 @@ void EmulatorContext::DisableHardcoreMode()
auto& pWindowManager = ra::services::ServiceLocator::GetMutable<ra::ui::viewmodels::WindowManager>();
pWindowManager.AssetList.UpdateButtons();

RebuildMenu();
SyncClientExternalHardcoreState();

auto& pRuntime = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
rc_client_set_hardcore_enabled(pRuntime.GetClient(), false);
UpdateMenuState(IDM_RA_HARDCORE_MODE);

// GameContext::DoFrame synchronizes the models to the runtime
auto& pGameContext = ra::services::ServiceLocator::GetMutable<ra::data::context::GameContext>();
Expand Down Expand Up @@ -532,12 +533,11 @@ bool EmulatorContext::EnableHardcoreMode(bool bShowWarning)
// updating the enabled-ness of the buttons of the asset list
pWindowManager.AssetList.UpdateButtons();

// update the integration menu
RebuildMenu();

// update the runtime
auto* pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>().GetClient();
rc_client_set_hardcore_enabled(pClient, true);
SyncClientExternalHardcoreState();

// update the integration menu
UpdateMenuState(IDM_RA_HARDCORE_MODE);

// GameContext::DoFrame synchronizes the models to the runtime
pGameContext.DoFrame();
Expand Down Expand Up @@ -1027,6 +1027,13 @@ bool EmulatorContext::IsMemoryInsecure() const
return m_bMemoryInsecure;
}

void EmulatorContext::UpdateMenuState(int nMenuItemId) const
{
SyncClientExternalRAIntegrationMenuItem(nMenuItemId);

RebuildMenu();
}

} // namespace context
} // namespace data
} // namespace ra
6 changes: 6 additions & 0 deletions src/data/context/EmulatorContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public:
m_fRebuildMenu();
}

/// <summary>
/// Updates the state of a single menu item.
/// </summary>
/// <remarks>Indirectly calls RebuildMenu after raising an event for the singular menu item</remarks>
void UpdateMenuState(int nMenuItemId) const;

/// <summary>
/// Gets whether or not the emulator can be paused.
/// </summary>
Expand Down
Loading

0 comments on commit a2ad077

Please sign in to comment.