Trying to make a button that disable panic alerts popups please test

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2680 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-03-18 22:05:31 +00:00
parent da288c5780
commit dc9a4860b9
9 changed files with 48 additions and 46 deletions

View File

@ -1,6 +1,5 @@
#include "LogManager.h" #include "LogManager.h"
#include "Timer.h" #include "Timer.h"
#include "../../Core/Src/PowerPC/PowerPC.h" // Core
LogManager *LogManager::m_logManager = NULL; LogManager *LogManager::m_logManager = NULL;

View File

@ -16,9 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////
// Include and declarations
// ¯¯¯¯¯¯¯¯¯
#include <stdio.h> // System #include <stdio.h> // System
#include "Common.h" // Local #include "Common.h" // Local
@ -26,20 +23,22 @@
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style); bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style);
static MsgAlertHandler msg_handler = DefaultMsgHandler; static MsgAlertHandler msg_handler = DefaultMsgHandler;
///////////////////////////// static bool AlertEnabled = true;
/* Select which of these functions that are used for message boxes. If
/* Select which of these functions that are used for message boxes. If wxWidgets is enabled wxWidgets is enabled we will use wxMsgAlert() that is defined in main.cpp */
we will use wxMsgAlert() that is defined in main.cpp */
void RegisterMsgAlertHandler(MsgAlertHandler handler) void RegisterMsgAlertHandler(MsgAlertHandler handler)
{ {
msg_handler = handler; msg_handler = handler;
} }
///////////////////////////////////////////////////////////// // enable/disable the alert handler
/* This is the first stop for messages where the log is updated and the correct windows void SetEnableAlert(bool enable) {
is shown */ AlertEnabled = enable;
// ¯¯¯¯¯¯¯¯¯ }
/* This is the first stop for gui alerts where the log is updated and the
correct windows is shown */
bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...) bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...)
{ {
// --------------------------------- // ---------------------------------
@ -54,17 +53,14 @@ bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, .
va_end(args); va_end(args);
ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer); ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer);
// -----------
if (msg_handler) { if (msg_handler && AlertEnabled) {
ret = msg_handler(caption, buffer, yes_no, Style); ret = msg_handler(caption, buffer, yes_no, Style);
} }
return ret; return ret;
} }
///////////////////////////////////////////////////////////// // Default non library depended panic alert
/* This is used in the No-GUI build */
// ¯¯¯¯¯¯¯¯¯
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style) bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style)
{ {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -29,6 +29,7 @@ typedef bool (*MsgAlertHandler)(const char* caption, const char* text,
bool yes_no, int Style); bool yes_no, int Style);
void RegisterMsgAlertHandler(MsgAlertHandler handler); void RegisterMsgAlertHandler(MsgAlertHandler handler);
extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...); extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...);
void SetEnableAlert(bool enable);
#ifdef _WIN32 #ifdef _WIN32
#define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, __VA_ARGS__) #define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, __VA_ARGS__)
@ -36,10 +37,10 @@ extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* fo
#define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, __VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, __VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, __VA_ARGS__) #define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, __VA_ARGS__)
#else #else
#define SuccessAlert(format, ...) MsgAlert("SUCCESS", false, INFORMATION, format, ##__VA_ARGS__) #define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, ##__VA_ARGS__)
#define PanicAlert(format, ...) MsgAlert("PANIC", false, WARNING, format, ##__VA_ARGS__) #define PanicAlert(format, ...) MsgAlert("Warning", false, WARNING, format, ##__VA_ARGS__)
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, WARNING, format, ##__VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, ##__VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert("ASK", true, QUESTION, format, ##__VA_ARGS__) #define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, ##__VA_ARGS__)
#endif #endif
#endif //MSGHANDLER #endif //MSGHANDLER

View File

@ -68,6 +68,7 @@ void SConfig::SaveSettings()
{ {
// Interface // Interface
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop); ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
ini.Set("Interface", "UsePanicHandlers", m_LocalCoreStartupParameter.bUsePanicHandlers);
ini.Set("Interface", "HideCursor", m_LocalCoreStartupParameter.bHideCursor); ini.Set("Interface", "HideCursor", m_LocalCoreStartupParameter.bHideCursor);
ini.Set("Interface", "AutoHideCursor", m_LocalCoreStartupParameter.bAutoHideCursor); ini.Set("Interface", "AutoHideCursor", m_LocalCoreStartupParameter.bAutoHideCursor);
ini.Set("Interface", "Theme", m_LocalCoreStartupParameter.iTheme); ini.Set("Interface", "Theme", m_LocalCoreStartupParameter.iTheme);
@ -168,6 +169,7 @@ void SConfig::LoadSettings()
{ {
// Interface // Interface
ini.Get("Interface", "ConfirmStop", &m_LocalCoreStartupParameter.bConfirmStop, false); ini.Get("Interface", "ConfirmStop", &m_LocalCoreStartupParameter.bConfirmStop, false);
ini.Get("Interface", "UsePanicHandlers", &m_LocalCoreStartupParameter.bUsePanicHandlers, true);
ini.Get("Interface", "HideCursor", &m_LocalCoreStartupParameter.bHideCursor, false); ini.Get("Interface", "HideCursor", &m_LocalCoreStartupParameter.bHideCursor, false);
ini.Get("Interface", "AutoHideCursor", &m_LocalCoreStartupParameter.bAutoHideCursor, false); ini.Get("Interface", "AutoHideCursor", &m_LocalCoreStartupParameter.bAutoHideCursor, false);
ini.Get("Interface", "Theme", &m_LocalCoreStartupParameter.iTheme, 0); ini.Get("Interface", "Theme", &m_LocalCoreStartupParameter.iTheme, 0);

View File

@ -74,7 +74,7 @@ struct SCoreStartupParameter
bool bWidescreen, bProgressiveScan; bool bWidescreen, bProgressiveScan;
// Interface settings // Interface settings
bool bConfirmStop, bHideCursor, bAutoHideCursor; bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers;
int iTheme; int iTheme;
enum EBootBios enum EBootBios

View File

@ -38,6 +38,7 @@ EVT_CLOSE(CConfigMain::OnClose)
EVT_BUTTON(wxID_CLOSE, CConfigMain::CloseClick) EVT_BUTTON(wxID_CLOSE, CConfigMain::CloseClick)
EVT_CHECKBOX(ID_INTERFACE_CONFIRMSTOP, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_CONFIRMSTOP, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_USEPANICHANDLERS, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_HIDECURSOR, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_HIDECURSOR, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_AUTOHIDECURSOR, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_AUTOHIDECURSOR, CConfigMain::CoreSettingsChanged)
EVT_RADIOBOX(ID_INTERFACE_THEME, CConfigMain::CoreSettingsChanged) EVT_RADIOBOX(ID_INTERFACE_THEME, CConfigMain::CoreSettingsChanged)
@ -199,6 +200,11 @@ void CConfigMain::CreateGUIControls()
// Confirm on stop // Confirm on stop
ConfirmStop = new wxCheckBox(GeneralPage, ID_INTERFACE_CONFIRMSTOP, wxT("Confirm On Stop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); ConfirmStop = new wxCheckBox(GeneralPage, ID_INTERFACE_CONFIRMSTOP, wxT("Confirm On Stop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
ConfirmStop->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop); ConfirmStop->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop);
// Use Panic Handlers
UsePanicHandlers = new wxCheckBox(GeneralPage, ID_INTERFACE_USEPANICHANDLERS, wxT("Use Panic Handlers"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
UsePanicHandlers->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
// Hide Cursor // Hide Cursor
wxStaticText *HideCursorText = new wxStaticText(GeneralPage, ID_INTERFACE_HIDECURSOR_TEXT, wxT("Hide Cursor:"), wxDefaultPosition, wxDefaultSize); wxStaticText *HideCursorText = new wxStaticText(GeneralPage, ID_INTERFACE_HIDECURSOR_TEXT, wxT("Hide Cursor:"), wxDefaultPosition, wxDefaultSize);
AutoHideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_AUTOHIDECURSOR, wxT("Auto")); AutoHideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_AUTOHIDECURSOR, wxT("Auto"));
@ -234,6 +240,7 @@ void CConfigMain::CreateGUIControls()
UseDynaRec->SetToolTip(wxT("Disabling this will cause Dolphin to run in interpreter mode," UseDynaRec->SetToolTip(wxT("Disabling this will cause Dolphin to run in interpreter mode,"
"\nwhich can be more accurate, but is MUCH slower")); "\nwhich can be more accurate, but is MUCH slower"));
ConfirmStop->SetToolTip(wxT("Show a confirmation box before stopping a game.")); ConfirmStop->SetToolTip(wxT("Show a confirmation box before stopping a game."));
UsePanicHandlers->SetToolTip(wxT("Show Panic Alerts Popups"));
AutoHideCursor->SetToolTip(wxT("This will auto hide the cursor in fullscreen mode.")); AutoHideCursor->SetToolTip(wxT("This will auto hide the cursor in fullscreen mode."));
HideCursor->SetToolTip(wxT("This will always hide the cursor when it's over the rendering window." HideCursor->SetToolTip(wxT("This will always hide the cursor when it's over the rendering window."
"\nIt can be convenient in a Wii game that already has a cursor.")); "\nIt can be convenient in a Wii game that already has a cursor."));
@ -265,6 +272,7 @@ void CConfigMain::CreateGUIControls()
sbInterface = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Interface Settings")); sbInterface = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Interface Settings"));
sbInterface->Add(ConfirmStop, 0, wxALL, 5); sbInterface->Add(ConfirmStop, 0, wxALL, 5);
sbInterface->Add(UsePanicHandlers, 0, wxALL, 5);
wxBoxSizer *sHideCursor = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *sHideCursor = new wxBoxSizer(wxHORIZONTAL);
sHideCursor->Add(HideCursorText); sHideCursor->Add(HideCursorText);
sHideCursor->Add(AutoHideCursor, 0, wxLEFT, 5); sHideCursor->Add(AutoHideCursor, 0, wxLEFT, 5);
@ -570,6 +578,10 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
case ID_INTERFACE_CONFIRMSTOP: // Interface case ID_INTERFACE_CONFIRMSTOP: // Interface
SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop = ConfirmStop->IsChecked(); SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop = ConfirmStop->IsChecked();
break; break;
case ID_INTERFACE_USEPANICHANDLERS: // Interface
SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers = UsePanicHandlers->IsChecked();
SetEnableAlert(UsePanicHandlers->IsChecked());
break;
case ID_INTERFACE_AUTOHIDECURSOR: case ID_INTERFACE_AUTOHIDECURSOR:
if (AutoHideCursor->IsChecked()) HideCursor->SetValue(!AutoHideCursor->IsChecked()); // Update the other one if (AutoHideCursor->IsChecked()) HideCursor->SetValue(!AutoHideCursor->IsChecked()); // Update the other one
SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor = AutoHideCursor->IsChecked(); SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor = AutoHideCursor->IsChecked();

View File

@ -49,7 +49,8 @@ class CConfigMain
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxBoxSizer* sGeneralPage; // General Settings wxBoxSizer* sGeneralPage; // General Settings
wxCheckBox* ConfirmStop, * AutoHideCursor, *HideCursor; wxCheckBox* ConfirmStop, *AutoHideCursor;
wxCheckBox* HideCursor, *UsePanicHandlers;
wxCheckBox* WiimoteStatusLEDs, * WiimoteStatusSpeakers; wxCheckBox* WiimoteStatusLEDs, * WiimoteStatusSpeakers;
wxArrayString arrayStringFor_InterfaceLang; wxArrayString arrayStringFor_InterfaceLang;
@ -217,6 +218,7 @@ class CConfigMain
ID_ENABLECHEATS, ID_ENABLECHEATS,
ID_INTERFACE_CONFIRMSTOP, // Interface settings ID_INTERFACE_CONFIRMSTOP, // Interface settings
ID_INTERFACE_USEPANICHANDLERS,
ID_INTERFACE_HIDECURSOR_TEXT, ID_INTERFACE_HIDECURSOR, ID_INTERFACE_AUTOHIDECURSOR, ID_INTERFACE_HIDECURSOR_TEXT, ID_INTERFACE_HIDECURSOR, ID_INTERFACE_AUTOHIDECURSOR,
ID_INTERFACE_WIIMOTE_TEXT, ID_INTERFACE_WIIMOTE_LEDS, ID_INTERFACE_WIIMOTE_SPEAKERS, ID_INTERFACE_WIIMOTE_TEXT, ID_INTERFACE_WIIMOTE_LEDS, ID_INTERFACE_WIIMOTE_SPEAKERS,
ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG, ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG,

View File

@ -26,7 +26,7 @@
#include "LogWindow.h" #include "LogWindow.h"
#include "Console.h" #include "Console.h"
#define UPDATETIME 1000 #define UPDATETIME 100
BEGIN_EVENT_TABLE(CLogWindow, wxDialog) BEGIN_EVENT_TABLE(CLogWindow, wxDialog)
EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit) EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit)

