Skip to content

Commit

Permalink
Merge branch 'master' into svc_rc_client_external
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Dec 2, 2023
2 parents 72f31df + 2164dcc commit 861424d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
17 changes: 15 additions & 2 deletions src/services/AchievementRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "services\IAudioSystem.hh"
#include "services\IConfiguration.hh"
#include "services\IFileSystem.hh"
#include "services\IHttpRequester.hh"
#include "services\ILocalStorage.hh"
#include "services\ServiceLocator.hh"
#include "services\impl\JsonFileConfiguration.hh"
Expand Down Expand Up @@ -193,12 +194,23 @@ uint32_t AchievementRuntime::ReadMemory(uint32_t nAddress, uint8_t* pBuffer, uin
}

static void ConvertHttpResponseToApiServerResponse(rc_api_server_response_t& pResponse,
const ra::services::Http::Response& httpResponse) noexcept
const ra::services::Http::Response& httpResponse,
std::string& sErrorBuffer)
{
memset(&pResponse, 0, sizeof(pResponse));
pResponse.http_status_code = ra::etoi(httpResponse.StatusCode());
pResponse.body = httpResponse.Content().c_str();
pResponse.body_length = httpResponse.Content().length();

if (pResponse.http_status_code > 599 || pResponse.body_length == 0)
{
const auto& pHttpRequestService = ra::services::ServiceLocator::Get<ra::services::IHttpRequester>();
sErrorBuffer = pHttpRequestService.GetStatusCodeText(pResponse.http_status_code);
pResponse.body = sErrorBuffer.c_str();
pResponse.body_length = sErrorBuffer.length();
pResponse.http_status_code = pHttpRequestService.IsRetryable(pResponse.http_status_code) ?
RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR : RC_API_SERVER_RESPONSE_CLIENT_ERROR;
}
}

void AchievementRuntime::ServerCallAsync(const rc_api_request_t* pRequest, rc_client_server_callback_t fCallback,
Expand Down Expand Up @@ -253,7 +265,8 @@ void AchievementRuntime::ServerCallAsync(const rc_api_request_t* pRequest, rc_cl

httpRequest.CallAsync([fCallback, pCallbackData, sApi](const ra::services::Http::Response& httpResponse) {
rc_api_server_response_t pResponse;
ConvertHttpResponseToApiServerResponse(pResponse, httpResponse);
std::string sErrorBuffer;
ConvertHttpResponseToApiServerResponse(pResponse, httpResponse, sErrorBuffer);

RA_LOG_INFO("<< %s response (%d): %s", sApi.c_str(), ra::etoi(httpResponse.StatusCode()),
httpResponse.Content().c_str());
Expand Down
18 changes: 12 additions & 6 deletions src/ui/win32/OverlayWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ void OverlayWindow::CreateOverlayWindow(HWND hWnd)

if (m_hOverlayWnd && IsWindow(m_hOverlayWnd))
{
// overlay window exists, just update the parent (if necessary)
// overlay window already exists, destroy before creating a new one
if (m_hWnd != hWnd)
{
m_hWnd = hWnd;
SetParent(m_hOverlayWnd, hWnd);
UpdateOverlayPosition();
DestroyOverlayWindow();
}
else
{
return;
}
return;
}

// overlay window does not exist, create it
Expand Down Expand Up @@ -197,8 +198,13 @@ void OverlayWindow::CreateOverlayWindow()
});
}

void OverlayWindow::DestroyOverlayWindow() noexcept
void OverlayWindow::DestroyOverlayWindow()
{

//clear current popups so they don't interfere with creation of a new overlay
auto& pOverlayManager = ra::services::ServiceLocator::GetMutable<ra::ui::viewmodels::OverlayManager>();
pOverlayManager.ClearPopups();

if (m_hEventHook)
{
UnhookWinEvent(m_hEventHook);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/win32/OverlayWindow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OverlayWindow
{
public:
void CreateOverlayWindow(HWND hWnd);
void DestroyOverlayWindow() noexcept;
void DestroyOverlayWindow();

void OnOverlayMoved() noexcept;

Expand Down

0 comments on commit 861424d

Please sign in to comment.