Simplify ErrorDialog.
This commit is contained in:
@@ -688,8 +688,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
// throw up a pretty error dialog
|
// throw up a pretty error dialog
|
||||||
ErrorDialog *d = MakeErrorDialog();
|
ErrorDialog *d = MakeErrorDialog();
|
||||||
d->SetErrorText(g_sErrorString);
|
d->ShowError( g_sErrorString );
|
||||||
d->ShowError();
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,11 @@
|
|||||||
#define ERROR_DIALOG_H
|
#define ERROR_DIALOG_H
|
||||||
|
|
||||||
class ErrorDialog {
|
class ErrorDialog {
|
||||||
CString ErrorText;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetErrorText(const CString &error) { ErrorText = error; }
|
|
||||||
CString GetErrorText() const { return ErrorText; }
|
|
||||||
|
|
||||||
/* This is used for showing errors from exceptions, so it might be used
|
/* This is used for showing errors from exceptions, so it might be used
|
||||||
* before SDL has been initialized (or SDL may have failed to init); don't
|
* before SDL has been initialized (or SDL may have failed to init); don't
|
||||||
* use SDL. If the window has been opened, it'll be hidden or closed. */
|
* use SDL. If the window has been opened, it'll be hidden or closed. */
|
||||||
virtual void ShowError() = 0;
|
virtual void ShowError( const CString &error ) = 0;
|
||||||
virtual ~ErrorDialog() { }
|
virtual ~ErrorDialog() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "../../resource.h"
|
#include "../../resource.h"
|
||||||
|
|
||||||
#include "../../archutils/Win32/GotoURL.h"
|
#include "../../archutils/Win32/GotoURL.h"
|
||||||
|
#include "../../archutils/Win32/AppInstance.h"
|
||||||
|
|
||||||
#include "ErrorDialog_Win32.h"
|
#include "ErrorDialog_Win32.h"
|
||||||
|
|
||||||
@@ -90,10 +91,11 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ErrorDialog_Win32::ShowError()
|
void ErrorDialog_Win32::ShowError( const CString &error )
|
||||||
{
|
{
|
||||||
g_sErrorString = GetErrorText();
|
g_sErrorString = error;
|
||||||
// throw up a pretty error dialog
|
// throw up a pretty error dialog
|
||||||
|
AppInstance handle;
|
||||||
DialogBox(handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG),
|
DialogBox(handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG),
|
||||||
NULL, ErrorWndProc);
|
NULL, ErrorWndProc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
#define ERROR_DIALOG_WIN32_H
|
#define ERROR_DIALOG_WIN32_H
|
||||||
|
|
||||||
#include "ErrorDialog.h"
|
#include "ErrorDialog.h"
|
||||||
#include "../../archutils/Win32/AppInstance.h"
|
|
||||||
|
|
||||||
class ErrorDialog_Win32: public ErrorDialog
|
class ErrorDialog_Win32: public ErrorDialog
|
||||||
{
|
{
|
||||||
AppInstance handle;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ShowError();
|
void ShowError( const CString &error );
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ARCH_ERROR_DIALOG
|
#undef ARCH_ERROR_DIALOG
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
class ErrorDialog_null: public ErrorDialog
|
class ErrorDialog_null: public ErrorDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void ShowError() { }
|
void ShowError( const CString &error ) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ARCH_ERROR_DIALOG
|
#undef ARCH_ERROR_DIALOG
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "../../global.h"
|
#include "../../global.h"
|
||||||
#include "ErrorDialog_stdout.h"
|
#include "ErrorDialog_stdout.h"
|
||||||
|
|
||||||
void ErrorDialog_stdout::ShowError()
|
void ErrorDialog_stdout::ShowError( const CString &error )
|
||||||
{
|
{
|
||||||
/* Simplest "dialog" ever. */
|
/* Simplest "dialog" ever. */
|
||||||
printf("Error: %s\n", GetErrorText().c_str());
|
printf("Error: %s\n", error.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
class ErrorDialog_stdout: public ErrorDialog
|
class ErrorDialog_stdout: public ErrorDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void ShowError();
|
void ShowError( const CString &error );
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ARCH_ERROR_DIALOG
|
#undef ARCH_ERROR_DIALOG
|
||||||
|
|||||||
Reference in New Issue
Block a user