2020-11-11 20:06:52 +00:00
|
|
|
#include "PommeDebug.h"
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
void ImplementMe(const char* fn, std::string msg, int severity)
|
|
|
|
{
|
|
|
|
if (severity >= 0)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "[TODO] \x1b[1m" << fn << "\x1b[22m";
|
|
|
|
if (!msg.empty())
|
|
|
|
{
|
|
|
|
ss << ": " << msg;
|
|
|
|
}
|
|
|
|
auto str = ss.str();
|
|
|
|
std::cerr << (severity > 0 ? "\x1b[31m" : "\x1b[33m") << str << "\x1b[0m\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (severity >= 2)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << fn << "()";
|
|
|
|
if (!msg.empty()) ss << "\n" << msg;
|
|
|
|
|
|
|
|
auto str = ss.str();
|
|
|
|
|
|
|
|
int mbflags = SDL_MESSAGEBOX_ERROR;
|
|
|
|
if (severity == 0) mbflags = SDL_MESSAGEBOX_INFORMATION;
|
|
|
|
if (severity == 1) mbflags = SDL_MESSAGEBOX_WARNING;
|
|
|
|
|
|
|
|
SDL_ShowSimpleMessageBox(mbflags, "Source port TODO", str.c_str(), nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (severity >= 2)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 10:35:29 +00:00
|
|
|
std::string Pomme::FourCCString(uint32_t fourCC, char filler)
|
2020-11-11 20:06:52 +00:00
|
|
|
{
|
2021-04-17 10:35:29 +00:00
|
|
|
char stringBuffer[5];
|
|
|
|
|
|
|
|
int shift = 24;
|
|
|
|
|
2020-11-11 20:06:52 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2021-04-17 10:35:29 +00:00
|
|
|
char c = (fourCC >> shift) & 0xFF;
|
|
|
|
|
|
|
|
// Replace any non-alphanumeric character with the filler character.
|
|
|
|
// This ensures that the resulting string is suitable for use as a filename.
|
|
|
|
if (!isalnum(c))
|
|
|
|
c = filler;
|
|
|
|
|
|
|
|
stringBuffer[i] = c;
|
|
|
|
|
|
|
|
shift -= 8;
|
2020-11-11 20:06:52 +00:00
|
|
|
}
|
2021-04-17 10:35:29 +00:00
|
|
|
|
|
|
|
stringBuffer[4] = '\0';
|
|
|
|
|
|
|
|
return stringBuffer;
|
2020-11-11 20:06:52 +00:00
|
|
|
}
|