mirror of https://github.com/PCSX2/pcsx2.git
Host: Add ReportErrorAsync() and formatted variant
This commit is contained in:
parent
1859ede325
commit
b3b7c55b9a
|
@ -0,0 +1,29 @@
|
||||||
|
/* PCSX2 - PS2 Emulator for PCs
|
||||||
|
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||||
|
*
|
||||||
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "Host.h"
|
||||||
|
#include "common/StringHelpers.h"
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
|
void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...)
|
||||||
|
{
|
||||||
|
std::va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
FastFormatAscii fmt;
|
||||||
|
fmt.WriteV(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
ReportErrorAsync(title, fmt.c_str());
|
||||||
|
}
|
10
pcsx2/Host.h
10
pcsx2/Host.h
|
@ -16,8 +16,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Pcsx2Defs.h"
|
#include "common/Pcsx2Defs.h"
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct HostKeyEvent
|
struct HostKeyEvent
|
||||||
|
@ -36,9 +38,13 @@ struct HostKeyEvent
|
||||||
namespace Host
|
namespace Host
|
||||||
{
|
{
|
||||||
/// Reads a file from the resources directory of the application.
|
/// Reads a file from the resources directory of the application.
|
||||||
/// This may be outside of the "normally" filesystem on platforms such as Mac.
|
/// This may be outside of the "normal" filesystem on platforms such as Mac.
|
||||||
std::optional<std::vector<u8>> ReadResourceFile(const char* filename);
|
std::optional<std::vector<u8>> ReadResourceFile(const char* filename);
|
||||||
|
|
||||||
/// Reads a resource file file from the resources directory as a string.
|
/// Reads a resource file file from the resources directory as a string.
|
||||||
std::optional<std::string> ReadResourceFileToString(const char* filename);
|
std::optional<std::string> ReadResourceFileToString(const char* filename);
|
||||||
|
|
||||||
|
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
|
||||||
|
void ReportErrorAsync(const std::string_view& title, const std::string_view& message);
|
||||||
|
void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...);
|
||||||
} // namespace Host
|
} // namespace Host
|
||||||
|
|
|
@ -19,9 +19,12 @@
|
||||||
#include "common/FileSystem.h"
|
#include "common/FileSystem.h"
|
||||||
#include "common/Path.h"
|
#include "common/Path.h"
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "Host.h"
|
#include "Host.h"
|
||||||
|
|
||||||
|
#include "gui/App.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
|
#include "gui/pxEvents.h"
|
||||||
|
|
||||||
static auto OpenResourceCFile(const char* filename, const char* mode)
|
static auto OpenResourceCFile(const char* filename, const char* mode)
|
||||||
{
|
{
|
||||||
const std::string full_filename(Path::CombineStdString(EmuFolders::Resources, filename));
|
const std::string full_filename(Path::CombineStdString(EmuFolders::Resources, filename));
|
||||||
|
@ -67,3 +70,11 @@ std::optional<std::string> Host::ReadResourceFileToString(const char* filename)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message)
|
||||||
|
{
|
||||||
|
wxGetApp().PostEvent(pxMessageBoxEvent(
|
||||||
|
title.empty() ? wxString() : wxString::FromUTF8(title.data(), title.length()),
|
||||||
|
message.empty() ? wxString() : wxString::FromUTF8(message.data(), message.length()),
|
||||||
|
MsgButtons().OK()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,6 +331,7 @@
|
||||||
<ClCompile Include="gui\ThreadingDialogs.cpp" />
|
<ClCompile Include="gui\ThreadingDialogs.cpp" />
|
||||||
<ClCompile Include="gui\wxAppWithHelpers.cpp" />
|
<ClCompile Include="gui\wxAppWithHelpers.cpp" />
|
||||||
<ClCompile Include="gui\wxSettingsInterface.cpp" />
|
<ClCompile Include="gui\wxSettingsInterface.cpp" />
|
||||||
|
<ClCompile Include="Host.cpp" />
|
||||||
<ClCompile Include="IopGte.cpp" />
|
<ClCompile Include="IopGte.cpp" />
|
||||||
<ClCompile Include="PINE.cpp" />
|
<ClCompile Include="PINE.cpp" />
|
||||||
<ClCompile Include="FW.cpp" />
|
<ClCompile Include="FW.cpp" />
|
||||||
|
@ -744,6 +745,7 @@
|
||||||
<ClInclude Include="Gif_Unit.h" />
|
<ClInclude Include="Gif_Unit.h" />
|
||||||
<ClInclude Include="GS\Renderers\DX11\D3D.h" />
|
<ClInclude Include="GS\Renderers\DX11\D3D.h" />
|
||||||
<ClInclude Include="GS\Window\GSwxDialog.h" />
|
<ClInclude Include="GS\Window\GSwxDialog.h" />
|
||||||
|
<ClInclude Include="gui\AppHost.h" />
|
||||||
<ClInclude Include="gui\CheckedStaticBox.h" />
|
<ClInclude Include="gui\CheckedStaticBox.h" />
|
||||||
<ClInclude Include="gui\i18n.h" />
|
<ClInclude Include="gui\i18n.h" />
|
||||||
<ClInclude Include="gui\DriveList.h" />
|
<ClInclude Include="gui\DriveList.h" />
|
||||||
|
|
|
@ -274,6 +274,9 @@
|
||||||
<Filter Include="System\Ps2\GS\GIF">
|
<Filter Include="System\Ps2\GS\GIF">
|
||||||
<UniqueIdentifier>{78f5077b-255e-435e-9a51-352171dfaee8}</UniqueIdentifier>
|
<UniqueIdentifier>{78f5077b-255e-435e-9a51-352171dfaee8}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Host">
|
||||||
|
<UniqueIdentifier>{65f21394-287a-471b-a0c1-d8f0d5d95a81}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Utilities\folderdesc.txt">
|
<None Include="Utilities\folderdesc.txt">
|
||||||
|
@ -1640,6 +1643,9 @@
|
||||||
<ClCompile Include="SPU2\SndOut_Cubeb.cpp">
|
<ClCompile Include="SPU2\SndOut_Cubeb.cpp">
|
||||||
<Filter>System\Ps2\SPU2</Filter>
|
<Filter>System\Ps2\SPU2</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Host.cpp">
|
||||||
|
<Filter>Host</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Patch.h">
|
<ClInclude Include="Patch.h">
|
||||||
|
@ -2722,9 +2728,6 @@
|
||||||
<ClInclude Include="MemoryCardFile.h">
|
<ClInclude Include="MemoryCardFile.h">
|
||||||
<Filter>System\Ps2\Iop</Filter>
|
<Filter>System\Ps2\Iop</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Host.h">
|
|
||||||
<Filter>System\Include</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="gui\wxSettingsInterface.h">
|
<ClInclude Include="gui\wxSettingsInterface.h">
|
||||||
<Filter>AppHost</Filter>
|
<Filter>AppHost</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -2738,7 +2741,10 @@
|
||||||
<Filter>System\Ps2\PAD</Filter>
|
<Filter>System\Ps2\PAD</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="PerformanceMetrics.h">
|
<ClInclude Include="PerformanceMetrics.h">
|
||||||
<Filter>System</Filter>
|
<Filter>System\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Host.h">
|
||||||
|
<Filter>Host</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue