Updates for bazel on windows.

This commit is contained in:
2023-05-17 14:26:26 -07:00
parent a8c0ef05fb
commit 9e8f04e9b4
84 changed files with 2789 additions and 5836 deletions

View File

@@ -17,45 +17,100 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef WIN32
#include "WindowsLogger.h"
// Documentation for the windows api stuff used here is available at
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
// clang-format off
#include "WindowsLogger.h"
#ifdef _WIN32
#include <windows.h>
#include <winuser.h>
#include <cstdlib>
#include <exception>
#include <string>
#endif
// clang-format on
namespace OpenArena {
WindowsLogger::WindowsLogger() {
_type = MESSAGETYPE_ALL;
#ifdef _WIN32
namespace {
using std::exception;
using std::string;
const string kDebugMessageTitle = "Debug";
const string kErrorMessageTitle = "ERROR";
const string kInfoMessageTitle = "Information";
const string kVerboseMessageTitle = "Verbose";
const string kWarningMessageTitle = "Warning";
const string kWtfMessageTitle = "How did you let this happen?";
const string kUnknownMessageTitle = "Unknown";
} // End namespace
WindowsLogger::WindowsLogger() {}
WindowsLogger::~WindowsLogger() {}
void WindowsLogger::LogMessage(const MessageType& type, const string& message) const {
MessageBox(NULL, message.c_str(), GetTitle(type).c_str(), MB_OK | GetIcon(type));
}
WindowsLogger::~WindowsLogger(void) {}
WindowsLogger::WindowsLogger(Logger::MessageType type) {
_type = type;
void WindowsLogger::LogError(const MessageType& type, const exception& ex) const {
Logger::LogToDo("Implement OpenArena::WindowsLogger::LogError(MessageType, exception)");
}
void WindowsLogger::Log(const char* message, MessageType type) {
Log(message, "unspecified", type);
void WindowsLogger::LogError(const MessageType& type, const std::string& message, const std::exception& ex) const {
Logger::LogToDo("Implement OpenArena::WindowsLogger::LogError(MessageType, exception, message)");
}
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));
/*
MB_ICONEXCLAMATION - An exclamation point.
MB_ICONWARNING - An exclamation point. Alias for MB_ICONEXCLAMATION.
MB_ICONINFORMATION - A lowercase i.
MB_ICONASTERISK - A lowercase i. Alias for MB_ICONINFORMATION.
MB_ICONQUESTION - A question mark. Don't use this, because it's confusing to users.
MB_ICONSTOP - A stop sign icon.
MB_ICONERROR - A stop sign icon. Alias for MB_ICONSTOP.
MB_ICONHAND - A stop sign icon. Alias for MB_ICONSTOP.
*/
uint32_t WindowsLogger::GetIcon(const MessageType& type) const {
switch (type) {
case MessageType::Debug:
return MB_ICONEXCLAMATION;
case MessageType::Error:
return MB_ICONSTOP;
case MessageType::Info:
return MB_ICONINFORMATION;
case MessageType::Verbose:
return MB_ICONINFORMATION;
case MessageType::Warning:
return MB_ICONEXCLAMATION;
case MessageType::Wtf:
return MB_ICONSTOP;
default:
return MB_ICONINFORMATION;
}
}
uint32 WindowsLogger::GetIconFromMessageType(MessageType type) {
string WindowsLogger::GetTitle(const MessageType& type) const {
switch (type) {
case MESSAGETYPE_ERROR:
return MB_ICONERROR;
case MESSAGETYPE_INFORMATION:
return MB_ICONINFORMATION;
case MESSAGETYPE_DEBUG:
return MB_ICONWARNING;
case MessageType::Debug:
return kDebugMessageTitle;
case MessageType::Error:
return kErrorMessageTitle;
case MessageType::Info:
return kInfoMessageTitle;
case MessageType::Verbose:
return kVerboseMessageTitle;
case MessageType::Warning:
return kWarningMessageTitle;
case MessageType::Wtf:
return kWtfMessageTitle;
default:
return MB_ICONASTERISK;
};
return kUnknownMessageTitle;
}
}
}; // namespace OpenArena
#endif
} // End namespace OpenArena
#ifdef WIN32
namespace OpenArena {}; // namespace OpenArena
#endif