View File

@ -128,30 +128,18 @@ bool DolphinApp::OnInit()
#ifdef _WIN32 #ifdef _WIN32
EXTENDEDTRACEINITIALIZE("."); EXTENDEDTRACEINITIALIZE(".");
SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
#endif
// TODO: if First Boot // TODO: if First Boot
if (!cpu_info.bSSE2) if (!cpu_info.bSSE2)
{ {
MessageBox(0, _T("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" PanicAlert("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
"Sayonara!\n"), "Dolphin", MB_ICONINFORMATION); "Sayonara!\n");
return false; return false;
} }
#else
if (!cpu_info.bSSE2)
{
printf("%s", "Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
"Sayonara!\n");
exit(0);
}
#endif
// ---------------
// ------------------------------------------
// Parse command lines // Parse command lines
// ---------------
#if wxUSE_CMDLINE_PARSER #if wxUSE_CMDLINE_PARSER
wxCmdLineEntryDesc cmdLineDesc[] = wxCmdLineEntryDesc cmdLineDesc[] =
{ {
@ -221,17 +209,19 @@ bool DolphinApp::OnInit()
// ============ // ============
#endif #endif
// Load CONFIG_FILE settings // Load CONFIG_FILE settings
SConfig::GetInstance().LoadSettings(); SConfig::GetInstance().LoadSettings();
// Enable the PNG image handler
wxInitAllImageHandlers();
// Enable the PNG image handler SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
wxInitAllImageHandlers();
// Create the window title // Create the window title
#ifdef _DEBUG #ifdef _DEBUG
const char *title = "Dolphin Debug SVN R " SVN_REV_STR; const char *title = "Dolphin Debug SVN R " SVN_REV_STR;
#else #else
const char *title = "Dolphin SVN R " SVN_REV_STR; const char *title = "Dolphin SVN R " SVN_REV_STR;
#endif #endif
// If we are debugging let use save the main window position and size // If we are debugging let use save the main window position and size