1
// Copyright (C) 2003 Dolphin Project.
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
15
// Official SVN repository and contact information can be found at
16
// http://code.google.com/p/dolphin-emu/
18
#include "Common.h" // Local
19
#include "StringUtils.h"
20
#include "util/text/utf8.h"
23
bool MsgHandler(const char* caption, const char* text, bool yes_no, int Style);
25
static bool AlertEnabled = true;
27
// enable/disable the alert handler
28
void SetEnableAlert(bool enable)
30
AlertEnabled = enable;
33
// This is the first stop for gui alerts where the log is updated and the
34
// correct window is shown
35
bool MsgAlert(bool yes_no, int Style, const char* format, ...)
37
// Read message and write it to the log
40
static const char *captions[] = {
47
const char *caption = captions[Style];
50
va_start(args, format);
51
CharArrayFromFormatV(buffer, sizeof(buffer)-1, format, args);
54
ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer);
56
// Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
57
if (AlertEnabled || Style == QUESTION || Style == CRITICAL)
58
return MsgHandler(caption, buffer, yes_no, Style);
64
#include "CommonWindows.h"
67
// Default non library dependent panic alert
68
bool MsgHandler(const char* caption, const char* text, bool yes_no, int Style)
70
#if defined(USING_WIN_UI)
71
int STYLE = MB_ICONINFORMATION;
72
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
73
if (Style == WARNING) STYLE = MB_ICONWARNING;
75
std::wstring wtext = ConvertUTF8ToWString(text);
76
std::wstring wcaption = ConvertUTF8ToWString(caption);
78
return IDYES == MessageBox(0, wtext.c_str(), wcaption.c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK));