[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / platform / win10 / MessagePrinter.cpp
blob9759331abf97095ee439cf96f086eb1a1a0878fc
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "platform/MessagePrinter.h"
11 #include "CompileInfo.h"
12 #include "rendering/dx/DeviceResources.h"
13 #include "rendering/dx/RenderContext.h"
14 #include "utils/log.h"
15 #include "windowing/win10/WinSystemWin10DX.h"
17 #include "platform/win32/CharsetConverter.h"
19 #include <winrt/Windows.ApplicationModel.Core.h>
20 #include <winrt/Windows.UI.Popups.h>
22 int WINAPI MessageBox(void* hWnd, const char* lpText, const char* lpCaption, UINT uType)
24 using namespace winrt::Windows::ApplicationModel::Core;
26 auto coreWindow = CoreApplication::MainView().CoreWindow();
27 if (!coreWindow)
28 return IDOK;
30 auto wText = KODI::PLATFORM::WINDOWS::ToW(lpText);
31 auto wCaption = KODI::PLATFORM::WINDOWS::ToW(lpCaption);
33 auto handler = winrt::Windows::UI::Core::DispatchedHandler([wText, wCaption]()
35 // Show the message dialog
36 auto msg = winrt::Windows::UI::Popups::MessageDialog(wText, wCaption);
37 // Set the command to be invoked when a user presses 'ESC'
38 msg.CancelCommandIndex(1);
39 msg.ShowAsync();
40 });
42 if (coreWindow.Dispatcher().HasThreadAccess())
43 handler();
44 else
45 coreWindow.Dispatcher().RunAsync(winrt::Windows::UI::Core::CoreDispatcherPriority::Normal, handler);
47 return IDOK;
50 void CMessagePrinter::DisplayMessage(const std::string& message)
52 MessageBox(NULL, message.c_str(), CCompileInfo::GetAppName(), MB_OK | MB_ICONINFORMATION);
55 void CMessagePrinter::DisplayWarning(const std::string& warning)
57 MessageBox(NULL, warning.c_str(), CCompileInfo::GetAppName(), MB_OK | MB_ICONWARNING);
60 void CMessagePrinter::DisplayError(const std::string& error)
62 MessageBox(NULL, error.c_str(), CCompileInfo::GetAppName(), MB_OK | MB_ICONERROR);
65 void CMessagePrinter::DisplayHelpMessage(const std::vector<std::pair<std::string, std::string>>& help)
67 //very crude implementation, pretty it up when possible
68 std::string message;
69 for (const auto& line : help)
71 message.append(line.first + "\t" + line.second + "\r\n");
74 MessageBox(NULL, message.c_str(), CCompileInfo::GetAppName(), MB_OK | MB_ICONINFORMATION);