Added Interface Logger

Added Class WindowsLogger which logs messages via the Windows MessageBox function
~G2k
This commit is contained in:
2006-07-01 23:08:51 -04:00
parent 3a996055f4
commit 1dd65057a8
3 changed files with 80 additions and 0 deletions

47
src/WindowsLogger.cpp Normal file
View File

@@ -0,0 +1,47 @@
#include <cstdlib>
#include "WindowsLogger.h"
#include <windows.h>
namespace OpenArena
{
WindowsLogger::WindowsLogger()
{
_type = MESSAGETYPE_ALL;
}
WindowsLogger::~WindowsLogger(void)
{
}
WindowsLogger::WindowsLogger(Logger::MessageType type)
{
_type = type;
}
void WindowsLogger::Log(const char* message, MessageType type)
{
Log(message, "unspecified", type);
}
void WindowsLogger::Log(const char* message, const char* classification, MessageType type)
{
if(_type != MESSAGETYPE_NONE || _type == type || _type == MESSAGETYPE_ALL)
{
MessageBox(NULL, message, classification, MB_OK | GetIconFromMessageType(type));
}
}
uint32 WindowsLogger::GetIconFromMessageType(MessageType type)
{
switch (type)
{
case MESSAGETYPE_ERROR:
return MB_ICONERROR;
case MESSAGETYPE_INFORMATION:
return MB_ICONINFORMATION;
case MESSAGETYPE_DEBUG:
return MB_ICONWARNING;
default:
return MB_ICONASTERISK;
};
}
};