Switch log types to enum
This commit is contained in:
parent
24b2be60e5
commit
4c14c3dc57
27 changed files with 203 additions and 105 deletions
|
|
@ -29,17 +29,15 @@ Logger& Logger::get() {
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::add_log(const std::string& log, const std::function<void(const std::string&)> callback) {
|
void Logger::set_log_function(LogType log, const std::function<void(const std::string&)> callback) {
|
||||||
std::scoped_lock logLock(logMutex);
|
std::scoped_lock logLock(logMutex);
|
||||||
logs[log] = callback;
|
logs[log] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::log(const std::string& log, const std::string& text) {
|
void Logger::log(LogType log, const std::string& text) {
|
||||||
std::scoped_lock logLock(logMutex);
|
std::scoped_lock logLock(logMutex);
|
||||||
auto it = logs.find(log);
|
auto it = logs.find(log);
|
||||||
if(it == logs.end())
|
if(it != logs.end())
|
||||||
throw std::runtime_error("[Logger::log] Log " + log + " does not exist to log text: " + text);
|
|
||||||
else
|
|
||||||
it->second(text);
|
it->second(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,20 @@
|
||||||
class Logger {
|
class Logger {
|
||||||
public:
|
public:
|
||||||
static Logger& get();
|
static Logger& get();
|
||||||
void add_log(const std::string& log, const std::function<void(const std::string&)> callback);
|
enum class LogType {
|
||||||
void log(const std::string& log, const std::string& text);
|
INFO = 0,
|
||||||
|
DESKTOP_USERINFO,
|
||||||
|
PHONE_USERINFO,
|
||||||
|
USERINFO,
|
||||||
|
WORLDFATAL,
|
||||||
|
CHAT,
|
||||||
|
FATAL
|
||||||
|
};
|
||||||
|
void set_log_function(LogType log, const std::function<void(const std::string&)> callback);
|
||||||
|
void log(LogType log, const std::string& text);
|
||||||
void cross_platform_println(const std::string& text);
|
void cross_platform_println(const std::string& text);
|
||||||
private:
|
private:
|
||||||
static Logger global;
|
static Logger global;
|
||||||
std::mutex logMutex;
|
std::mutex logMutex;
|
||||||
std::unordered_map<std::string, std::function<void(const std::string&)>> logs;
|
std::unordered_map<LogType, std::function<void(const std::string&)>> logs;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void NetClient::init_channel(const std::string& channelName, std::shared_ptr<rtc
|
||||||
cLock->isDisconnected = true;
|
cLock->isDisconnected = true;
|
||||||
});
|
});
|
||||||
channels[channelName] = channel;
|
channels[channelName] = channel;
|
||||||
Logger::get().log("INFO", "Client channel setup: " + channelName);
|
Logger::get().log(Logger::LogType::INFO, "Client channel setup: " + channelName);
|
||||||
lastMessageTime = std::chrono::steady_clock::now();
|
lastMessageTime = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ void NetClient::update() {
|
||||||
if(isDisconnected)
|
if(isDisconnected)
|
||||||
return;
|
return;
|
||||||
if(std::chrono::steady_clock::now() - lastMessageTime >= NetLibrary::TIMEOUT_DURATION) {
|
if(std::chrono::steady_clock::now() - lastMessageTime >= NetLibrary::TIMEOUT_DURATION) {
|
||||||
Logger::get().log("INFO", "[NetClient::update] Connection timed out");
|
Logger::get().log(Logger::LogType::INFO, "[NetClient::update] Connection timed out");
|
||||||
isDisconnected = true;
|
isDisconnected = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -75,11 +75,11 @@ void NetClient::update() {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("INFO", "[NetClient::update] Exception thrown while parsing and sending messages: " + std::string(e.what()));
|
Logger::get().log(Logger::LogType::INFO, "[NetClient::update] Exception thrown while parsing and sending messages: " + std::string(e.what()));
|
||||||
isDisconnected = true;
|
isDisconnected = true;
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
Logger::get().log("INFO", "[NetClient::update] Unknown exception thrown while parsing and sending messages.");
|
Logger::get().log(Logger::LogType::INFO, "[NetClient::update] Unknown exception thrown while parsing and sending messages.");
|
||||||
isDisconnected = true;
|
isDisconnected = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -80,19 +80,19 @@ NetLibrary::LoadP2PSettingsInPathResult NetLibrary::load_p2p_settings_in_path(co
|
||||||
|
|
||||||
void NetLibrary::init_config(const std::filesystem::path& p2pConfigPath) {
|
void NetLibrary::init_config(const std::filesystem::path& p2pConfigPath) {
|
||||||
rtc::InitLogger(rtc::LogLevel::Info, [](rtc::LogLevel level, std::string message) {
|
rtc::InitLogger(rtc::LogLevel::Info, [](rtc::LogLevel level, std::string message) {
|
||||||
Logger::get().log("INFO", "[LibDataChannel Log Level " + std::to_string(static_cast<int>(level)) + "] " + message);
|
Logger::get().log(Logger::LogType::INFO, "[LibDataChannel Log Level " + std::to_string(static_cast<int>(level)) + "] " + message);
|
||||||
});
|
});
|
||||||
|
|
||||||
switch(load_p2p_settings_in_path(p2pConfigPath)) {
|
switch(load_p2p_settings_in_path(p2pConfigPath)) {
|
||||||
case LoadP2PSettingsInPathResult::SUCCESS:
|
case LoadP2PSettingsInPathResult::SUCCESS:
|
||||||
Logger::get().log("INFO", "Successfully loaded local P2P configuration");
|
Logger::get().log(Logger::LogType::INFO, "Successfully loaded local P2P configuration");
|
||||||
break;
|
break;
|
||||||
case LoadP2PSettingsInPathResult::FAILED_TO_READ:
|
case LoadP2PSettingsInPathResult::FAILED_TO_READ:
|
||||||
Logger::get().log("USERINFO", "Invalid custom P2P config, using defaults");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Invalid custom P2P config, using defaults");
|
||||||
case LoadP2PSettingsInPathResult::FAILED_TO_OPEN:
|
case LoadP2PSettingsInPathResult::FAILED_TO_OPEN:
|
||||||
switch(load_p2p_settings_in_path("data/config/default_p2p.json")) {
|
switch(load_p2p_settings_in_path("data/config/default_p2p.json")) {
|
||||||
case LoadP2PSettingsInPathResult::SUCCESS:
|
case LoadP2PSettingsInPathResult::SUCCESS:
|
||||||
Logger::get().log("INFO", "Successfully loaded default P2P configuration");
|
Logger::get().log(Logger::LogType::INFO, "Successfully loaded default P2P configuration");
|
||||||
break;
|
break;
|
||||||
case LoadP2PSettingsInPathResult::FAILED_TO_READ:
|
case LoadP2PSettingsInPathResult::FAILED_TO_READ:
|
||||||
throw std::runtime_error("[NetLibrary::init] Failed to read default_p2p.json");
|
throw std::runtime_error("[NetLibrary::init] Failed to read default_p2p.json");
|
||||||
|
|
@ -119,17 +119,17 @@ void NetLibrary::init_websocket() {
|
||||||
auto wsFuture = wsPromise.get_future();
|
auto wsFuture = wsPromise.get_future();
|
||||||
|
|
||||||
ws->onOpen([]() {
|
ws->onOpen([]() {
|
||||||
Logger::get().log("INFO", "Websocket connected, signaling ready");
|
Logger::get().log(Logger::LogType::INFO, "Websocket connected, signaling ready");
|
||||||
wsPromise.set_value();
|
wsPromise.set_value();
|
||||||
});
|
});
|
||||||
|
|
||||||
ws->onError([](std::string s) {
|
ws->onError([](std::string s) {
|
||||||
Logger::get().log("INFO", "Websocket error: " + s);
|
Logger::get().log(Logger::LogType::INFO, "Websocket error: " + s);
|
||||||
wsPromise.set_exception(std::make_exception_ptr(std::runtime_error(s)));
|
wsPromise.set_exception(std::make_exception_ptr(std::runtime_error(s)));
|
||||||
});
|
});
|
||||||
|
|
||||||
ws->onClosed([]() {
|
ws->onClosed([]() {
|
||||||
Logger::get().log("INFO", "Websocket closed");
|
Logger::get().log(Logger::LogType::INFO, "Websocket closed");
|
||||||
destroy_websocket();
|
destroy_websocket();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ void NetLibrary::init_websocket() {
|
||||||
if(peerIt != peers.end())
|
if(peerIt != peers.end())
|
||||||
peerConnection = peerIt->second->connection;
|
peerConnection = peerIt->second->connection;
|
||||||
else if(type == "offer") {
|
else if(type == "offer") {
|
||||||
Logger::get().log("INFO", "Websocket answering to " + id);
|
Logger::get().log(Logger::LogType::INFO, "Websocket answering to " + id);
|
||||||
auto peer = setup_peer_connection(config, wws, id);
|
auto peer = setup_peer_connection(config, wws, id);
|
||||||
peers[id] = peer;
|
peers[id] = peer;
|
||||||
peerConnection = peer->connection;
|
peerConnection = peer->connection;
|
||||||
|
|
@ -177,15 +177,15 @@ void NetLibrary::init_websocket() {
|
||||||
|
|
||||||
get_global_id();
|
get_global_id();
|
||||||
|
|
||||||
Logger::get().log("INFO", "NetLibrary global id: " + globalID);
|
Logger::get().log(Logger::LogType::INFO, "NetLibrary global id: " + globalID);
|
||||||
|
|
||||||
const std::string wsPrefix = signalingAddr.find("://") == std::string::npos ? "ws://" : "";
|
const std::string wsPrefix = signalingAddr.find("://") == std::string::npos ? "ws://" : "";
|
||||||
const std::string url = wsPrefix + signalingAddr + "/" + globalID;
|
const std::string url = wsPrefix + signalingAddr + "/" + globalID;
|
||||||
|
|
||||||
Logger::get().log("INFO", "Websocket URL is: " + url);
|
Logger::get().log(Logger::LogType::INFO, "Websocket URL is: " + url);
|
||||||
ws->open(url);
|
ws->open(url);
|
||||||
|
|
||||||
Logger::get().log("INFO", "NetLibrary waiting for signaling to be connected...");
|
Logger::get().log(Logger::LogType::INFO, "NetLibrary waiting for signaling to be connected...");
|
||||||
//wsFuture.get();
|
//wsFuture.get();
|
||||||
alreadyInitialized = true;
|
alreadyInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +193,7 @@ void NetLibrary::init_websocket() {
|
||||||
void NetLibrary::copy_default_p2p_config_to_path(const std::filesystem::path& newP2PConfigPath) {
|
void NetLibrary::copy_default_p2p_config_to_path(const std::filesystem::path& newP2PConfigPath) {
|
||||||
try {
|
try {
|
||||||
std::string readLocalP2PConfig = read_file_to_string(newP2PConfigPath); // If it doesnt fail, then file exists, so dont copy p2p config
|
std::string readLocalP2PConfig = read_file_to_string(newP2PConfigPath); // If it doesnt fail, then file exists, so dont copy p2p config
|
||||||
Logger::get().log("INFO", "Local P2P configuration already exists");
|
Logger::get().log(Logger::LogType::INFO, "Local P2P configuration already exists");
|
||||||
return;
|
return;
|
||||||
} catch(...) {}
|
} catch(...) {}
|
||||||
|
|
||||||
|
|
@ -202,11 +202,11 @@ void NetLibrary::copy_default_p2p_config_to_path(const std::filesystem::path& ne
|
||||||
std::stringstream newFileSS;
|
std::stringstream newFileSS;
|
||||||
newFileSS << std::setw(4) << j;
|
newFileSS << std::setw(4) << j;
|
||||||
if(SDL_SaveFile(newP2PConfigPath.string().c_str(), newFileSS.view().data(), newFileSS.view().size()))
|
if(SDL_SaveFile(newP2PConfigPath.string().c_str(), newFileSS.view().data(), newFileSS.view().size()))
|
||||||
Logger::get().log("INFO", "New P2P configuration created");
|
Logger::get().log(Logger::LogType::INFO, "New P2P configuration created");
|
||||||
else
|
else
|
||||||
Logger::get().log("INFO", "[NetLibrary::copy_default_p2p_config_to_path] Could not open new p2p.json to write to");
|
Logger::get().log(Logger::LogType::INFO, "[NetLibrary::copy_default_p2p_config_to_path] Could not open new p2p.json to write to");
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
Logger::get().log("INFO", "[NetLibrary::copy_default_p2p_config_to_path] Could not open default_p2p.json");
|
Logger::get().log(Logger::LogType::INFO, "[NetLibrary::copy_default_p2p_config_to_path] Could not open default_p2p.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ void NetLibrary::finish_client_registration(std::shared_ptr<NetClient> client) {
|
||||||
client->fullyRegistered = true;
|
client->fullyRegistered = true;
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("INFO", "Invalid client registration: " + std::string(e.what()));
|
Logger::get().log(Logger::LogType::INFO, "Invalid client registration: " + std::string(e.what()));
|
||||||
client->isDisconnected = true;
|
client->isDisconnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -282,7 +282,7 @@ void NetLibrary::update() {
|
||||||
if(p->channel->isOpen()) {
|
if(p->channel->isOpen()) {
|
||||||
while(!p->messageQueue.empty()) {
|
while(!p->messageQueue.empty()) {
|
||||||
p->channel->send(p->messageQueue.front());
|
p->channel->send(p->messageQueue.front());
|
||||||
Logger::get().log("INFO", "Sent main channel message: " + p->messageQueue.front());
|
Logger::get().log(Logger::LogType::INFO, "Sent main channel message: " + p->messageQueue.front());
|
||||||
p->messageQueue.pop();
|
p->messageQueue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ std::shared_ptr<NetLibrary::PeerData> NetLibrary::setup_peer_connection(const rt
|
||||||
setup_main_data_channel(peer, id);
|
setup_main_data_channel(peer, id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger::get().log("INFO", "Client connected with incorrect first channel name: " + dc->label() + ". Could be from a different version of the program");
|
Logger::get().log(Logger::LogType::INFO, "Client connected with incorrect first channel name: " + dc->label() + ". Could be from a different version of the program");
|
||||||
dc->send("REFUSE");
|
dc->send("REFUSE");
|
||||||
peer->connection->close();
|
peer->connection->close();
|
||||||
}
|
}
|
||||||
|
|
@ -340,19 +340,19 @@ std::shared_ptr<NetLibrary::PeerData> NetLibrary::setup_peer_connection(const rt
|
||||||
|
|
||||||
void NetLibrary::setup_main_data_channel(std::shared_ptr<PeerData> peer, const std::string& id) {
|
void NetLibrary::setup_main_data_channel(std::shared_ptr<PeerData> peer, const std::string& id) {
|
||||||
peer->channel->onOpen([id]() {
|
peer->channel->onOpen([id]() {
|
||||||
Logger::get().log("INFO", "Main data channel has opened on " + id);
|
Logger::get().log(Logger::LogType::INFO, "Main data channel has opened on " + id);
|
||||||
});
|
});
|
||||||
peer->channel->onClosed([id]() {
|
peer->channel->onClosed([id]() {
|
||||||
Logger::get().log("INFO", "Main data channel has closed on " + id);
|
Logger::get().log(Logger::LogType::INFO, "Main data channel has closed on " + id);
|
||||||
});
|
});
|
||||||
peer->channel->onMessage([id, pConWeak = make_weak_ptr(peer->connection)](auto data) {
|
peer->channel->onMessage([id, pConWeak = make_weak_ptr(peer->connection)](auto data) {
|
||||||
if(!std::holds_alternative<std::string>(data)) { // Main channel messages will only carry text
|
if(!std::holds_alternative<std::string>(data)) { // Main channel messages will only carry text
|
||||||
Logger::get().log("INFO", "Main data channel received binary message, which is not expected");
|
Logger::get().log(Logger::LogType::INFO, "Main data channel received binary message, which is not expected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string message = std::get<std::string>(data);
|
std::string message = std::get<std::string>(data);
|
||||||
if(message == "REFUSE") {
|
if(message == "REFUSE") {
|
||||||
Logger::get().log("USERINFO", "Refused connection. Could be on a different version");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Refused connection. Could be on a different version");
|
||||||
auto pConLock = pConWeak.lock();
|
auto pConLock = pConWeak.lock();
|
||||||
if(pConLock)
|
if(pConLock)
|
||||||
pConLock->close();
|
pConLock->close();
|
||||||
|
|
@ -360,7 +360,7 @@ void NetLibrary::setup_main_data_channel(std::shared_ptr<PeerData> peer, const s
|
||||||
else {
|
else {
|
||||||
std::string clientLocalID = message.substr(0, LOCALID_LEN);
|
std::string clientLocalID = message.substr(0, LOCALID_LEN);
|
||||||
std::string serverLocalID = message.substr(LOCALID_LEN);
|
std::string serverLocalID = message.substr(LOCALID_LEN);
|
||||||
Logger::get().log("INFO", "Main data channel received message " + message);
|
Logger::get().log(Logger::LogType::INFO, "Main data channel received message " + message);
|
||||||
auto pConLock = pConWeak.lock();
|
auto pConLock = pConWeak.lock();
|
||||||
if(pConLock)
|
if(pConLock)
|
||||||
assign_client_connection_to_server(serverLocalID, clientLocalID, pConLock);
|
assign_client_connection_to_server(serverLocalID, clientLocalID, pConLock);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
NetServer::NetServer(const std::string& serverLocalID) {
|
NetServer::NetServer(const std::string& serverLocalID) {
|
||||||
localID = serverLocalID;
|
localID = serverLocalID;
|
||||||
Logger::get().log("INFO", "[NetServer::NetServer] Server has local id: " + serverLocalID);
|
Logger::get().log(Logger::LogType::INFO, "[NetServer::NetServer] Server has local id: " + serverLocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetServer::update() {
|
void NetServer::update() {
|
||||||
|
|
@ -39,7 +39,7 @@ void NetServer::update() {
|
||||||
bool timedOut = std::chrono::steady_clock::now() - client->lastMessageTime > NetLibrary::TIMEOUT_DURATION;
|
bool timedOut = std::chrono::steady_clock::now() - client->lastMessageTime > NetLibrary::TIMEOUT_DURATION;
|
||||||
if(timedOut) {
|
if(timedOut) {
|
||||||
client->setToDisconnect = true;
|
client->setToDisconnect = true;
|
||||||
Logger::get().log("INFO", "Connection timed out");
|
Logger::get().log(Logger::LogType::INFO, "Connection timed out");
|
||||||
}
|
}
|
||||||
if(client->setToDisconnect)
|
if(client->setToDisconnect)
|
||||||
disconnectCallback(client);
|
disconnectCallback(client);
|
||||||
|
|
@ -52,12 +52,12 @@ void NetServer::update() {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("INFO", "[NetServer::update] Exception thrown while parsing and sending messages for a client: " + std::string(e.what()));
|
Logger::get().log(Logger::LogType::INFO, "[NetServer::update] Exception thrown while parsing and sending messages for a client: " + std::string(e.what()));
|
||||||
client->setToDisconnect = true;
|
client->setToDisconnect = true;
|
||||||
disconnectCallback(client);
|
disconnectCallback(client);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
Logger::get().log("INFO", "[NetServer::update] Unknown exception thrown while parsing and sending messages for a client.");
|
Logger::get().log(Logger::LogType::INFO, "[NetServer::update] Unknown exception thrown while parsing and sending messages for a client.");
|
||||||
client->setToDisconnect = true;
|
client->setToDisconnect = true;
|
||||||
disconnectCallback(client);
|
disconnectCallback(client);
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ void NetServer::client_connected(std::shared_ptr<rtc::PeerConnection> connection
|
||||||
clientsToAdd.emplace_back(newClient);
|
clientsToAdd.emplace_back(newClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::get().log("INFO", "Client connected and creating channels for: " + clientLocalID);
|
Logger::get().log(Logger::LogType::INFO, "Client connected and creating channels for: " + clientLocalID);
|
||||||
newClient->channels.emplace(RELIABLE_COMMAND_CHANNEL, connection->createDataChannel(clientLocalID + RELIABLE_COMMAND_CHANNEL));
|
newClient->channels.emplace(RELIABLE_COMMAND_CHANNEL, connection->createDataChannel(clientLocalID + RELIABLE_COMMAND_CHANNEL));
|
||||||
newClient->channels.emplace(RESOURCE_COMMAND_CHANNEL, connection->createDataChannel(clientLocalID + RESOURCE_COMMAND_CHANNEL));
|
newClient->channels.emplace(RESOURCE_COMMAND_CHANNEL, connection->createDataChannel(clientLocalID + RESOURCE_COMMAND_CHANNEL));
|
||||||
rtc::DataChannelInit unreliableCommandInit;
|
rtc::DataChannelInit unreliableCommandInit;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace AndroidJNICalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
void startNetworkService() {
|
void startNetworkService() {
|
||||||
Logger::get().log("INFO", "[AndroidJNICalls::startNetworkService] Start service");
|
Logger::get().log(Logger::LogType::INFO, "[AndroidJNICalls::startNetworkService] Start service");
|
||||||
JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
|
JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
|
||||||
jobject activity = (jobject)SDL_GetAndroidActivity();
|
jobject activity = (jobject)SDL_GetAndroidActivity();
|
||||||
jclass clazz = env->GetObjectClass(activity);
|
jclass clazz = env->GetObjectClass(activity);
|
||||||
|
|
@ -108,7 +108,7 @@ namespace AndroidJNICalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopNetworkService() {
|
void stopNetworkService() {
|
||||||
Logger::get().log("INFO", "[AndroidJNICalls::stopNetworkService] Stop service");
|
Logger::get().log(Logger::LogType::INFO, "[AndroidJNICalls::stopNetworkService] Stop service");
|
||||||
JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
|
JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
|
||||||
jobject activity = (jobject)SDL_GetAndroidActivity();
|
jobject activity = (jobject)SDL_GetAndroidActivity();
|
||||||
jclass clazz = env->GetObjectClass(activity);
|
jclass clazz = env->GetObjectClass(activity);
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ void ClientData::draw_cursor(SkCanvas* canvas, const DrawData& drawData) const {
|
||||||
skia::textlayout::ParagraphStyle pStyle;
|
skia::textlayout::ParagraphStyle pStyle;
|
||||||
pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
||||||
skia::textlayout::TextStyle tStyle;
|
skia::textlayout::TextStyle tStyle;
|
||||||
tStyle.setFontSize(18.0f);
|
tStyle.setFontSize(18.0f * drawData.main->g.final_gui_scale());
|
||||||
tStyle.setFontFamilies(drawData.main->g.gui.io.fonts->get_default_font_families());
|
tStyle.setFontFamilies(drawData.main->g.gui.io.fonts->get_default_font_families());
|
||||||
tStyle.setForegroundPaint(SkPaint{SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f}});
|
tStyle.setForegroundPaint(SkPaint{SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f}});
|
||||||
pStyle.setTextStyle(tStyle);
|
pStyle.setTextStyle(tStyle);
|
||||||
|
|
|
||||||
|
|
@ -680,7 +680,7 @@ void DrawingProgram::update_downloading_dropped_files() {
|
||||||
NetworkingObjects::NetObjID imageID = world.rMan.add_resource(newResource).get_net_id();
|
NetworkingObjects::NetObjID imageID = world.rMan.add_resource(newResource).get_net_id();
|
||||||
ResourceDisplay* display = world.rMan.get_display_data(imageID);
|
ResourceDisplay* display = world.rMan.get_display_data(imageID);
|
||||||
if(display->get_type() == ResourceDisplay::Type::FILE) {
|
if(display->get_type() == ResourceDisplay::Type::FILE) {
|
||||||
Logger::get().log("WORLDFATAL", "Failed to parse image from URL");
|
Logger::get().log(Logger::LogType::WORLDFATAL, "Failed to parse image from URL");
|
||||||
auto& parentLayerComponents = downFile.comp->obj->parentLayer->get_layer().components;
|
auto& parentLayerComponents = downFile.comp->obj->parentLayer->get_layer().components;
|
||||||
parentLayerComponents->erase(parentLayerComponents, downFile.comp->obj->objInfo);
|
parentLayerComponents->erase(parentLayerComponents, downFile.comp->obj->objInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -699,7 +699,7 @@ void DrawingProgram::update_downloading_dropped_files() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case FileDownloader::DownloadData::Status::FAILURE: {
|
case FileDownloader::DownloadData::Status::FAILURE: {
|
||||||
Logger::get().log("WORLDFATAL", "Failed to download data from URL");
|
Logger::get().log(Logger::LogType::WORLDFATAL, "Failed to download data from URL");
|
||||||
auto& parentLayerComponents = downFile.comp->obj->parentLayer->get_layer().components;
|
auto& parentLayerComponents = downFile.comp->obj->parentLayer->get_layer().components;
|
||||||
parentLayerComponents->erase(parentLayerComponents, downFile.comp->obj->objInfo);
|
parentLayerComponents->erase(parentLayerComponents, downFile.comp->obj->objInfo);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -769,7 +769,7 @@ void DrawingProgramSelection::paste_clipboard(Vector2f pasteScreenPos) {
|
||||||
WorldScalar scaleLimit(0.001);
|
WorldScalar scaleLimit(0.001);
|
||||||
for(auto& c : drawP.world.main.clipboard.components) {
|
for(auto& c : drawP.world.main.clipboard.components) {
|
||||||
if((c->coords.inverseScale / scaleMultiplier) < scaleLimit) {
|
if((c->coords.inverseScale / scaleMultiplier) < scaleLimit) {
|
||||||
Logger::get().log("WORLDFATAL", "Some pasted objects will be too small! Scale up the canvas first (zoom in alot)");
|
Logger::get().log(Logger::LogType::WORLDFATAL, "Some pasted objects will be too small! Scale up the canvas first (zoom in alot)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ void DrawingProgramLayer::erase_invalid_components() {
|
||||||
compsToErase.emplace_back(it);
|
compsToErase.emplace_back(it);
|
||||||
}
|
}
|
||||||
if(!compsToErase.empty()) {
|
if(!compsToErase.empty()) {
|
||||||
Logger::get().log("INFO", "[DrawingProgramLayer::erase_invalid_components] Erased " + std::to_string(compsToErase.size()) + " invalid component(s) from layer");
|
Logger::get().log(Logger::LogType::INFO, "[DrawingProgramLayer::erase_invalid_components] Erased " + std::to_string(compsToErase.size()) + " invalid component(s) from layer");
|
||||||
components->erase_list(components, compsToErase);
|
components->erase_list(components, compsToErase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,10 @@ void ToolConfiguration::print_relative_width_fail_message(RelativeWidthFailCode
|
||||||
case RelativeWidthFailCode::SUCCESS:
|
case RelativeWidthFailCode::SUCCESS:
|
||||||
break;
|
break;
|
||||||
case RelativeWidthFailCode::TOO_ZOOMED_IN:
|
case RelativeWidthFailCode::TOO_ZOOMED_IN:
|
||||||
Logger::get().log("USERINFO", "Zoomed in too much! Unlock size or zoom out");
|
Logger::get().log(Logger::LogType::USERINFO, "Zoomed in too much! Unlock size or zoom out");
|
||||||
break;
|
break;
|
||||||
case RelativeWidthFailCode::TOO_ZOOMED_OUT:
|
case RelativeWidthFailCode::TOO_ZOOMED_OUT:
|
||||||
Logger::get().log("USERINFO", "Zoomed out too much! Unlock size or zoom in");
|
Logger::get().log(Logger::LogType::USERINFO, "Zoomed out too much! Unlock size or zoom in");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <include/core/SkPathBuilder.h>
|
#include <include/core/SkPathBuilder.h>
|
||||||
|
|
||||||
#include "../../GridManager.hpp"
|
#include "../../GridManager.hpp"
|
||||||
#include <Helpers/Logger.hpp>
|
|
||||||
|
|
||||||
#include "../../MainProgram.hpp"
|
#include "../../MainProgram.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -287,10 +287,8 @@ template <typename T> bool TextBox<T>::update_data() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> TextBox<T>::~TextBox() {
|
template <typename T> TextBox<T>::~TextBox() {
|
||||||
if(is_selected()) {
|
if(is_selected())
|
||||||
Logger::get().log("INFO", "Destroy");
|
|
||||||
CustomEvents::emit_event(CustomEvents::RefreshTextBoxInputEvent{});
|
CustomEvents::emit_event(CustomEvents::RefreshTextBoxInputEvent{});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -621,7 +621,7 @@ void GUIManager::single_layout_run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIManager::clay_error_handler(Clay_ErrorData errorData) {
|
void GUIManager::clay_error_handler(Clay_ErrorData errorData) {
|
||||||
Logger::get().log("INFO", "[Clay Error] " + std::string(errorData.errorText.chars));
|
Logger::get().log(Logger::LogType::INFO, "[Clay Error] " + std::string(errorData.errorText.chars));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIManager::in_dynamic_area(const std::function<void()>& f) {
|
void GUIManager::in_dynamic_area(const std::function<void()>& f) {
|
||||||
|
|
|
||||||
|
|
@ -265,10 +265,10 @@ void InputManager::get_clipboard_image_data_SDL(const std::function<void(std::st
|
||||||
throw std::runtime_error("Bitmap format is unsupported");
|
throw std::runtime_error("Bitmap format is unsupported");
|
||||||
}
|
}
|
||||||
catch(const std::runtime_error& e) {
|
catch(const std::runtime_error& e) {
|
||||||
Logger::get().log("INFO", std::string("[InputManager::get_clipboard_image_data_SDL] Error thrown: ") + e.what());
|
Logger::get().log(Logger::LogType::INFO, std::string("[InputManager::get_clipboard_image_data_SDL] Error thrown: ") + e.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
Logger::get().log("INFO", "[InputManager::get_clipboard_image_data_SDL] Unknown error thrown");
|
Logger::get().log(Logger::LogType::INFO, "[InputManager::get_clipboard_image_data_SDL] Unknown error thrown");
|
||||||
}
|
}
|
||||||
if(!result.empty())
|
if(!result.empty())
|
||||||
callback(std::string_view((char*)(result.data()), result.size())); // This part of the code should throw errors
|
callback(std::string_view((char*)(result.data()), result.size())); // This part of the code should throw errors
|
||||||
|
|
|
||||||
|
|
@ -61,25 +61,43 @@ MainProgram::MainProgram():
|
||||||
screen->gui_layout_run();
|
screen->gui_layout_run();
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger::get().add_log("WORLDFATAL", [&](const std::string& text) {
|
Logger::get().set_log_function(Logger::LogType::WORLDFATAL, [&](const std::string& text) {
|
||||||
*logFile << "[WORLDFATAL] " << text << std::endl;
|
*logFile << "[WORLDFATAL] " << text << std::endl;
|
||||||
std::cout << "[WORLDFATAL] " << text << std::endl;
|
std::cout << "[WORLDFATAL] " << text << std::endl;
|
||||||
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_ERROR});
|
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_ERROR, UserLogMessage::DISPLAY_DESKTOP_ONLY});
|
||||||
if(logMessages.size() == LOG_SIZE)
|
if(logMessages.size() == LOG_SIZE)
|
||||||
logMessages.pop_back();
|
logMessages.pop_back();
|
||||||
g.gui.set_to_layout();
|
g.gui.set_to_layout();
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger::get().add_log("USERINFO", [&](const std::string& text) {
|
Logger::get().set_log_function(Logger::LogType::USERINFO, [&](const std::string& text) {
|
||||||
*logFile << "[USERINFO] " << text << std::endl;
|
*logFile << "[USERINFO] " << text << std::endl;
|
||||||
std::cout << "[USERINFO] " << text << std::endl;
|
std::cout << "[USERINFO] " << text << std::endl;
|
||||||
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_NORMAL});
|
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_NORMAL, UserLogMessage::DISPLAY_FOR_ALL});
|
||||||
if(logMessages.size() == LOG_SIZE)
|
if(logMessages.size() == LOG_SIZE)
|
||||||
logMessages.pop_back();
|
logMessages.pop_back();
|
||||||
g.gui.set_to_layout();
|
g.gui.set_to_layout();
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger::get().add_log("CHAT", [&](const std::string& text) {
|
Logger::get().set_log_function(Logger::LogType::DESKTOP_USERINFO, [&](const std::string& text) {
|
||||||
|
*logFile << "[DESKTOP_USERINFO] " << text << std::endl;
|
||||||
|
std::cout << "[DESKTOP_USERINFO] " << text << std::endl;
|
||||||
|
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_NORMAL, UserLogMessage::DISPLAY_DESKTOP_ONLY});
|
||||||
|
if(logMessages.size() == LOG_SIZE)
|
||||||
|
logMessages.pop_back();
|
||||||
|
g.gui.set_to_layout();
|
||||||
|
});
|
||||||
|
|
||||||
|
Logger::get().set_log_function(Logger::LogType::PHONE_USERINFO, [&](const std::string& text) {
|
||||||
|
*logFile << "[PHONE_USERINFO] " << text << std::endl;
|
||||||
|
std::cout << "[PHONE_USERINFO] " << text << std::endl;
|
||||||
|
logMessages.emplace_front(UserLogMessage{text, UserLogMessage::COLOR_NORMAL, UserLogMessage::DISPLAY_PHONE_ONLY});
|
||||||
|
if(logMessages.size() == LOG_SIZE)
|
||||||
|
logMessages.pop_back();
|
||||||
|
g.gui.set_to_layout();
|
||||||
|
});
|
||||||
|
|
||||||
|
Logger::get().set_log_function(Logger::LogType::CHAT, [&](const std::string& text) {
|
||||||
*logFile << "[CHAT] " << text << std::endl;
|
*logFile << "[CHAT] " << text << std::endl;
|
||||||
std::cout << "[CHAT] " << text << std::endl;
|
std::cout << "[CHAT] " << text << std::endl;
|
||||||
});
|
});
|
||||||
|
|
@ -198,9 +216,9 @@ void MainProgram::load_config() {
|
||||||
|
|
||||||
void MainProgram::set_vsync_value(int vsyncValue) {
|
void MainProgram::set_vsync_value(int vsyncValue) {
|
||||||
if(!SDL_GL_SetSwapInterval(vsyncValue)) {
|
if(!SDL_GL_SetSwapInterval(vsyncValue)) {
|
||||||
Logger::get().log("INFO", "Vsync value " + std::to_string(vsyncValue) + " not available. Setting to 1");
|
Logger::get().log(Logger::LogType::INFO, "Vsync value " + std::to_string(vsyncValue) + " not available. Setting to 1");
|
||||||
if(vsyncValue == -1) {
|
if(vsyncValue == -1) {
|
||||||
Logger::get().log("USERINFO", "Adaptive VSync not available. Setting Vsync to On");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Adaptive VSync not available. Setting Vsync to On");
|
||||||
vsyncValue = 1;
|
vsyncValue = 1;
|
||||||
}
|
}
|
||||||
SDL_GL_SetSwapInterval(1);
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
|
@ -272,7 +290,7 @@ void MainProgram::create_new_tab(const CustomEvents::OpenInfiniPaintFileEvent& o
|
||||||
newWorld = std::make_shared<World>(*this, openFile);
|
newWorld = std::make_shared<World>(*this, openFile);
|
||||||
}
|
}
|
||||||
catch(const std::runtime_error& e) {
|
catch(const std::runtime_error& e) {
|
||||||
Logger::get().log("WORLDFATAL", "Failed to open canvas: " + (openFile.filePathSource.has_value() ? openFile.filePathSource.value().string() : "NO PATH") + " with error: " + e.what());
|
Logger::get().log(Logger::LogType::WORLDFATAL, "Failed to open canvas: " + (openFile.filePathSource.has_value() ? openFile.filePathSource.value().string() : "NO PATH") + " with error: " + e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
worlds.emplace_back(newWorld);
|
worlds.emplace_back(newWorld);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ struct UserLogMessage {
|
||||||
COLOR_NORMAL = 0,
|
COLOR_NORMAL = 0,
|
||||||
COLOR_ERROR
|
COLOR_ERROR
|
||||||
} color;
|
} color;
|
||||||
|
enum {
|
||||||
|
DISPLAY_FOR_ALL,
|
||||||
|
DISPLAY_PHONE_ONLY,
|
||||||
|
DISPLAY_DESKTOP_ONLY
|
||||||
|
} whereToDisplay = DISPLAY_DESKTOP_ONLY;
|
||||||
TimePoint time;
|
TimePoint time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ void NetThreadManager::synchronous_update() {
|
||||||
void NetThreadManager::init_thread() {
|
void NetThreadManager::init_thread() {
|
||||||
if(t)
|
if(t)
|
||||||
throw std::runtime_error("[NetThreadManager::init_thread] Thread can't exist when init_thread is called");
|
throw std::runtime_error("[NetThreadManager::init_thread] Thread can't exist when init_thread is called");
|
||||||
Logger::get().log("INFO", "[NetThreadManager::init_thread] Starting network thread");
|
Logger::get().log(Logger::LogType::INFO, "[NetThreadManager::init_thread] Starting network thread");
|
||||||
destroyThread = false;
|
destroyThread = false;
|
||||||
t = std::make_unique<std::thread>([&]{ thread_update(); });
|
t = std::make_unique<std::thread>([&]{ thread_update(); });
|
||||||
}
|
}
|
||||||
|
|
@ -77,8 +77,8 @@ void NetThreadManager::thread_update() {
|
||||||
|
|
||||||
void NetThreadManager::destroy_thread() {
|
void NetThreadManager::destroy_thread() {
|
||||||
if(!t)
|
if(!t)
|
||||||
throw std::runtime_error("[NetThreadManager::init_thread] Thread can't be null when destroy_thread is called");
|
throw std::runtime_error("[NetThreadManager::destroy_thread] Thread can't be null when destroy_thread is called");
|
||||||
Logger::get().log("INFO", "[NetThreadManager::destroy_thread] Stopping network thread");
|
Logger::get().log(Logger::LogType::INFO, "[NetThreadManager::destroy_thread] Stopping network thread");
|
||||||
destroyThread = true;
|
destroyThread = true;
|
||||||
t->join();
|
t->join();
|
||||||
t = nullptr;
|
t = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ bool ImageResourceDisplay::load(ResourceManager& rMan, const std::string& fileNa
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rotate) {
|
if(rotate) {
|
||||||
Logger::get().log("INFO", "Image loaded is rotated, so must rotate dimensions");
|
Logger::get().log(Logger::LogType::INFO, "Image loaded is rotated, so must rotate dimensions");
|
||||||
imageInfo = imageInfo.makeDimensions(SkISize(imageInfo.height(), imageInfo.width()));
|
imageInfo = imageInfo.makeDimensions(SkISize(imageInfo.height(), imageInfo.width()));
|
||||||
}
|
}
|
||||||
codec = nullptr;
|
codec = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -114,11 +114,11 @@ NetworkingObjects::NetObjTemporaryPtr<ResourceData> ResourceManager::add_resourc
|
||||||
*resource.data = read_file_to_string(filePath);
|
*resource.data = read_file_to_string(filePath);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
Logger::get().log("INFO", "[ResourceManager::add_resource_file] Could not open file " + filePath.string());
|
Logger::get().log(Logger::LogType::INFO, "[ResourceManager::add_resource_file] Could not open file " + filePath.string());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::get().log("INFO", "[ResourceManager::add_resource_file] Successfully read file " + filePath.string());
|
Logger::get().log(Logger::LogType::INFO, "[ResourceManager::add_resource_file] Successfully read file " + filePath.string());
|
||||||
|
|
||||||
return add_resource(resource);
|
return add_resource(resource);
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ const NetworkingObjects::NetObjOwnerPtr<ResourceData>& ResourceManager::add_reso
|
||||||
return p->data == resource.data || (*p->data) == (*resource.data);
|
return p->data == resource.data || (*p->data) == (*resource.data);
|
||||||
});
|
});
|
||||||
if(it != resourceList.end()) {
|
if(it != resourceList.end()) {
|
||||||
Logger::get().log("INFO", "[ResourceManager::add_resource] File " + std::string(resource.name) + " is a duplicate");
|
Logger::get().log(Logger::LogType::INFO, "[ResourceManager::add_resource] File " + std::string(resource.name) + " is a duplicate");
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
auto& resourceInsert = resourceList.emplace_back(world.netObjMan.make_obj_direct<ResourceData>(resource));
|
auto& resourceInsert = resourceList.emplace_back(world.netObjMan.make_obj_direct<ResourceData>(resource));
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ void FileSelectScreen::update_file_list(std::vector<FileInfo>& fL, const std::fi
|
||||||
if(daysSinceMovedToTrash >= DAYS_TO_DELETION) {
|
if(daysSinceMovedToTrash >= DAYS_TO_DELETION) {
|
||||||
// Remove file and thumbnail
|
// Remove file and thumbnail
|
||||||
std::filesystem::path thumbnailPath = folderPath / (fileInfoToAdd.fileName + ".jpg");
|
std::filesystem::path thumbnailPath = folderPath / (fileInfoToAdd.fileName + ".jpg");
|
||||||
Logger::get().log("INFO", "Deleting file in trash: " + fullPath.string() + " with thumbnail: " + thumbnailPath.string());
|
Logger::get().log(Logger::LogType::INFO, "Deleting file in trash: " + fullPath.string() + " with thumbnail: " + thumbnailPath.string());
|
||||||
SDL_RemovePath(fullPath.string().c_str());
|
SDL_RemovePath(fullPath.string().c_str());
|
||||||
SDL_RemovePath(thumbnailPath.string().c_str());
|
SDL_RemovePath(thumbnailPath.string().c_str());
|
||||||
saveInfo.trash.files.erase(it);
|
saveInfo.trash.files.erase(it);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,14 @@ PhoneDrawingProgramScreen::PhoneDrawingProgramScreen(MainProgram& m):
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void PhoneDrawingProgramScreen::update() {
|
void PhoneDrawingProgramScreen::update() {
|
||||||
|
std::erase_if(main.logMessages, [&](auto& logM) {
|
||||||
|
logM.time.update_time_since();
|
||||||
|
if(logM.time > UserLogMessage::FADE_START_TIME) {
|
||||||
|
main.g.gui.set_to_layout();
|
||||||
|
return logM.time >= UserLogMessage::DISPLAY_TIME;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
DrawingProgramScreen::update();
|
DrawingProgramScreen::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,6 +360,63 @@ void PhoneDrawingProgramScreen::top_toolbar_settings_popup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhoneDrawingProgramScreen::global_log() {
|
||||||
|
auto& gui = main.g.gui;
|
||||||
|
auto& io = gui.io;
|
||||||
|
|
||||||
|
float notificationSize = std::min(300.0f, gui.io.safeWindowRect.width() - 20.0f);
|
||||||
|
|
||||||
|
gui.new_id("Global log popup list", [&] {
|
||||||
|
CLAY_AUTO_ID({
|
||||||
|
.layout = {
|
||||||
|
.sizing = {.width = CLAY_SIZING_FIXED(notificationSize), .height = CLAY_SIZING_FIT(0) },
|
||||||
|
.childGap = io.theme->childGap1,
|
||||||
|
.childAlignment = { .x = CLAY_ALIGN_X_RIGHT, .y = CLAY_ALIGN_Y_TOP},
|
||||||
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||||
|
},
|
||||||
|
.floating = {.offset = {0, 10}, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_BOTTOM}, .attachTo = CLAY_ATTACH_TO_PARENT}
|
||||||
|
}) {
|
||||||
|
for(size_t i = 0; i < main.logMessages.size(); i++) {
|
||||||
|
auto& logM = main.logMessages[i];
|
||||||
|
logM.time.update_time_since();
|
||||||
|
if(logM.time < UserLogMessage::DISPLAY_TIME) {
|
||||||
|
if(logM.whereToDisplay == UserLogMessage::DISPLAY_DESKTOP_ONLY)
|
||||||
|
continue;
|
||||||
|
float a = 1.0f - lerp_time<float>(logM.time, UserLogMessage::DISPLAY_TIME, UserLogMessage::FADE_START_TIME);
|
||||||
|
gui.new_id(i, [&] {
|
||||||
|
gui.element<LayoutElement>("Global log message", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||||
|
CLAY(lId, {
|
||||||
|
.layout = {
|
||||||
|
.sizing = {.width = CLAY_SIZING_FIT(notificationSize), .height = CLAY_SIZING_FIT(0) },
|
||||||
|
.padding = CLAY_PADDING_ALL(io.theme->padding1),
|
||||||
|
.childGap = 0,
|
||||||
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP},
|
||||||
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||||
|
},
|
||||||
|
.backgroundColor = convert_vec4<Clay_Color>(color_mul_alpha(io.theme->backColor1, a)),
|
||||||
|
.cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1)
|
||||||
|
}) {
|
||||||
|
SkColor4f c{0, 0, 0, 0};
|
||||||
|
switch(logM.color) {
|
||||||
|
case UserLogMessage::COLOR_NORMAL:
|
||||||
|
c = io.theme->frontColor1;
|
||||||
|
break;
|
||||||
|
case UserLogMessage::COLOR_ERROR:
|
||||||
|
c = io.theme->errorColor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
text_label_color(gui, logM.text, color_mul_alpha(c, a));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void PhoneDrawingProgramScreen::top_toolbar() {
|
void PhoneDrawingProgramScreen::top_toolbar() {
|
||||||
auto& gui = main.g.gui;
|
auto& gui = main.g.gui;
|
||||||
auto& io = gui.io;
|
auto& io = gui.io;
|
||||||
|
|
@ -381,6 +446,7 @@ void PhoneDrawingProgramScreen::top_toolbar() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
top_toolbar_remaining_area();
|
top_toolbar_remaining_area();
|
||||||
|
global_log();
|
||||||
top_toolbar_settings_popup();
|
top_toolbar_settings_popup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ class PhoneDrawingProgramScreen : public DrawingProgramScreen {
|
||||||
Vector4f* colorPickerPtr = nullptr;
|
Vector4f* colorPickerPtr = nullptr;
|
||||||
ColorSelectorData colorPickerData;
|
ColorSelectorData colorPickerData;
|
||||||
|
|
||||||
|
void global_log();
|
||||||
void gui_layout_safety_checks();
|
void gui_layout_safety_checks();
|
||||||
void hidden_gui();
|
void hidden_gui();
|
||||||
void center_message(const char* id, const std::string& m);
|
void center_message(const char* id, const std::string& m);
|
||||||
|
|
|
||||||
|
|
@ -689,23 +689,23 @@ void Toolbar::update_notification_check() {
|
||||||
VersionNumber& newV = newVersion.value();
|
VersionNumber& newV = newVersion.value();
|
||||||
VersionNumber& currentV = currentVersion.value();
|
VersionNumber& currentV = currentVersion.value();
|
||||||
updateCheckerData.newVersionStr = version_numbers_to_version_str(newV);
|
updateCheckerData.newVersionStr = version_numbers_to_version_str(newV);
|
||||||
Logger::get().log("INFO", "Latest online version is v" + updateCheckerData.newVersionStr);
|
Logger::get().log(Logger::LogType::INFO, "Latest online version is v" + updateCheckerData.newVersionStr);
|
||||||
if(newV > currentV) {
|
if(newV > currentV) {
|
||||||
updateCheckerData.showGui = true;
|
updateCheckerData.showGui = true;
|
||||||
main.g.gui.set_to_layout();
|
main.g.gui.set_to_layout();
|
||||||
}
|
}
|
||||||
else if(newV == currentV)
|
else if(newV == currentV)
|
||||||
Logger::get().log("INFO", "Current version is up to date");
|
Logger::get().log(Logger::LogType::INFO, "Current version is up to date");
|
||||||
else
|
else
|
||||||
Logger::get().log("INFO", "Local version has larger version number than the latest online one");
|
Logger::get().log(Logger::LogType::INFO, "Local version has larger version number than the latest online one");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Logger::get().log("INFO", "Update notification file couldn't be converted to version numbers");
|
Logger::get().log(Logger::LogType::INFO, "Update notification file couldn't be converted to version numbers");
|
||||||
updateCheckerData.versionFile = nullptr;
|
updateCheckerData.versionFile = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileDownloader::DownloadData::Status::FAILURE:
|
case FileDownloader::DownloadData::Status::FAILURE:
|
||||||
Logger::get().log("INFO", "Failed to check for updates");
|
Logger::get().log(Logger::LogType::INFO, "Failed to check for updates");
|
||||||
updateCheckerData.updateCheckDone = true;
|
updateCheckerData.updateCheckDone = true;
|
||||||
updateCheckerData.versionFile = nullptr;
|
updateCheckerData.versionFile = nullptr;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1013,6 +1013,8 @@ void Toolbar::global_log() {
|
||||||
auto& logM = main.logMessages[i];
|
auto& logM = main.logMessages[i];
|
||||||
logM.time.update_time_since();
|
logM.time.update_time_since();
|
||||||
if(logM.time < UserLogMessage::DISPLAY_TIME) {
|
if(logM.time < UserLogMessage::DISPLAY_TIME) {
|
||||||
|
if(logM.whereToDisplay == UserLogMessage::DISPLAY_PHONE_ONLY)
|
||||||
|
continue;
|
||||||
float a = 1.0f - lerp_time<float>(logM.time, UserLogMessage::DISPLAY_TIME, UserLogMessage::FADE_START_TIME);
|
float a = 1.0f - lerp_time<float>(logM.time, UserLogMessage::DISPLAY_TIME, UserLogMessage::FADE_START_TIME);
|
||||||
gui.new_id(i, [&] {
|
gui.new_id(i, [&] {
|
||||||
gui.element<LayoutElement>("Global log message", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
gui.element<LayoutElement>("Global log message", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||||
|
|
@ -1393,9 +1395,9 @@ void Toolbar::options_menu() {
|
||||||
left_to_right_line_layout(gui, [&]() {
|
left_to_right_line_layout(gui, [&]() {
|
||||||
text_button_wide("connect", "Connect", [&] {
|
text_button_wide("connect", "Connect", [&] {
|
||||||
if(serverToConnectTo.length() != (NetLibrary::LOCALID_LEN + NetLibrary::GLOBALID_LEN))
|
if(serverToConnectTo.length() != (NetLibrary::LOCALID_LEN + NetLibrary::GLOBALID_LEN))
|
||||||
Logger::get().log("USERINFO", "Connect issue: Incorrect address length");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Connect issue: Incorrect address length");
|
||||||
else if(serverToConnectTo.substr(0, NetLibrary::GLOBALID_LEN) == NetLibrary::get_global_id())
|
else if(serverToConnectTo.substr(0, NetLibrary::GLOBALID_LEN) == NetLibrary::get_global_id())
|
||||||
Logger::get().log("USERINFO", "Connect issue: Can't connect to your own address");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Connect issue: Can't connect to your own address");
|
||||||
else {
|
else {
|
||||||
CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
|
CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
|
||||||
.isClient = true,
|
.isClient = true,
|
||||||
|
|
@ -1842,7 +1844,7 @@ void Toolbar::file_picker_gui_refresh_entries() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("INFO", e.what());
|
Logger::get().log(Logger::LogType::INFO, e.what());
|
||||||
if(main.conf.currentSearchPath == main.homePath) // The home path must exist. If we get errors on the home path, we have a real problem
|
if(main.conf.currentSearchPath == main.homePath) // The home path must exist. If we get errors on the home path, we have a real problem
|
||||||
throw e;
|
throw e;
|
||||||
main.conf.currentSearchPath = main.homePath;
|
main.conf.currentSearchPath = main.homePath;
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,11 @@ Vector3f World::get_random_cursor_color() {
|
||||||
void World::init_client_data_list_callbacks() {
|
void World::init_client_data_list_callbacks() {
|
||||||
clients->set_insert_callback([&](const NetworkingObjects::NetObjOwnerPtr<ClientData>& objPtr) {
|
clients->set_insert_callback([&](const NetworkingObjects::NetObjOwnerPtr<ClientData>& objPtr) {
|
||||||
add_chat_message(objPtr->get_display_name(), "joined", Toolbar::ChatMessage::Type::JOIN);
|
add_chat_message(objPtr->get_display_name(), "joined", Toolbar::ChatMessage::Type::JOIN);
|
||||||
|
Logger::get().log(Logger::LogType::PHONE_USERINFO, objPtr->get_display_name() + " joined");
|
||||||
});
|
});
|
||||||
clients->set_erase_callback([&](const NetworkingObjects::NetObjOwnerPtr<ClientData>& objPtr) {
|
clients->set_erase_callback([&](const NetworkingObjects::NetObjOwnerPtr<ClientData>& objPtr) {
|
||||||
add_chat_message(objPtr->get_display_name(), "left", Toolbar::ChatMessage::Type::JOIN);
|
add_chat_message(objPtr->get_display_name(), "left", Toolbar::ChatMessage::Type::JOIN);
|
||||||
|
Logger::get().log(Logger::LogType::PHONE_USERINFO, objPtr->get_display_name() + " left");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +211,7 @@ void World::focus_update() {
|
||||||
bool World::connection_update() {
|
bool World::connection_update() {
|
||||||
if(netServer) {
|
if(netServer) {
|
||||||
if(netServer->is_disconnected()) {
|
if(netServer->is_disconnected()) {
|
||||||
Logger::get().log("USERINFO", "Host connection failed");
|
Logger::get().log(Logger::LogType::USERINFO, "Host connection failed");
|
||||||
netSource.clear();
|
netSource.clear();
|
||||||
netServer = nullptr;
|
netServer = nullptr;
|
||||||
netObjMan.disconnect();
|
netObjMan.disconnect();
|
||||||
|
|
@ -224,7 +226,7 @@ bool World::connection_update() {
|
||||||
}
|
}
|
||||||
else if(netClient) {
|
else if(netClient) {
|
||||||
if(netClient->is_disconnected()) {
|
if(netClient->is_disconnected()) {
|
||||||
Logger::get().log("USERINFO", "Client connection failed");
|
Logger::get().log(Logger::LogType::USERINFO, "Client connection failed");
|
||||||
netObjMan.disconnect();
|
netObjMan.disconnect();
|
||||||
main.set_tab_to_close(this);
|
main.set_tab_to_close(this);
|
||||||
netClient = nullptr;
|
netClient = nullptr;
|
||||||
|
|
@ -383,7 +385,7 @@ void World::send_chat_message(const std::string& message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::add_chat_message(const std::string& name, const std::string& message, Toolbar::ChatMessage::Type type) {
|
void World::add_chat_message(const std::string& name, const std::string& message, Toolbar::ChatMessage::Type type) {
|
||||||
Logger::get().log("CHAT", type == Toolbar::ChatMessage::JOIN ? (name + " " + message) : ("[" + name + "] " + message));
|
Logger::get().log(Logger::LogType::CHAT, type == Toolbar::ChatMessage::JOIN ? (name + " " + message) : ("[" + name + "] " + message));
|
||||||
chatMessages.emplace_front(Toolbar::ChatMessage{name, message, type});
|
chatMessages.emplace_front(Toolbar::ChatMessage{name, message, type});
|
||||||
if(chatMessages.size() == CHAT_SIZE)
|
if(chatMessages.size() == CHAT_SIZE)
|
||||||
chatMessages.pop_back();
|
chatMessages.pop_back();
|
||||||
|
|
@ -523,11 +525,11 @@ void World::save_to_file(const std::filesystem::path& filePathToSaveAt) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Logger::get().log("USERINFO", "File saved");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "File saved");
|
||||||
undo.set_save_action();
|
undo.set_save_action();
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("WORLDFATAL", std::string("Save error: ") + e.what());
|
Logger::get().log(Logger::LogType::WORLDFATAL, std::string("Save error: ") + e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -573,12 +575,12 @@ void World::load_from_file(const std::filesystem::path& filePathToLoadFrom, std:
|
||||||
|
|
||||||
ByteMemStream f((char*)uncompressedDataView.data(), uncompressedDataView.size());
|
ByteMemStream f((char*)uncompressedDataView.data(), uncompressedDataView.size());
|
||||||
|
|
||||||
Logger::get().log("INFO", "Loading file from version " + version_numbers_to_version_str(fileVersion));
|
Logger::get().log(Logger::LogType::INFO, "Loading file from version " + version_numbers_to_version_str(fileVersion));
|
||||||
|
|
||||||
cereal::PortableBinaryInputArchive a(f);
|
cereal::PortableBinaryInputArchive a(f);
|
||||||
load_file(a, fileVersion);
|
load_file(a, fileVersion);
|
||||||
|
|
||||||
Logger::get().log("USERINFO", "File loaded");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "File loaded");
|
||||||
set_name(filePath.stem().string());
|
set_name(filePath.stem().string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -621,7 +623,7 @@ void World::scale_up_step() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::scale_up(const WorldScalar& scaleUpAmount) {
|
void World::scale_up(const WorldScalar& scaleUpAmount) {
|
||||||
Logger::get().log("USERINFO", "Canvas scaled up");
|
Logger::get().log(Logger::LogType::DESKTOP_USERINFO, "Canvas scaled up");
|
||||||
bMan.scale_up(scaleUpAmount);
|
bMan.scale_up(scaleUpAmount);
|
||||||
gridMan.scale_up(scaleUpAmount);
|
gridMan.scale_up(scaleUpAmount);
|
||||||
drawData.cam.scale_up(*this, scaleUpAmount);
|
drawData.cam.scale_up(*this, scaleUpAmount);
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ void world_take_screenshot(const std::shared_ptr<World>& w, const WorldScreensho
|
||||||
sk_sp<SkSurface> surface = w->main.create_native_surface(w->main.window.size, true);
|
sk_sp<SkSurface> surface = w->main.create_native_surface(w->main.window.size, true);
|
||||||
SkCanvas* screenshotCanvas = surface->getCanvas();
|
SkCanvas* screenshotCanvas = surface->getCanvas();
|
||||||
if(!screenshotCanvas) {
|
if(!screenshotCanvas) {
|
||||||
Logger::get().log("INFO", "Screenshot Tool could not make canvas");
|
Logger::get().log(Logger::LogType::INFO, "[world_take_screenshot] Could not make canvas");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ void world_take_screenshot(const std::shared_ptr<World>& w, const WorldScreensho
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!success) {
|
if(!success) {
|
||||||
Logger::get().log("WORLDFATAL", "[ScreenshotTool::take_screenshot] Could not encode and write screenshot");
|
Logger::get().log(Logger::LogType::WORLDFATAL, "[world_take_screenshot] Could not encode and write screenshot");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
@ -104,7 +104,7 @@ void world_take_screenshot(const std::shared_ptr<World>& w, const WorldScreensho
|
||||||
throw std::runtime_error("SDL_SaveFile failed with error: " + std::string(SDL_GetError()));
|
throw std::runtime_error("SDL_SaveFile failed with error: " + std::string(SDL_GetError()));
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("WORLDFATAL", std::string("[ScreenshotTool::take_screenshot] Save screenshot error: ") + e.what());
|
Logger::get().log(Logger::LogType::WORLDFATAL, std::string("[world_take_screenshot] Save screenshot error: ") + e.what());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(success) {
|
if(success) {
|
||||||
|
|
@ -133,7 +133,7 @@ void world_take_screenshot(const std::shared_ptr<World>& w, const WorldScreensho
|
||||||
throw std::runtime_error("SDL_SaveFile failed with error: " + std::string(SDL_GetError()));
|
throw std::runtime_error("SDL_SaveFile failed with error: " + std::string(SDL_GetError()));
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("WORLDFATAL", std::string("[ScreenshotTool::take_screenshot] Save screenshot error: ") + e.what());
|
Logger::get().log(Logger::LogType::WORLDFATAL, std::string("[world_take_screenshot] Save screenshot error: ") + e.what());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
auto skData = out.detachAsData();
|
auto skData = out.detachAsData();
|
||||||
|
|
@ -210,7 +210,7 @@ void take_screenshot_area_hw(const std::shared_ptr<World>& w, const sk_sp<SkSurf
|
||||||
void* fullImgRawDataStartPt = (uint8_t*)fullImgRawData + 4 * (size_t)sectionImagePos.x() + 4 * (size_t)fullImageSize.x() * (size_t)sectionImagePos.y();
|
void* fullImgRawDataStartPt = (uint8_t*)fullImgRawData + 4 * (size_t)sectionImagePos.x() + 4 * (size_t)fullImageSize.x() * (size_t)sectionImagePos.y();
|
||||||
SkPixmap aaImgData(aaImgInfo, fullImgRawDataStartPt, fullImageSize.x() * 4);
|
SkPixmap aaImgData(aaImgInfo, fullImgRawDataStartPt, fullImageSize.x() * 4);
|
||||||
if(!surface->readPixels(aaImgData, 0, 0))
|
if(!surface->readPixels(aaImgData, 0, 0))
|
||||||
throw std::runtime_error("[ScreenshotTool::take_screenshot_area_hw] Error copy pixmap");
|
throw std::runtime_error("[take_screenshot_area_hw] Error copy pixmap");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string world_screenshot_info_get_extension_from_type(WorldScreenshotInfo::ScreenshotType t) {
|
std::string world_screenshot_info_get_extension_from_type(WorldScreenshotInfo::ScreenshotType t) {
|
||||||
|
|
|
||||||
24
src/main.cpp
24
src/main.cpp
|
|
@ -300,7 +300,7 @@ void initialize_sdl(MainStruct& mS, int wWidth, int wHeight) {
|
||||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mS.defaultFBO);
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mS.defaultFBO);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Logger::get().log("INFO", "GL Version: " + std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
|
Logger::get().log(Logger::LogType::INFO, "GL Version: " + std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -375,18 +375,18 @@ void init_logs(MainStruct& mS) {
|
||||||
SDL_free(configPathSDL);
|
SDL_free(configPathSDL);
|
||||||
#endif
|
#endif
|
||||||
mS.logFile = std::ofstream(mS.configPath / "log.txt");
|
mS.logFile = std::ofstream(mS.configPath / "log.txt");
|
||||||
Logger::get().add_log("FATAL", [&, mS = &mS](const std::string& text) {
|
Logger::get().set_log_function(Logger::LogType::FATAL, [&, mS = &mS](const std::string& text) {
|
||||||
mS->logFile << "[FATAL] " << text << std::endl;
|
mS->logFile << "[FATAL] " << text << std::endl;
|
||||||
std::cerr << "[FATAL] " << text << std::endl;
|
std::cerr << "[FATAL] " << text << std::endl;
|
||||||
mS->logFile.close();
|
mS->logFile.close();
|
||||||
});
|
});
|
||||||
Logger::get().add_log("INFO", [&, mS = &mS](const std::string& text) {
|
Logger::get().set_log_function(Logger::LogType::INFO, [&, mS = &mS](const std::string& text) {
|
||||||
mS->logFile << "[INFO] " << text << std::endl;
|
mS->logFile << "[INFO] " << text << std::endl;
|
||||||
Logger::get().cross_platform_println("[INFO] " + text);
|
Logger::get().cross_platform_println("[INFO] " + text);
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger::get().log("INFO", "Home Path: " + mS.homePath.string());
|
Logger::get().log(Logger::LogType::INFO, "Home Path: " + mS.homePath.string());
|
||||||
Logger::get().log("INFO", "Config Path: " + mS.configPath.string());
|
Logger::get().log(Logger::LogType::INFO, "Config Path: " + mS.configPath.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
|
|
@ -572,7 +572,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("FATAL", e.what());
|
Logger::get().log(Logger::LogType::FATAL, e.what());
|
||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -648,7 +648,7 @@ SDL_AppResult SDL_AppIterate(void *appstate) {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("FATAL", e.what());
|
Logger::get().log(Logger::LogType::FATAL, e.what());
|
||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -666,16 +666,16 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
||||||
#endif
|
#endif
|
||||||
switch(event->type) {
|
switch(event->type) {
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
Logger::get().log("INFO", "[SDL_AppEvent] Quit");
|
Logger::get().log(Logger::LogType::INFO, "[SDL_AppEvent] Quit");
|
||||||
if(mS.m->app_close_requested())
|
if(mS.m->app_close_requested())
|
||||||
return SDL_APP_SUCCESS;
|
return SDL_APP_SUCCESS;
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WILL_ENTER_BACKGROUND:
|
case SDL_EVENT_WILL_ENTER_BACKGROUND:
|
||||||
Logger::get().log("INFO", "[SDL_AppEvent] Entering background");
|
Logger::get().log(Logger::LogType::INFO, "[SDL_AppEvent] Entering background");
|
||||||
mS.m->input_app_about_to_go_to_background_callback();
|
mS.m->input_app_about_to_go_to_background_callback();
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WILL_ENTER_FOREGROUND:
|
case SDL_EVENT_WILL_ENTER_FOREGROUND:
|
||||||
Logger::get().log("INFO", "[SDL_AppEvent] Entering foreground");
|
Logger::get().log(Logger::LogType::INFO, "[SDL_AppEvent] Entering foreground");
|
||||||
mS.m->input_app_about_to_go_to_foreground_callback();
|
mS.m->input_app_about_to_go_to_foreground_callback();
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||||
|
|
@ -835,7 +835,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("FATAL", e.what());
|
Logger::get().log(Logger::LogType::FATAL, e.what());
|
||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -861,7 +861,7 @@ void SDL_AppQuit(void *appstate, SDL_AppResult result) {
|
||||||
sdl_terminate(mS);
|
sdl_terminate(mS);
|
||||||
}
|
}
|
||||||
catch(const std::exception& e) {
|
catch(const std::exception& e) {
|
||||||
Logger::get().log("FATAL", e.what());
|
Logger::get().log(Logger::LogType::FATAL, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete (&mS);
|
delete (&mS);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue